Exclude all folders files apart from one file for duplicate checking

Hi Everyone

I need to exclude an entire folder, apart from one file from duplicate checking.

I can exclude all like this

sonar.cpd.exclusions=server/config/validation/**

but I need to include one file in there

sonar.cpd.inclusions=server/config/validation/custom-validation.js

Am I being dull and all I need to do is basically what I’ve got above?

sonar.sources=client,server
sonar.cpd.exclusions=server/config/validation/**
sonar.cpd.inclusions=server/config/validation/custom-validation.js

Hi,

I think you’ve already identified the best course here. Inclusions are for corner case scenarios, and I think you’ve got one.

 
Ann

Hi Ann

Thanks for responding

So just to double check, the following code

sonar.sources=client,server
sonar.cpd.exclusions=server/config/validation/**
sonar.cpd.inclusions=server/config/validation/custom-validation.js

Will exclude the entire contents of server/config/validation/ from duplicate checking, apart from the server/config/validation/custom-validation.js file?

Thanks again

Matt

Hi Matt,

You should double-check the wildcard meanings. ** is 0-n directories. You probably want to stick a file specifier on the end there.

Also, duplications are far easier to set correctly via the UI than in properties.

 
:slight_smile:
Ann

The folder contains just .js files

so would this work in your opinion?

sonar.sources=client,server
sonar.cpd.exclusions=server/config/validation/*.js
sonar.cpd.inclusions=server/config/validation/custom-validation.js

Thanks for your help with this

Matt

Hi Matt,

With a repetition of the caveat about using the UI, yes. That looks doable to me.

Although now that I think of it, since server is a source location, I’m not sure whether or not you should prefix your paths with it. maybe **/config/&etc instead.

 
Ann