use of cfml.parsing.cfscript.script.CFFuncDeclStatement in project CFLint by cflint.
the class MethodNameChecker method expression.
@Override
public void expression(final CFScriptStatement expression, final Context context, final BugList bugs) {
if (expression instanceof CFFuncDeclStatement) {
final CFFuncDeclStatement method = (CFFuncDeclStatement) expression;
final int lineNo = method.getLine() + context.startLine() - 1;
checkNameForBugs(context, lineNo);
}
}
use of cfml.parsing.cfscript.script.CFFuncDeclStatement in project CFLint by cflint.
the class FunctionTypeChecker method expression.
@Override
public void expression(final CFScriptStatement expression, final Context context, final BugList bugs) {
if (expression instanceof CFFuncDeclStatement) {
final CFFuncDeclStatement function = (CFFuncDeclStatement) expression;
final int begLine = function.getLine();
final String functionType = function.getReturnType() == null ? null : function.getReturnType().toString();
checkReturnType(functionType, begLine, context, bugs);
}
}
use of cfml.parsing.cfscript.script.CFFuncDeclStatement in project CFLint by cflint.
the class UnusedArgumentChecker method expression.
@Override
public void expression(final CFScriptStatement expression, final Context context, final BugList bugs) {
if (expression instanceof CFFuncDeclStatement) {
final CFFuncDeclStatement function = (CFFuncDeclStatement) expression;
for (final CFFunctionParameter argument : function.getFormals()) {
// CF
final String name = argument.getName().toLowerCase();
// variable
// names
// are
// not
// case
// sensitive
methodArguments.put(name, false);
// close enough?
setArgumentLineNo(name, function.getLine());
if (isUsed(function.Decompile(0), name)) {
methodArguments.put(name, true);
}
}
}
}
use of cfml.parsing.cfscript.script.CFFuncDeclStatement in project CFLint by cflint.
the class FunctionHintChecker method expression.
@Override
public void expression(CFScriptStatement expression, Context context, BugList bugs) {
if (expression instanceof CFFuncDeclStatement) {
final CFFuncDeclStatement funcDeclStatement = (CFFuncDeclStatement) expression;
final CFExpression hintAttribute = CFTool.convertMap(funcDeclStatement.getAttributes()).get("hint");
if (hintAttribute == null) {
final String _mlText = PrecedingCommentReader.getMultiLine(context, expression.getToken());
final String mlText = _mlText == null ? null : _mlText.replaceFirst("^/\\*", "").replaceAll("\\*/$", "").trim();
if (mlText != null && !mlText.isEmpty()) {
final Pattern pattern = Pattern.compile(".*\\s*@hint\\s+([\\w,_]+)\\s*.*", Pattern.DOTALL);
final Matcher matcher = pattern.matcher(mlText);
if (matcher.matches()) {
String hintText = matcher.group(1);
if (hintText.trim().isEmpty()) {
context.addMessage("FUNCTION_HINT_MISSING", context.getFunctionName());
}
}
} else {
context.addMessage("FUNCTION_HINT_MISSING", context.getFunctionName());
}
}
}
}
use of cfml.parsing.cfscript.script.CFFuncDeclStatement in project CFLint by cflint.
the class FunctionLengthChecker method expression.
@Override
public void expression(final CFScriptStatement expression, final Context context, final BugList bugs) {
if (expression instanceof CFFuncDeclStatement) {
final CFFuncDeclStatement function = (CFFuncDeclStatement) expression;
final String decompile = function.Decompile(1);
final int begLine = function.getLine();
final String[] lines = decompile.split("\\n");
checkSize(context, begLine, lines.length, bugs);
}
}
Aggregations