What exactly does saving on `context.module() ' do?

Currently I have Metrics displaying in the left hand pane within the Measures column inside of the Project View of SQ 7.9 LTS. I currently am setting these Metrics inside of the left column in my own DomainI have made. The line code in question is this.


What exactly does this on() save onto? When this runs I see the the correct value. This is all being done in the Sensor class I have made.

In comparison how does saving onto file differ than with saving onto module()?

Thanks so much!

You can compute/save a measure at different level. In the past it was possible the save at project/module/folder/file level, but in 7.9 only files and projects are supported.

In a single module project, context.module() is equivalent to context.project().

If you save measures at file level, it is usually required to aggregate them at higher level, using a MeasureComputer. See for example: https://github.com/SonarSource/sonar-custom-plugin-example/blob/master/src/main/java/org/sonarsource/plugins/example/measures/ComputeSizeAverage.java

1 Like