diff --git a/README.md b/README.md index 332ec84c3..b8a8dfec1 100644 --- a/README.md +++ b/README.md @@ -470,7 +470,7 @@ Parameters within the rules can be overridden in the .cflintrc files. Use the r ```json { "parameters" : { - "VariableNameChecker.MaxLength": "15" + "VariableNameChecker.maxLength": "15" } } ``` diff --git a/src/main/java/com/cflint/plugins/core/ArgumentNameChecker.java b/src/main/java/com/cflint/plugins/core/ArgumentNameChecker.java index 956b72484..9826eed53 100644 --- a/src/main/java/com/cflint/plugins/core/ArgumentNameChecker.java +++ b/src/main/java/com/cflint/plugins/core/ArgumentNameChecker.java @@ -20,17 +20,17 @@ public class ArgumentNameChecker extends CFLintScannerAdapter { /** * Name of minimum length parameter. */ - private static final String MIN_LENGTH = "MinLength"; + private static final String MIN_LENGTH = "minLength"; /** * Name of maximum length parameter. */ - private static final String MAX_LENGTH = "MaxLength"; + private static final String MAX_LENGTH = "maxLength"; /** * Name of maximum words parameter. */ - private static final String MAX_WORDS = "MaxWords"; + private static final String MAX_WORDS = "maxWords"; /** * List of disallowed prefix names. diff --git a/src/main/java/com/cflint/plugins/core/ComponentNameChecker.java b/src/main/java/com/cflint/plugins/core/ComponentNameChecker.java index ed22967b3..29e693c96 100644 --- a/src/main/java/com/cflint/plugins/core/ComponentNameChecker.java +++ b/src/main/java/com/cflint/plugins/core/ComponentNameChecker.java @@ -82,25 +82,25 @@ private String actualFileName(final String fileName) { * See @ValidName for defaults. */ private void parseParameters(CFLintConfiguration configuration) throws ConfigError { - if (configuration.getParameter(this,"MinLength") != null) { + if (configuration.getParameter(this,"minLength") != null) { try { - minComponentLength = Integer.parseInt(configuration.getParameter(this,"MinLength")); + minComponentLength = Integer.parseInt(configuration.getParameter(this,"minLength")); } catch (final Exception e) { throw new ConfigError("Minimum length need to be an integer."); } } - if (configuration.getParameter(this,"MaxLength") != null) { + if (configuration.getParameter(this,"maxLength") != null) { try { - maxComponentLength = Integer.parseInt(configuration.getParameter(this,"MaxLength")); + maxComponentLength = Integer.parseInt(configuration.getParameter(this,"maxLength")); } catch (final Exception e) { throw new ConfigError("Maximum length need to be an integer."); } } - if (configuration.getParameter(this,"MaxWords") != null) { + if (configuration.getParameter(this,"maxWords") != null) { try { - maxComponentWords = Integer.parseInt(configuration.getParameter(this,"MaxWords")); + maxComponentWords = Integer.parseInt(configuration.getParameter(this,"maxWords")); } catch (final Exception e) { throw new ConfigError("Maximum no of words need to be an integer."); } diff --git a/src/main/java/com/cflint/plugins/core/LiteralChecker.java b/src/main/java/com/cflint/plugins/core/LiteralChecker.java index 88e56fcd5..e19ed3e98 100644 --- a/src/main/java/com/cflint/plugins/core/LiteralChecker.java +++ b/src/main/java/com/cflint/plugins/core/LiteralChecker.java @@ -29,9 +29,9 @@ public class LiteralChecker extends CFLintScannerAdapter { @Override public void expression(final CFExpression expression, final Context context, final BugList bugs) { - final String repeatThreshold = context.getConfiguration().getParameter(this,"Maximum"); - final String maxWarnings = context.getConfiguration().getParameter(this,"MaxWarnings"); - final String warningScope = context.getConfiguration().getParameter(this,"WarningScope"); + final String repeatThreshold = context.getConfiguration().getParameter(this,"maximum"); + final String maxWarnings = context.getConfiguration().getParameter(this,"maxWarnings"); + final String warningScope = context.getConfiguration().getParameter(this,"warningScope"); if (repeatThreshold != null) { threshold = Integer.parseInt(repeatThreshold); @@ -112,7 +112,7 @@ private boolean isSpecial(final String name) { return true; } //Check ignore words list from the configuration - return getParameterAsList("IgnoreWords").contains(name.toLowerCase()); + return getParameterAsList("ignoreWords").contains(name.toLowerCase()); } public void magicLocalValue(final String name, final int lineNo, final int offset, final Context context, final BugList bugs, CFExpression expression) { diff --git a/src/main/java/com/cflint/plugins/core/MethodNameChecker.java b/src/main/java/com/cflint/plugins/core/MethodNameChecker.java index 92b2084a8..0fc6d0a63 100644 --- a/src/main/java/com/cflint/plugins/core/MethodNameChecker.java +++ b/src/main/java/com/cflint/plugins/core/MethodNameChecker.java @@ -68,25 +68,25 @@ public void element(final Element element, final Context context, final BugList * See @ValidName for defaults. */ private void parseParameters(CFLintConfiguration configuration) throws ConfigError { - if (configuration.getParameter(this,"MinLength") != null) { + if (configuration.getParameter(this,"minLength") != null) { try { - minMethodLength = Integer.parseInt(configuration.getParameter(this,"MinLength")); + minMethodLength = Integer.parseInt(configuration.getParameter(this,"minLength")); } catch (final Exception e) { throw new ConfigError("Minimum length need to be an integer."); } } - if (configuration.getParameter(this,"MaxLength") != null) { + if (configuration.getParameter(this,"maxLength") != null) { try { - maxMethodLength = Integer.parseInt(configuration.getParameter(this,"MaxLength")); + maxMethodLength = Integer.parseInt(configuration.getParameter(this,"maxLength")); } catch (final Exception e) { throw new ConfigError("Maximum length need to be an integer."); } } - if (configuration.getParameter(this,"MaxWords") != null) { + if (configuration.getParameter(this,"maxWords") != null) { try { - maxMethodWords = Integer.parseInt(configuration.getParameter(this,"MaxWords")); + maxMethodWords = Integer.parseInt(configuration.getParameter(this,"maxWords")); } catch (final Exception e) { throw new ConfigError("Maximum no of words need to be an integer."); } diff --git a/src/main/java/com/cflint/plugins/core/UnusedLocalVarChecker.java b/src/main/java/com/cflint/plugins/core/UnusedLocalVarChecker.java index 3dde3ebf9..b0ac94497 100644 --- a/src/main/java/com/cflint/plugins/core/UnusedLocalVarChecker.java +++ b/src/main/java/com/cflint/plugins/core/UnusedLocalVarChecker.java @@ -122,7 +122,7 @@ public void element(final Element element, final Context context, final BugList @SuppressWarnings("unchecked") private void checkAttributes(final Element element, final CFLintConfiguration configuration) { - for (String tagInfo : (List)configuration.getParameter(this,"UsedTagAttributes", List.class)) { + for (String tagInfo : (List)configuration.getParameter(this,"usedTagAttributes", List.class)) { final String[] parts = (tagInfo + "//").split("/"); if (element.getName() != null && parts[0].equalsIgnoreCase(element.getName())) { final String name = element.getAttributeValue(parts[1]); diff --git a/src/main/java/com/cflint/plugins/core/ValidName.java b/src/main/java/com/cflint/plugins/core/ValidName.java index 3b30b00f5..465301f40 100644 --- a/src/main/java/com/cflint/plugins/core/ValidName.java +++ b/src/main/java/com/cflint/plugins/core/ValidName.java @@ -358,15 +358,15 @@ public void setRequiredPrefixList(final String[] prefixes) { this.requiredPrefixes = prefixes; } - public void setMinLength(int minLength) { + public void setminLength(int minLength) { this.minLength = minLength; } - public void setMaxLength(int maxLength) { + public void setmaxLength(int maxLength) { this.maxLength = maxLength; } - public void setMaxWords(int maxWords) { + public void setmaxWords(int maxWords) { this.maxWords = maxWords; } } diff --git a/src/main/java/com/cflint/plugins/core/VariableNameChecker.java b/src/main/java/com/cflint/plugins/core/VariableNameChecker.java index 4f1b7b3df..b0781957e 100644 --- a/src/main/java/com/cflint/plugins/core/VariableNameChecker.java +++ b/src/main/java/com/cflint/plugins/core/VariableNameChecker.java @@ -139,28 +139,28 @@ private void checkExpression(final CFExpression expression, final Context contex } private void parseParameters(final ValidName name, CFLintConfiguration configuration) throws ConfigError { - if (configuration.getParameter(this,"MinLength") != null) { + if (configuration.getParameter(this,"minLength") != null) { try { - minVarLength = Integer.parseInt(configuration.getParameter(this,"MinLength")); - name.setMinLength(minVarLength); + minVarLength = Integer.parseInt(configuration.getParameter(this,"minLength")); + name.setminLength(minVarLength); } catch (final Exception e) { throw new ConfigError("Minimum length need to be an integer."); } } - if (configuration.getParameter(this,"MaxLength") != null) { + if (configuration.getParameter(this,"maxLength") != null) { try { - maxVarLength = Integer.parseInt(configuration.getParameter(this,"MaxLength")); - name.setMaxLength(maxVarLength); + maxVarLength = Integer.parseInt(configuration.getParameter(this,"maxLength")); + name.setmaxLength(maxVarLength); } catch (final Exception e) { throw new ConfigError("Maximum length need to be an integer."); } } - if (configuration.getParameter(this,"MaxWords") != null) { + if (configuration.getParameter(this,"maxWords") != null) { try { - maxVarWords = Integer.parseInt(configuration.getParameter(this,"MaxWords")); - name.setMaxWords(maxVarWords); + maxVarWords = Integer.parseInt(configuration.getParameter(this,"maxWords")); + name.setmaxWords(maxVarWords); } catch (final Exception e) { throw new ConfigError("Maximum no of words need to be an integer."); } @@ -199,10 +199,10 @@ public void checkNameForBugs(final Context context, final String fullVariable, f if (name.isInvalid(variable,context.getConfiguration().getParameter(this, "case"))) { parent.addUniqueMessage("VAR_INVALID_NAME", variable, this, line, offset, cfExpression); } - if (!scope.isCFScoped(variable) && name.isUpperCase(variable) && !context.getConfiguration().getParameterNotNull(this,"IgnoreAllCapsInScopes").toLowerCase().contains(varScope)) { + if (!scope.isCFScoped(variable) && name.isUpperCase(variable) && !context.getConfiguration().getParameterNotNull(this,"ignoreAllCapsInScopes").toLowerCase().contains(varScope)) { parent.addUniqueMessage("VAR_ALLCAPS_NAME", variable, this, line, offset, cfExpression); } - if (scope.isCFScoped(variable) && name.isUpperCase(variable) && !context.getConfiguration().getParameterNotNull(this,"IgnoreUpperCaseScopes").contains(variable)) { + if (scope.isCFScoped(variable) && name.isUpperCase(variable) && !context.getConfiguration().getParameterNotNull(this,"ignoreUpperCaseScopes").contains(variable)) { parent.addUniqueMessage("SCOPE_ALLCAPS_NAME", variable, this, line, offset, cfExpression); } if (name.tooShort(variable)) { @@ -217,7 +217,7 @@ public void checkNameForBugs(final Context context, final String fullVariable, f if (name.isTemporary(variable)) { parent.addUniqueMessage("VAR_IS_TEMPORARY", variable, this, line, offset, cfExpression); } - if (name.hasPrefixOrPostfix(variable) && !context.getConfiguration().getParameterNotNull(this,"IgnorePrefixPostfixOn").contains(variable)) { + if (name.hasPrefixOrPostfix(variable) && !context.getConfiguration().getParameterNotNull(this,"ignorePrefixPostfixOn").contains(variable)) { parent.addUniqueMessage("VAR_HAS_PREFIX_OR_POSTFIX", variable, this, line, offset, cfExpression); } } diff --git a/src/main/resources/cflint.definition.json b/src/main/resources/cflint.definition.json index ca0fa8851..041c0d41f 100644 --- a/src/main/resources/cflint.definition.json +++ b/src/main/resources/cflint.definition.json @@ -524,12 +524,12 @@ { "code": "VAR_TOO_SHORT", "severity": "INFO", - "messageText": "Variable ${variable} should be longer than ${MinLength} characters." + "messageText": "Variable ${variable} should be longer than ${minLength} characters." }, { "code": "VAR_TOO_LONG", "severity": "INFO", - "messageText": "Variable ${variable} should be shorter than ${MaxLength} characters." + "messageText": "Variable ${variable} should be shorter than ${maxLength} characters." }, { "code": "VAR_TOO_WORDY", @@ -549,27 +549,27 @@ ], "parameter": [ { - "name": "MinLength", + "name": "minLength", "value": "3" }, { - "name": "MaxLength", + "name": "maxLength", "value": "20" }, { - "name": "MaxWords", + "name": "maxWords", "value": "4" }, { - "name": "IgnoreUpperCaseScopes", + "name": "ignoreUpperCaseScopes", "value": "CGI,URL" }, { - "name": "IgnoreAllCapsInScopes", + "name": "ignoreAllCapsInScopes", "value": "this,variables" }, { - "name": "IgnorePrefixPostfixOn", + "name": "ignorePrefixPostfixOn", "value": "thisTag" }, { @@ -600,12 +600,12 @@ { "code": "ARGUMENT_TOO_SHORT", "severity": "INFO", - "messageText": "Argument ${variable} should be longer than ${MinLength} characters." + "messageText": "Argument ${variable} should be longer than ${minLength} characters." }, { "code": "ARGUMENT_TOO_LONG", "severity": "INFO", - "messageText": "Argument ${variable} should be shorter than ${MaxLength} characters." + "messageText": "Argument ${variable} should be shorter than ${maxLength} characters." }, { "code": "ARGUMENT_TOO_WORDY", @@ -625,15 +625,15 @@ ], "parameter": [ { - "name": "MinLength", + "name": "minLength", "value": "3" }, { - "name": "MaxLength", + "name": "maxLength", "value": "20" }, { - "name": "MaxWords", + "name": "maxWords", "value": "4" }, { @@ -659,12 +659,12 @@ { "code": "METHOD_TOO_SHORT", "severity": "INFO", - "messageText": "Method name ${function} should be longer than ${MinLength} characters." + "messageText": "Method name ${function} should be longer than ${minLength} characters." }, { "code": "METHOD_TOO_LONG", "severity": "INFO", - "messageText": "Method name ${function} should be shorter than ${MaxLength} characters." + "messageText": "Method name ${function} should be shorter than ${maxLength} characters." }, { "code": "METHOD_TOO_WORDY", @@ -684,15 +684,15 @@ ], "parameter": [ { - "name": "MinLength", + "name": "minLength", "value": "3" }, { - "name": "MaxLength", + "name": "maxLength", "value": "25" }, { - "name": "MaxWords", + "name": "maxWords", "value": "5" }, { @@ -718,12 +718,12 @@ { "code": "COMPONENT_TOO_SHORT", "severity": "INFO", - "messageText": "Component name ${component} should be longer than ${MinLength} characters." + "messageText": "Component name ${component} should be longer than ${minLength} characters." }, { "code": "COMPONENT_TOO_LONG", "severity": "INFO", - "messageText": "Component name ${component} should be shorter than ${MaxLength} characters." + "messageText": "Component name ${component} should be shorter than ${maxLength} characters." }, { "code": "COMPONENT_TOO_WORDY", @@ -743,15 +743,15 @@ ], "parameter": [ { - "name": "MinLength", + "name": "minLength", "value": "3" }, { - "name": "MaxLength", + "name": "maxLength", "value": "15" }, { - "name": "MaxWords", + "name": "maxWords", "value": "3" }, { @@ -813,7 +813,7 @@ ], "parameter": [ { - "name": "UsedTagAttributes", + "name": "usedTagAttributes", "value": [ "cfquery/name", "cfloop/index", @@ -921,19 +921,19 @@ ], "parameter": [ { - "name": "Maximum", + "name": "maximum", "value": "3" }, { - "name": "MaxWarnings", + "name": "maxWarnings", "value": "5" }, { - "name": "WarningScope", + "name": "warningScope", "value": "global" }, { - "name": "IgnoreWords", + "name": "ignoreWords", "value": "numeric,text,textnocase,asc,desc,in,out,inout,one,all,bigdecimal,boolean,byte,char,int,long,float,double,short,string,null" } ] @@ -950,19 +950,19 @@ ], "parameter": [ { - "name": "Maximum", + "name": "maximum", "value": "3" }, { - "name": "MaxWarnings", + "name": "maxWarnings", "value": "5" }, { - "name": "WarningScope", + "name": "warningScope", "value": "local" }, { - "name": "IgnoreWords", + "name": "ignoreWords", "value": "numeric,text,textnocase,asc,desc,in,out,inout,one,all,bigdecimal,boolean,byte,char,int,long,float,double,short,string,null" } ] diff --git a/src/test/resources/com/cflint/tests/VariableNameChecker/config/.cflintrc b/src/test/resources/com/cflint/tests/VariableNameChecker/config/.cflintrc index 348bde2ea..d1aa5e359 100644 --- a/src/test/resources/com/cflint/tests/VariableNameChecker/config/.cflintrc +++ b/src/test/resources/com/cflint/tests/VariableNameChecker/config/.cflintrc @@ -22,12 +22,12 @@ { "code": "VAR_TOO_SHORT", "severity": "INFO", - "messageText": "Variable ${variable} SHORTER THAN ${MinLength}!" + "messageText": "Variable ${variable} SHORTER THAN ${minLength}!" }, { "code": "VAR_TOO_LONG", "severity": "INFO", - "messageText" : "Variable ${variable} LONGER THAN ${MaxLength}!" + "messageText" : "Variable ${variable} LONGER THAN ${maxLength}!" }, { "code": "VAR_TOO_WORDY", @@ -47,27 +47,27 @@ ], "parameter": [ { - "name": "MinLength", + "name": "minLength", "value": "4" }, { - "name": "MaxLength", + "name": "maxLength", "value": "15" }, { - "name": "MaxWords", + "name": "maxWords", "value": "5" }, { - "name": "IgnoreUpperCaseScopes", + "name": "ignoreUpperCaseScopes", "value": "CGI,URL,REQUEST" }, { - "name": "IgnoreAllCapsInScopes", + "name": "ignoreAllCapsInScopes", "value": "this,variables,otherscope" }, { - "name": "IgnorePrefixPostfixOn", + "name": "ignorePrefixPostfixOn", "value": "thisTag,thatTag" } ] diff --git a/src/test/resources/com/cflint/tests/VariableNameChecker/config2/.cflintrc b/src/test/resources/com/cflint/tests/VariableNameChecker/config2/.cflintrc index 4b5c667f1..294771390 100644 --- a/src/test/resources/com/cflint/tests/VariableNameChecker/config2/.cflintrc +++ b/src/test/resources/com/cflint/tests/VariableNameChecker/config2/.cflintrc @@ -2,7 +2,7 @@ "inheritParent" : true, "parameters": { - "VariableNameChecker.MinLength": "4", - "VariableNameChecker.MaxLength": "15" + "VariableNameChecker.minLength": "4", + "VariableNameChecker.maxLength": "15" } } \ No newline at end of file