From 12ff4a12bc6613cd17d02c3c4b6f7de469a07ffe Mon Sep 17 00:00:00 2001 From: Belen Pruvost Date: Thu, 29 Apr 2021 14:30:56 +0200 Subject: [PATCH] SONAR-14750 - Add link to warning + update doc --- server/sonar-docs/src/pages/analysis/scm-integration.md | 2 +- .../main/java/org/sonar/scanner/scm/DefaultBlameOutput.java | 3 ++- .../src/main/java/org/sonar/scm/git/GitScmProvider.java | 6 ++++-- .../java/org/sonar/scanner/scm/DefaultBlameOutputTest.java | 3 ++- .../src/test/java/org/sonar/scm/git/GitScmProviderTest.java | 3 ++- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/server/sonar-docs/src/pages/analysis/scm-integration.md b/server/sonar-docs/src/pages/analysis/scm-integration.md index c2d14b0b437..ccd8181b311 100644 --- a/server/sonar-docs/src/pages/analysis/scm-integration.md +++ b/server/sonar-docs/src/pages/analysis/scm-integration.md @@ -24,7 +24,7 @@ Git integration uses [JGit](https://www.eclipse.org/jgit/). JGit is a pure Java * Git doesn't consider old "Mac" line ends (CR) as new lines. As a result the blame operation will contain fewer lines than expected by SonarQube and analysis will fail. The solution is to fix line ends to use either Windows (CR/LF) or Unix (LF) line ends. * JGit doesn't support .mailmap file to "clean" email adress during the blame -* "Missing blame information..." can be caused by checking out with a partial / shallow clone, or using Git submodules. +* "Missing blame information..." and "Could not find ref..." can be caused by checking out with a partial / shallow clone, or using Git submodules. ### How to investigate error during blame (only possible on Unix/Linux)? diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/DefaultBlameOutput.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/DefaultBlameOutput.java index 3e0aa880a61..9a7381826bc 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/DefaultBlameOutput.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/DefaultBlameOutput.java @@ -134,7 +134,8 @@ class DefaultBlameOutput implements BlameOutput { LOG.warn(" * " + f); } LOG.warn("This may lead to missing/broken features in SonarQube"); - analysisWarnings.addUnique(String.format("Missing blame information for %d %s. This may lead to some features not working correctly. Please check the analysis logs.", + analysisWarnings.addUnique(String.format("Missing blame information for %d %s. This may lead to some features not working correctly. " + + "Please check the analysis logs and refer to the documentation.", allFilesToBlame.size(), allFilesToBlame.size() > 1 ? "files" : "file")); } 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 9f3419eee26..8342668300f 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 @@ -105,7 +105,8 @@ public class GitScmProvider extends ScmProvider { 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.", targetBranchName)); + + "Please make sure to fetch this ref before pull request analysis and refer to" + + " the documentation.", targetBranchName)); return null; } @@ -149,7 +150,8 @@ public class GitScmProvider extends ScmProvider { 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.", targetBranchName)); + + "Please make sure to fetch this ref before pull request analysis" + + " and refer to the documentation.", targetBranchName)); return null; } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/DefaultBlameOutputTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/DefaultBlameOutputTest.java index 135da7d0799..21ba297db5e 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/DefaultBlameOutputTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/DefaultBlameOutputTest.java @@ -53,7 +53,8 @@ public class DefaultBlameOutputTest { new DefaultBlameOutput(null, analysisWarnings, singletonList(file)).finish(true); assertThat(analysisWarnings.warnings()).extracting(DefaultAnalysisWarnings.Message::getText) - .containsOnly("Missing blame information for 1 file. This may lead to some features not working correctly. Please check the analysis logs."); + .containsOnly("Missing blame information for 1 file. This may lead to some features not working correctly. " + + "Please check the analysis logs and refer to the documentation."); } @Test diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/GitScmProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/GitScmProviderTest.java index f4501a19768..8f603f32b08 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/GitScmProviderTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/GitScmProviderTest.java @@ -609,7 +609,8 @@ public class GitScmProviderTest { assertThat(warnLog.getRawMsg()).isEqualTo(refNotFound); String warning = refNotFound - + ". You may see unexpected issues and changes. Please make sure to fetch this ref before pull request analysis."; + + ". You may see unexpected issues and changes. Please make sure to fetch this ref before pull request analysis" + + " and refer to the documentation."; verify(analysisWarnings).addUnique(warning); } -- 2.39.5