Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use .cflintrc to ignore a directory? #290

Closed
TheRealAgentK opened this issue Jun 7, 2017 · 14 comments
Closed

How to use .cflintrc to ignore a directory? #290

TheRealAgentK opened this issue Jun 7, 2017 · 14 comments
Labels
Milestone

Comments

@TheRealAgentK
Copy link
Collaborator

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.

@TheRealAgentK TheRealAgentK changed the title How to use .cflintrc to ignore a directory How to use .cflintrc to ignore a directory? Jun 7, 2017
ryaneberly added a commit that referenced this issue Jun 20, 2017
@ryaneberly
Copy link
Contributor

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

ryaneberly added a commit that referenced this issue Jun 20, 2017
@TheRealAgentK
Copy link
Collaborator Author

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 :-)

@TheRealAgentK
Copy link
Collaborator Author

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.

@TheRealAgentK TheRealAgentK reopened this Jun 20, 2017
@TheRealAgentK
Copy link
Collaborator Author

TheRealAgentK commented Jun 20, 2017

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>

@ryaneberly
Copy link
Contributor

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.

@TheRealAgentK
Copy link
Collaborator Author

Is making MISSING_SEMI stick to the .cflintrc rules easy? Or a major hassle?

@ryaneberly
Copy link
Contributor

ryaneberly commented Jun 20, 2017 via email

@TheRealAgentK
Copy link
Collaborator Author

ok, I'll have a play with that later and see how I go.

@TheRealAgentK
Copy link
Collaborator Author

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 :)

ryaneberly added a commit that referenced this issue Jun 28, 2017
@ryaneberly
Copy link
Contributor

See 20b3622
it should honor MISSING_SEMI filtering now

@ryaneberly ryaneberly added this to the 1.2.0 milestone Jun 28, 2017
TheRealAgentK added a commit to TheRealAgentK/CFLint that referenced this issue Jun 30, 2017
…xposed and output if a directory is supposed to be ignored.
@TheRealAgentK
Copy link
Collaborator Author

TheRealAgentK commented Jun 30, 2017

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

@ryaneberly
Copy link
Contributor

@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.....)

TheRealAgentK added a commit to TheRealAgentK/CFLint that referenced this issue Jul 1, 2017
TheRealAgentK added a commit to TheRealAgentK/CFLint that referenced this issue Jul 1, 2017
@TheRealAgentK
Copy link
Collaborator Author

New PR in #321

ryaneberly pushed a commit that referenced this issue Jul 1, 2017
* Trying to fix addition issue in #290 - PARSE_ERROR still gets exposed and output if a directory is supposed to be ignored.

* #290 - Additional refactoring from fireCFLintException to reportRule

* #290 - Removed fireCFLintException from comments
@ryaneberly
Copy link
Contributor

merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants