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

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

Open
Panzareon opened this issue Nov 15, 2022 · 0 comments

Comments

@Panzareon
Copy link

Panzareon commented Nov 15, 2022

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).

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

No branches or pull requests

1 participant