aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-10-07 15:46:04 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-10-07 15:47:36 +0200
commite0bbcb1ffabf5c3809efd2e88071a2dc9f0e3d93 (patch)
treea9ba1011fde4e2ea92d6b228eff32b3ad2c79e24 /sonar-batch
parentab1110bb14232145300f03a4e5b295ca406c0dbe (diff)
downloadsonarqube-e0bbcb1ffabf5c3809efd2e88071a2dc9f0e3d93.tar.gz
sonarqube-e0bbcb1ffabf5c3809efd2e88071a2dc9f0e3d93.zip
SONAR-5620 Improve support of empty authors
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scm/DefaultBlameResult.java8
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/mediumtest/scm/ScmMediumTest.java6
2 files changed, 9 insertions, 5 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scm/DefaultBlameResult.java b/sonar-batch/src/main/java/org/sonar/batch/scm/DefaultBlameResult.java
index 7386d0fbc58..9d82a9372ff 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scm/DefaultBlameResult.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scm/DefaultBlameResult.java
@@ -29,6 +29,8 @@ import org.sonar.api.measures.Metric;
import org.sonar.api.measures.PropertiesBuilder;
import org.sonar.api.utils.DateUtils;
+import javax.annotation.Nullable;
+
import java.text.Normalizer;
import java.util.List;
import java.util.regex.Pattern;
@@ -63,10 +65,12 @@ class DefaultBlameResult implements BlameResult {
lineNumber++;
}
ScmSensor.saveMeasures(context, file, authors.buildData(), dates.buildData(), revisions.buildData());
-
}
- private String normalizeString(String inputString) {
+ private String normalizeString(@Nullable String inputString) {
+ if (inputString == null) {
+ return "";
+ }
String lowerCasedString = inputString.toLowerCase();
String stringWithoutAccents = removeAccents(lowerCasedString);
return removeNonAsciiCharacters(stringWithoutAccents);
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/scm/ScmMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/scm/ScmMediumTest.java
index b9292d4aa51..22a3592cd7d 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/scm/ScmMediumTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/scm/ScmMediumTest.java
@@ -86,7 +86,7 @@ public class ScmMediumTest {
assertThat(result.measures()).contains(new DefaultMeasure<String>()
.forMetric(CoreMetrics.SCM_AUTHORS_BY_LINE)
.onFile(new DefaultInputFile("com.foo.project", "src/sample.xoo"))
- .withValue("1=julien;2=julien;3=julien;4=julien;5=simon"));
+ .withValue("1=;2=julien;3=julien;4=julien;5=simon"));
}
@Test
@@ -117,7 +117,7 @@ public class ScmMediumTest {
assertThat(result.measures()).contains(new DefaultMeasure<String>()
.forMetric(CoreMetrics.SCM_AUTHORS_BY_LINE)
.onFile(new DefaultInputFile("com.foo.project", "src/sample.xoo"))
- .withValue("1=julien;2=julien;3=julien;4=julien;5=simon"));
+ .withValue("1=;2=julien;3=julien;4=julien;5=simon"));
}
private File prepareProject() throws IOException {
@@ -132,7 +132,7 @@ public class ScmMediumTest {
FileUtils.write(xooMeasureFile, "lines:5");
FileUtils.write(xooScmFile,
// revision,author,dateTime
- "1,julien,2013-01-04\n" +
+ "1,,2013-01-04\n" +
"1,julien,2013-01-04\n" +
"2,julien,2013-02-03\n" +
"2,julien,2013-02-03\n" +