Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/522_colu' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ryaneberly committed May 5, 2018
2 parents 53ac951 + 4685a05 commit 2957314
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/java/com/cflint/CFLint.java
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,12 @@ public void reportRule(final Element elem, final Object currentExpression, final
bldr.setRuleParameters(ruleInfo.getParameters());
if (configuration.includes(ruleInfo.getMessageByCode(msgcode))
&& !configuration.excludes(ruleInfo.getMessageByCode(msgcode))) {
//A bit of a hack to fix the offset issue
//This could be handled better at the source where line and offset are calc'd.
int idxOffSet = 1;
if(lineOffsets != null && msg.getLine()!=null && msg.getOffset() != null && msg.getOffset() >=lineOffsets[msg.getLine()] ){
idxOffSet=0;
}
if (expression instanceof CFExpression) {
final BugInfo bugInfo = bldr.build((CFExpression) expression, elem);
final Token token = ((CFExpression) expression).getToken();
Expand All @@ -1340,9 +1346,9 @@ public void reportRule(final Element elem, final Object currentExpression, final
bugInfo.setLine(msg.getLine());
if (msg.getOffset() != null) {
bugInfo.setOffset(msg.getOffset());
bugInfo.setColumn(msg.getOffset() - lineOffsets[msg.getLine() - 1]);
bugInfo.setColumn(msg.getOffset() - lineOffsets[msg.getLine() - idxOffSet]);
} else {
bugInfo.setOffset(lineOffsets != null ? lineOffsets[msg.getLine() - 1] : 0);
bugInfo.setOffset(lineOffsets != null ? lineOffsets[msg.getLine() - idxOffSet] : 0);
bugInfo.setColumn(0);
}
}
Expand All @@ -1353,9 +1359,9 @@ public void reportRule(final Element elem, final Object currentExpression, final
bug.setLine(msg.getLine());
if (msg.getOffset() != null) {
bug.setOffset(msg.getOffset());
bug.setColumn(msg.getOffset() - lineOffsets[msg.getLine() - 1]);
bug.setColumn(msg.getOffset() - lineOffsets[msg.getLine() - idxOffSet]);
} else {
bug.setOffset(lineOffsets != null ? lineOffsets[msg.getLine() - 1] : 0);
bug.setOffset(lineOffsets != null ? lineOffsets[msg.getLine() - idxOffSet] : 0);
bug.setColumn(0);
}
bug.setLength(msg.getVariable() != null ? msg.getVariable().length() : 0);
Expand Down
10 changes: 10 additions & 0 deletions src/test/resources/com/cflint/tests/Parsing/columns/.cflintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"rule" : [ ],
"excludes" : [ ],
"includes" : [ {
"code" : "ARGUMENT_HAS_PREFIX_OR_POSTFIX"
},
{ "code" : "ARGUMENT_IS_TEMPORARY"} ,
{ "code" : "COMPONENT_INVALID_NAME"} ],
"inheritParent" : false
}
15 changes: 15 additions & 0 deletions src/test/resources/com/cflint/tests/Parsing/columns/test.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Test h
*/
component {
/**
* Conver
* @dateO
*/
public string function formatDate(
date dateObj
)
{
return dateFormat(arguments.dateObj, "mm/dd/yyyy");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"version" : "",
"timestamp" : 0,
"issues" : [ {
"severity" : "INFO",
"id" : "ARGUMENT_HAS_PREFIX_OR_POSTFIX",
"message" : "ARGUMENT_HAS_PREFIX_OR_POSTFIX",
"category" : "CFLINT",
"abbrev" : "AH",
"locations" : [ {
"file" : "src/test/resources/com/cflint/tests/Parsing/columns/test.cfc",
"fileName" : "test.cfc",
"function" : "formatDate",
"column" : 11,
"line" : 9,
"message" : "Argument has prefix or postfix dateObj and could be named better.",
"variable" : "dateObj",
"expression" : "public string function formatDate(dateObj) {/n return dateFormat(arguments.dateObj, 'mm/dd/yyyy');/n/n }"
} ]
}, {
"severity" : "INFO",
"id" : "ARGUMENT_IS_TEMPORARY",
"message" : "ARGUMENT_IS_TEMPORARY",
"category" : "CFLINT",
"abbrev" : "AI",
"locations" : [ {
"file" : "src/test/resources/com/cflint/tests/Parsing/columns/test.cfc",
"fileName" : "test.cfc",
"function" : "formatDate",
"column" : 11,
"line" : 9,
"message" : "Temporary argument dateObj could be named better.",
"variable" : "dateObj",
"expression" : "public string function formatDate(dateObj) {/n return dateFormat(arguments.dateObj, 'mm/dd/yyyy');/n/n }"
} ]
}, {
"severity" : "INFO",
"id" : "COMPONENT_INVALID_NAME",
"message" : "COMPONENT_INVALID_NAME",
"category" : "CFLINT",
"abbrev" : "CI",
"locations" : [ {
"file" : "src/test/resources/com/cflint/tests/Parsing/columns/test.cfc",
"fileName" : "test.cfc",
"function" : "",
"column" : 40,
"line" : 1,
"message" : "Component name test is not a valid name. Please use PascalCase and start with a capital letter.",
"variable" : "",
"expression" : "component {/n public string function formatDate(dateObj) {/n return dateFormat(arguments.dateObj, 'mm/dd/yyyy');/n/n }/n}"
} ]
} ],
"counts" : {
"totalFiles" : 0,
"totalLines" : 0,
"countByCode" : [ {
"code" : "ARGUMENT_IS_TEMPORARY",
"count" : 1
}, {
"code" : "COMPONENT_INVALID_NAME",
"count" : 1
}, {
"code" : "ARGUMENT_HAS_PREFIX_OR_POSTFIX",
"count" : 1
} ],
"countBySeverity" : [ {
"severity" : "INFO",
"count" : 3
} ]
}
}

0 comments on commit 2957314

Please sign in to comment.