Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ryaneberly committed Dec 28, 2017
1 parent 0ce1e87 commit 7eb4240
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 78 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/cflint/plugins/core/ComponentNameChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/cflint/plugins/core/LiteralChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/cflint/plugins/core/MethodNameChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>)configuration.getParameter(this,"UsedTagAttributes", List.class)) {
for (String tagInfo : (List<String>)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]);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/cflint/plugins/core/ValidName.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
24 changes: 12 additions & 12 deletions src/main/java/com/cflint/plugins/core/VariableNameChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
Expand Down Expand Up @@ -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)) {
Expand All @@ -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);
}
}
Expand Down
Loading

0 comments on commit 7eb4240

Please sign in to comment.