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

coverage cache vs multi-module projects #1465

Closed
ivangalkin opened this issue Apr 24, 2018 · 1 comment · Fixed by #1575
Closed

coverage cache vs multi-module projects #1465

ivangalkin opened this issue Apr 24, 2018 · 1 comment · Fixed by #1575

Comments

@ivangalkin
Copy link
Contributor

Hi All

I believe there is a severe design problem in the coverage sensors. It is observable if
a) multi-module project is analyzed plus
b) coverage report (e.g. the cobertura one) contains relative paths (see below, <source> is .)

If path is relative, SensorContext::fileSystem().baseDir().getAbsolutePath() is used as a base directory while parsing. After report is parsed the corresponding CoverageMeasures structure is cached. For the next sub-project the base directory should be actually recalculated, but it isn't.

I believe the cache can be used only if all paths are absolute. This design idea applicable to all sensors. If we don't check/force this fact, it's not safe to cache any reports (and we had a similar discussion in #1423).

The correct solution in my opinion should be

a. Terminate if coverage report of a if multi-module project contains relative paths and/or
b. Provide a property in order disable the cache

I know, that the coverage output can be customized, but the current implementation is a pitfall and must be fixed or at least documented IMHO.

<coverage ... version="gcovr 3.4">
  <sources><source>.</source></sources>
  <packages>
     <package>
        <classes><class filename="relativePath"> ... <class/>
        </classes>
    </package>
 </packages>
</coverage>

Best regards,

@guwirth
Copy link
Collaborator

guwirth commented Apr 25, 2018

Hi @ivangalkin, instead of fixing the sensor I think it's the better way to use the generic test and coverage sensors in future: https://docs.sonarqube.org/display/SONAR/Generic+Test+Data. In our plugin we can provide a transformation mechanism and the XLST.

ivangalkin added a commit to ivangalkin/sonar-cxx that referenced this issue Oct 14, 2018
Path absolutization is never a good idea. Especially in the coverage
sensor, which caches the file paths.

See SonarOpenCommunity#1465
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants