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

Adding directory coverage thus supporting the Treemap widget #23

Merged

Conversation

MichaelZinsmaier
Copy link
Contributor

Hi again,

thats the 2nd in a series of 3 pull request I tried to separate functionality a bit.

This one is the reason that I actually started to work on the code (-:
I noticed that the Treemap widget is not working correctly with Statementcoverage. Reason is that the directories do not have StatementCoverage values.

The treemap widgets cannot be traveresed from project -> module -> directory -> file if the directory does not provide the same statistics as the other levels. I changed the code to collect data for directories as well.

There are two options
either summing up all values (B) or using only direct children (A):

If all directories with values are represented on one treemap level (as SonarQube does) the result of A is a treemap that shows for each directory the "quality of its children" which I think is correct. If grandchildren would be added (option B) you could easily have a green directory with red files inside (if the sub directories are big enough)...

The Pull Request implements approach A. Hope that fits into the plugin.

Remarks:

  • it depends on the first Pull Request (to get InputDir as Resource)
  • I tested it with the SBT example project and my own bigger Scala Multi Module project
    but additional tests would surely be a good idea

Best Michael

The stub parser is not used anymore, removed it
Justification: relying on getParentFile gets the path splitting working  under windows and unix

- adapted the tests to the new behavior
- added a windows / unix switch in the tests to get them working on both systems

PathUtils now converts:
- the empty path to an empty List
- an absolute path to a list folders (not including the drive name under windows)
- a relative path to a list of folders
Justification:

- sanitizing the reported file pathes to a common format makes the sensor simpler
- it is a precondition for implementing proper directory coverage
- tests run now under unix and windows, easier to develop

The sonar.sources property can be read from the settings. By mapping all
reported pathes (absolute / base dir relative / source dir relative) against
the actual file tree it is possible to converte all of them to the same
source dir relative format.

For instance

    /home/src/main/scala/folder/test0.scala  => folder/test0.scala
                         folder/test1.scala  => folder/test1.scala
         /src/main/scala/test2.scala         =>        test2.scala
   ...
- testing absolute report file paths
- testing base dir relative report file paths
- testing source dir relative report file paths
The SonarQube treemap widgets work better if metrics exist for the
project, the directory and the file level.

Project coverage is defined as sum of ALL children
Directory coverage is defined as sum of the DIRECT children

The directories have to be treated special because the SonarQube treemap
displays all directories on the same level (not as a tree). Using full
sums would hide bad coverage results in some cases.
- measures should be saved for all levels (directory, project, module, file)
- the sum should not be necessary any more
- makes the two metrics more similar, a correct "sum" for the coverage value
cannot be defined as easily.
RadoBuransky added a commit that referenced this pull request Oct 25, 2015
Adding directory coverage thus supporting the Treemap widget
@RadoBuransky RadoBuransky merged commit 4688fc6 into RadoBuransky:master Oct 25, 2015
@DonBranson
Copy link

Michael,

I have version 5.1.3 installed, which includes this PR, but am still not getting Treemap. Do I need to make any config changes so this shows up? Maybe if I could have a look at your sample project, I could see what I'm missing.

Thanks,
Don

@DonBranson DonBranson mentioned this pull request May 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants