diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2021-06-28 16:42:50 -0500 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-06-29 20:03:18 +0000 |
commit | c2a459c2e64af14cdc736d1074829abd8a10bcae (patch) | |
tree | e0b2ecbcd74dbff33d65d14db9de95984fc2c885 /sonar-scanner-engine/src/main/java/org/sonar/scm | |
parent | a46a61290a9a091a47bf3b76942fa4e59b8b981f (diff) | |
download | sonarqube-c2a459c2e64af14cdc736d1074829abd8a10bcae.tar.gz sonarqube-c2a459c2e64af14cdc736d1074829abd8a10bcae.zip |
SONAR-14890 Link to documentation in Warnings should be relative
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org/sonar/scm')
-rw-r--r-- | sonar-scanner-engine/src/main/java/org/sonar/scm/git/GitScmProvider.java | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scm/git/GitScmProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scm/git/GitScmProvider.java index f728b2be2ac..c91cf055ced 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scm/git/GitScmProvider.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scm/git/GitScmProvider.java @@ -59,6 +59,7 @@ import org.sonar.api.utils.MessageException; import org.sonar.api.utils.System2; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; +import org.sonar.scanner.bootstrap.ScannerWsClient; public class GitScmProvider extends ScmProvider { @@ -68,12 +69,14 @@ public class GitScmProvider extends ScmProvider { private final AnalysisWarnings analysisWarnings; private final GitIgnoreCommand gitIgnoreCommand; private final System2 system2; + private final String documentationLink; - public GitScmProvider(JGitBlameCommand jgitBlameCommand, AnalysisWarnings analysisWarnings, GitIgnoreCommand gitIgnoreCommand, System2 system2) { + public GitScmProvider(JGitBlameCommand jgitBlameCommand, AnalysisWarnings analysisWarnings, GitIgnoreCommand gitIgnoreCommand, System2 system2, ScannerWsClient client) { this.jgitBlameCommand = jgitBlameCommand; this.analysisWarnings = analysisWarnings; this.gitIgnoreCommand = gitIgnoreCommand; this.system2 = system2; + this.documentationLink = client.baseUrl() + "/documentation/analysis/scm-integration/"; } @Override @@ -103,10 +106,7 @@ public class GitScmProvider extends ScmProvider { try (Repository repo = buildRepo(rootBaseDir)) { Ref targetRef = resolveTargetRef(targetBranchName, repo); if (targetRef == null) { - analysisWarnings.addUnique(String.format(COULD_NOT_FIND_REF - + ". You may see unexpected issues and changes. " - + "Please make sure to fetch this ref before pull request analysis and refer to" - + " <a href=\"/documentation/analysis/scm-integration/\" target=\"_blank\">the documentation</a>.", targetBranchName)); + addWarningTargetNotFound(targetBranchName); return null; } @@ -148,10 +148,7 @@ public class GitScmProvider extends ScmProvider { try (Repository repo = buildRepo(projectBaseDir)) { Ref targetRef = resolveTargetRef(targetBranchName, repo); if (targetRef == null) { - analysisWarnings.addUnique(String.format(COULD_NOT_FIND_REF - + ". You may see unexpected issues and changes. " - + "Please make sure to fetch this ref before pull request analysis" - + " and refer to <a href=\"/documentation/analysis/scm-integration/\" target=\"_blank\">the documentation</a>.", targetBranchName)); + addWarningTargetNotFound(targetBranchName); return null; } @@ -181,6 +178,13 @@ public class GitScmProvider extends ScmProvider { return null; } + private void addWarningTargetNotFound(String targetBranchName) { + analysisWarnings.addUnique(String.format(COULD_NOT_FIND_REF + + ". You may see unexpected issues and changes. " + + "Please make sure to fetch this ref before pull request analysis and refer to" + + " <a href=\"%s\" target=\"_blank\">the documentation</a>.", targetBranchName, documentationLink)); + } + private void collectChangedLines(Repository repo, RevCommit mergeBaseCommit, Map<Path, Set<Integer>> changedLines, Path changedFile) { ChangedLinesComputer computer = new ChangedLinesComputer(); |