Soloplan/resharper-clt-plugin

Solution filter in different folder as solution breaks relative paths to the source code files of issues

Panzareon opened this issue · 0 comments

If InspectCode is executed with a solution filter, the generated xml has paths relative to the solution that the solution filter references, and not the solution filter.

However, this plugin assumes that the paths are relative to the folder of the solution file set as the resharper.clt.solutionFile parameter. See logic in https://github.com/Soloplan/resharper-clt-plugin/blob/137063b5c42562ca841c29384d340da9cc3d9e1e/src/main/java/com/soloplan/oss/sonarqube/plugin/resharper/clt/sensors/BaseSensor.java:

    // Build the absolute path to the solution file
    final File solutionFile = new File(sonarQubeProperties.userDir + File.separator + sonarQubeProperties.solutionFileName);
    final String inspectCodeRelativeBaseDir = solutionFile.getParent() + File.separator;

    // Iterate all issues found within the InspectCode report XML file matching the project name predicate
    for (SonarQubeIssueModel sonarQubeIssueModel : sonarQubeSensorXmlParserResults.parsedIssues) {
      ...
      // Construct an absolute path from the filesystem root to the source file where the issue occurred,
      // relative to the path where the solution file is located.
      final String absoluteFilePath = inspectCodeRelativeBaseDir + sonarQubeIssueModel.getFilePath();

Which means that you need to specify the actual solution as the resharper.clt.solutionFile, and the solution filter for InspectCode.

The xml that InspectCode generates does contain the analyzed solution relative to the userDir, so if this plugin would parse that path and use it to resolve the relative paths specified in the file, it would be less error prone.

And as far as I can tell, this is the only usage of the solutionFileName parameters, so maybe it could be removed (or made optional to override the path given in the xml if needed).