How to use .cflintrc to ignore a directory?
TheRealAgentK opened this issue · comments
I'm running CFLint against a codebase and want to exclude some directory structures from being scanned.
Let's say I'm scanning against /a and the full structure is /a/b/c/d
So, I put a .cflintrc into /a/b/c with this content:
{
"output" : [ ],
"rule" : [ ],
"excludes" : [ ],
"includes" : [ ],
"inheritParent" : false,
"inheritPlugins" : true
}
expecting to not get any of the overall rules of the CFLint execution in a/b/c and a/b/c/d because I switched off inheriting. Excluding/Including is not specified either - so I'd think that nothing should run here.
Nevertheless, I still get MISSING_SEMIs and others in those directories.
Maybe you can suggest a better assumption, but currently the code assumes an empty include list is NOT a constraint. In other words, when both the include list and the exclude list are empty, ALL messages codes are enabled. To do what you want, simply put a meaningless match in the include list:
"includes" : [ {} ],
That will include only messages for which the code is null. i.e. none.
See
https://github.com/cflint/CFLint/wiki/Recipe-:-Ignoring-All-Rules-in-a-Folder
for more details
I was looking around in the wiki and past issues and couldn't find anything and you just needed to point out the correct wiki page. sigh :-)
Now re the assumptions... I'm not sure I agree with them. I need to have a bit of a think over all the possible scenarios and form a more meaningful opinion for myself.
So, I tried the notation you pointed me to, but it doesn't seem to work.
This is my .cflintrc in /Users/kai/Documents/Code/something/html/testbox
{
"output" : [ ],
"rule" : [ ],
"excludes" : [ ],
"includes" : [ {} ],
"inheritParent" : false,
"inheritPlugins" : true
}
Am running:
java -jar CFLint-1.1.0-all.jar -folder /Users/kai/Documents/Code/something/html/ -xml -xmlfile something.xml -xmlstyle findbugs -includeRule CFQUERYPARAM_REQ,QUERYPARAM_REQ,MISSING_VAR,AVOID_EMPTY_FILES -v -e -stats
When it outputs, I still get a couple of these:
<issue severity="ERROR" id="MISSING_SEMI" message="MISSING_SEMI" category="CFLint" abbrev="MS"><location file="/Users/kai/Documents/Code/something/html/testbox/system/Expectation.cfc" fileName="Expectation.cfc" function="" column="55" line="52" message="End of statement(;) expected instead of =" variable=""><Expression><![CDATA[=]]></Expression></location>
</issue>
No problem. I just added the page mentioned tonight. Sorry for the confusion.
I'd like to hear your thoughts on the empty include.
Ah, MISSING_SEMI is special -- that does need to honor the include rules. Good catch. The other messages should filter out though.
Is making MISSING_SEMI stick to the .cflintrc rules easy? Or a major hassle?
ok, I'll have a play with that later and see how I go.
I tried a few things - my last effort being:
Context c = new Context(currentFile,currentElement,null,true,null,null);
reportRule(currentElement,null,c,null, new ContextMessage("MISSING_SEMI",null));
But that (and any previous variations I tried) result in null pointer exceptions and failed test on mvn install.
I'm not sure if the Context is constructed right - it also required plugin or pluginParams - which I have no idea what that is and where to get it from in that function :)
See 20b3622
it should honor MISSING_SEMI filtering now
MISSING_SEMI is fixed and working.
However, just noticed I'm getting PARSE_ERRORs for ignored directories too. I've tried to build a solution for it following your model for MISSING_SEMI, @ryaneberly - but it doesn't seem to work. Pushed and PRed it in 290-ParseError branch - could you have a look at it re what I'm missing?
PR is in #319
@TheRealAgentK ,
Its a great start. I think you just need to replace all
fireCFLintException(e, PARSE_ERROR,.....
with your code like you did on line 1253 (i.e. lines 420, 442, 626, 698.....)
New PR in #321
merged