Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to analyze with SonarQube a project where sources and tests are in the same directories

I have a project to analyze which is only based on Angular framework. The main issue I have is that both source and test files are on the same directories, divided into features.

Here is an example of my structure:

+- client
|   +- features
|   |   +- home
|   |   |   +- home.js          [source code]
    |   |   +- home.spec.js     [test code]
        |   +- home.html
        |   +- home.less
        +- admin
        |   +- admin.js         [source code]
        |   +- admin.spec.js    [test code]
        |   +- admin.html
        |   +- admin.less
        ...

In my sonar-project.properties, it seems impossible to set a pattern instead of a path (for ex. sonar.tests=client/**/*.spec.js).

Is there a way to run an analysis with this kind of structure?

Thanks.

like image 283
Romain Linsolas Avatar asked Mar 17 '15 14:03

Romain Linsolas


People also ask

How do you specify multiple sonar sources?

Use Comma-separated paths to analysis multiple modules or projects. sonar. sources= mainDir/subDir/src, mainDir/subDir/subDir/src,... Set base directory with **sonar.

Which tool helps for analyze files in SonarQube?

The SonarScanner is the scanner to use when there is no specific scanner for your build system.

Which of the following places are used to set parameters for project analysis SonarQube?

Project analysis settings can be configured in multiple places. Here is the hierarchy: Global properties, defined in the UI, apply to all projects (From the top bar, go to Administration > Configuration > General Settings)


1 Answers

Thanks to SonarQube mailing list, the solution is to set the following properties:

sonar.sources=client
sonar.tests=client

sonar.exclusions=**/*.spec.js
sonar.test.inclusions=**/*.spec.js
like image 141
Romain Linsolas Avatar answered Oct 01 '22 16:10

Romain Linsolas