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

Improve Java ITs: Replace deprecated setProfile by associateProjectToQualityProfile #8389

Closed
sebastien-marichal opened this issue Nov 21, 2023 · 4 comments
Labels
Area: SQ Plugin Java plugin related issues. Type: Tooling Tools make us productive.

Comments

@sebastien-marichal
Copy link
Contributor

sebastien-marichal commented Nov 21, 2023

In Tests.analyzeProject, we use setProfile which is deprecated and probably not even compatible with S4NET (I am not sure we use the sonar.profile option).

It is not as simple as replacing the call, associateProjectToQualityProfile requires the project to already exist as it calls the api/qualityprofiles/add_project endpoint which assumes that the project exists.

One approach could be:

  public static BuildResult analyzeProject(String projectKey, Path temp, String projectDir, @Nullable String profileKey, String... keyValues) throws IOException {
    Path projectFullPath = TestUtils.projectDir(temp, projectDir);

    if (profileKey != null) {
      ORCHESTRATOR.getServer().provisionProject(projectKey, projectKey); // Create the project
      ORCHESTRATOR.getServer().associateProjectToQualityProfile(projectKey, "cs", profileKey); // Bind the profile to it
    }

    ScannerForMSBuild beginStep = TestUtils.createBeginStep(projectKey, projectFullPath)
      .setProperties(keyValues);

    ORCHESTRATOR.executeBuild(beginStep);
    TestUtils.runBuild(projectFullPath);
    return ORCHESTRATOR.executeBuild(TestUtils.createEndStep(projectFullPath));
  }

The same goes for the VBNET version.
Usage outside the Tests class should be checked as well.

@sebastien-marichal sebastien-marichal added Area: VB.NET VB.NET rules related issues. Area: C# C# rules related issues. Type: Tooling Tools make us productive. Area: SQ Plugin Java plugin related issues. and removed Area: VB.NET VB.NET rules related issues. Area: C# C# rules related issues. labels Nov 21, 2023
@pavel-mikula-sonarsource
Copy link
Contributor

@sebastien-marichal Isn't this duplicate of #3102 ?

@sebastien-marichal
Copy link
Contributor Author

Probably, although this ticket seems to be more up-to-date.
setProfile does not seem to be as used in test classes as it was back in 2020.

@pavel-mikula-sonarsource
Copy link
Contributor

Please move relevant parts there and close this one

@sebastien-marichal
Copy link
Contributor Author

Close as duplicate of #3102

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: SQ Plugin Java plugin related issues. Type: Tooling Tools make us productive.
Projects
None yet
Development

No branches or pull requests

2 participants