Search in sources :

Example 6 with CFFuncDeclStatement

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);
    }
}
Also used : CFFuncDeclStatement(cfml.parsing.cfscript.script.CFFuncDeclStatement)

Example 7 with CFFuncDeclStatement

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);
    }
}
Also used : CFFuncDeclStatement(cfml.parsing.cfscript.script.CFFuncDeclStatement)

Example 8 with CFFuncDeclStatement

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);
            }
        }
    }
}
Also used : CFFuncDeclStatement(cfml.parsing.cfscript.script.CFFuncDeclStatement) CFFunctionParameter(cfml.parsing.cfscript.script.CFFunctionParameter)

Example 9 with CFFuncDeclStatement

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());
            }
        }
    }
}
Also used : CFFuncDeclStatement(cfml.parsing.cfscript.script.CFFuncDeclStatement) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) CFExpression(cfml.parsing.cfscript.CFExpression)

Example 10 with CFFuncDeclStatement

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);
    }
}
Also used : CFFuncDeclStatement(cfml.parsing.cfscript.script.CFFuncDeclStatement)

Aggregations

CFFuncDeclStatement (cfml.parsing.cfscript.script.CFFuncDeclStatement)12 CFFunctionParameter (cfml.parsing.cfscript.script.CFFunctionParameter)6 CFExpression (cfml.parsing.cfscript.CFExpression)2 CFForInStatement (cfml.parsing.cfscript.script.CFForInStatement)2 CFTryCatchStatement (cfml.parsing.cfscript.script.CFTryCatchStatement)2 IOException (java.io.IOException)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 CFIdentifier (cfml.parsing.cfscript.CFIdentifier)1 CFCase (cfml.parsing.cfscript.script.CFCase)1 CFCatchStatement (cfml.parsing.cfscript.script.CFCatchStatement)1 CFCompDeclStatement (cfml.parsing.cfscript.script.CFCompDeclStatement)1 CFCompoundStatement (cfml.parsing.cfscript.script.CFCompoundStatement)1 CFDoWhileStatement (cfml.parsing.cfscript.script.CFDoWhileStatement)1 CFExpressionStatement (cfml.parsing.cfscript.script.CFExpressionStatement)1 CFForStatement (cfml.parsing.cfscript.script.CFForStatement)1 CFIfStatement (cfml.parsing.cfscript.script.CFIfStatement)1 CFPropertyStatement (cfml.parsing.cfscript.script.CFPropertyStatement)1 CFReturnStatement (cfml.parsing.cfscript.script.CFReturnStatement)1 CFScriptStatement (cfml.parsing.cfscript.script.CFScriptStatement)1