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

Including tests as source #16

Open
philbert opened this issue Jul 23, 2019 · 1 comment
Open

Including tests as source #16

philbert opened this issue Jul 23, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@philbert
Copy link

(Using sonar-groovy 1.4 and Sonarqube 7.9)

It appears that the plugin has no rules applied to test cases when using sonar property sonar.tests (If it does then we consider it too few rules for our liking, as we have never hit a violation in this circumstance)

Instead we include test cases as sonar.sources, which, of course, brings some new problems.

There is an issue in the previous maintainer's sonar-groovy project about this, which shows others are including tests as source:
pmayweg/sonar-groovy#89

Sonarqube itself seems to have little to no functionality or information what rules are applied against tests vs sources so I presume this distinction is up to the various language plugins?

If I could wish for the functionality, I would wish it to be based on the label applied to the rule (as this is under user control, however I suspect labels are for display filtering only and don't work this way)

I did notice however that in some of the descriptions of the rules, for example "InstanceofRule" there is text such as this:
By default, the rule does not analyze test files. This rule sets the default value of the doNotApplyToFilesMatching property to ignore file names ending in 'Spec.groovy', 'Test.groovy', 'Tests.groovy' or 'TestCase.groovy'.

Since the file where I hit this violation ends with "Spec.groovy", I am curious if there is any user-level control over this parameter that I can exercise to disable certain rules for test cases?

@TobiX
Copy link
Member

TobiX commented Jul 23, 2019

I think the source of the problem lies somewhere around this:

https://github.com/Inform-Software/sonar-groovy/blob/master/sonar-groovy-plugin/src/main/java/org/sonar/plugins/groovy/foundation/GroovyFileSystem.java#L45-L61

This plugin seems to deliberately restrict itself to the main sources. On the other hand, rules are currently not classified if they apply to main source, test source or both - So removing this restriction will open up the next chore: Classifying all of CodeNarc's rules into those categories...

@TobiX TobiX added the bug Something isn't working label Dec 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants