Test code scope and rules definition

Template for a good new topic, formatted with Markdown:

  • ALM used Azure DevOps
  • CI system used Azure DevOps
  • Languages of the repository JS

After setting up test- and source-scope my test source files no longer show up in the code-tab of the analysis. As I found no further information on how test code is handled I wonder if my configuration for the scopes is correct? Here are my settings regarding scopes:

          sonar.sources = /
          sonar.tests = /
          # Include test subdirectories in test scope
          sonar.test.inclusions = tests/**/*
          # Exclude test subdirectories from source scope
          sonar.exclusions = tests/**/*

I also like to know which rules exactly are applied to test code and if there is a way to configure the rules applied to test code?

Thank you!


Welcome to the community!

…really? You’ve set both values to box root?

It’s pretty clear from this:

that you have an identifiable tests directory. I think you should use it:

          sonar.sources = comma,delimited,list,of,actual,source,directories
          sonar.tests = tests

You can look for the tests tag. Unfortunately, you can’t configure “normal” rules to run on tests without analyzing your tests as code. And then I think they test rules wouldn’t run on them.