sonarlint exclude doesn't exclude everything

57 views
Skip to first unread message

edin.ce...@zalando-lounge.de

unread,
May 15, 2017, 4:47:20 AM5/15/17
to SonarLint
Hi all,

I've been setting up sonarlint CLI for a Javascript project and trying to exclude some folders. The funny things is that some folders are getting excluded bot some don't. 
Here is what I'm trying to do:

sonarlint --exclude '{node_modules/**, pegasus-common/**, pegasus-client-common/** dist/**, coverage/**, zoah/**, */**/*.spec.js, xunit.xml}'

After the sonarlint report is generated I can see that some folders are still shown in the report:

Any hints regarding excluding files in sonarlint CLI?

janos....@sonarsource.com

unread,
May 18, 2017, 4:26:42 AM5/18/17
to SonarLint
Hi,

Whitespace is not ignored in glob patterns, and treated as part of the names to match. So instead of comma + space, use just comma in a list of items, like this:

sonarlint --exclude '{node_modules/**,pegasus-common/**,pegasus-client-common/**,dist/**,coverage/**,zoah/**,*/**/*.spec.js,xunit.xml}'

(You also forgot a comma between "pegasus-client-common/** dist/**", I corrected that too.)

I quick way to verify your glob pattern is correct is using Bash 4, with the globstar option set:

shopt -s globstar
echo {node_modules/**,pegasus-common/**,pegasus-client-common/**,dist/**,coverage/**,zoah/**,*/**/*.spec.js,xunit.xml}

If the pattern is valid, the output will include files you wanted to match. If you don't see some files that you want to be matched, then the glob pattern has a mistake somewhere.

Cheers,
Janos
Reply all
Reply to author
Forward
0 new messages