@@ -87,8 +87,7 @@ class IssueTrackingResult { | |||
} | |||
unmatchedByRuleAndKey.get(ruleKey).put(i.getKee(), i); | |||
Map<Integer, Multimap<String, IssueDto>> unmatchedForRule = unmatchedByRuleAndLineAndChecksum.get(ruleKey); | |||
Integer line = i.getLine(); | |||
Integer lineNotNull = line != null ? line : 0; | |||
Integer lineNotNull = lineNotNull(i); | |||
if (!unmatchedForRule.containsKey(lineNotNull)) { | |||
unmatchedForRule.put(lineNotNull, HashMultimap.<String, IssueDto>create()); | |||
} | |||
@@ -97,12 +96,18 @@ class IssueTrackingResult { | |||
unmatchedForRuleAndLine.put(checksumNotNull, i); | |||
} | |||
private Integer lineNotNull(IssueDto i) { | |||
Integer line = i.getLine(); | |||
Integer lineNotNull = line != null ? line : 0; | |||
return lineNotNull; | |||
} | |||
void setMatch(DefaultIssue issue, IssueDto matching) { | |||
matched.put(issue, matching); | |||
RuleKey ruleKey = RuleKey.of(matching.getRuleRepo(), matching.getRule()); | |||
unmatchedByRuleAndKey.get(ruleKey).remove(matching.getKee()); | |||
unmatchedByKey.remove(matching.getKee()); | |||
Integer lineNotNull = matching.getLine() != null ? matching.getLine() : 0; | |||
Integer lineNotNull = lineNotNull(matching); | |||
String checksumNotNull = StringUtils.defaultString(matching.getChecksum(), ""); | |||
unmatchedByRuleAndLineAndChecksum.get(ruleKey).get(lineNotNull).get(checksumNotNull).remove(matching); | |||
} |
@@ -22,6 +22,8 @@ package org.sonar.xoo.scm; | |||
import org.sonar.api.batch.scm.BlameCommand; | |||
import org.sonar.api.batch.scm.ScmProvider; | |||
import java.io.File; | |||
public class XooScmProvider extends ScmProvider { | |||
private final XooBlameCommand blame; | |||
@@ -30,6 +32,11 @@ public class XooScmProvider extends ScmProvider { | |||
this.blame = blame; | |||
} | |||
@Override | |||
public boolean supports(File baseDir) { | |||
return new File(baseDir, ".xoo").exists(); | |||
} | |||
@Override | |||
public String key() { | |||
return "xoo"; |
@@ -24,23 +24,18 @@ import org.slf4j.LoggerFactory; | |||
public class ProgressReport implements Runnable { | |||
private static final Logger LOG = LoggerFactory.getLogger(ProgressReport.class); | |||
private final long period; | |||
private final Logger logger; | |||
private String message = ""; | |||
private final Thread thread; | |||
private String stopMessage = ""; | |||
public ProgressReport(String threadName, long period, Logger logger) { | |||
public ProgressReport(String threadName, long period) { | |||
this.period = period; | |||
this.logger = logger; | |||
thread = new Thread(this); | |||
thread.setName(threadName); | |||
} | |||
public ProgressReport(String threadName, long period) { | |||
this(threadName, period, LoggerFactory.getLogger(ProgressReport.class)); | |||
} | |||
@Override | |||
public void run() { | |||
while (!Thread.interrupted()) { | |||
@@ -73,9 +68,9 @@ public class ProgressReport implements Runnable { | |||
} | |||
private void log(String message) { | |||
synchronized (logger) { | |||
logger.info(message); | |||
logger.notifyAll(); | |||
synchronized (LOG) { | |||
LOG.info(message); | |||
LOG.notifyAll(); | |||
} | |||
} | |||
@@ -150,6 +150,37 @@ public class ScmMediumTest { | |||
.withValue("1=;2=julien;3=julien;4=julien;5=simon")); | |||
} | |||
@Test | |||
public void testAutoDetection() throws IOException { | |||
File baseDir = prepareProject(); | |||
new File(baseDir, ".xoo").createNewFile(); | |||
TaskResult result = tester.newTask() | |||
.properties(ImmutableMap.<String, String>builder() | |||
.put("sonar.task", "scan") | |||
.put("sonar.projectBaseDir", baseDir.getAbsolutePath()) | |||
.put("sonar.projectKey", "com.foo.project") | |||
.put("sonar.projectName", "Foo Project") | |||
.put("sonar.projectVersion", "1.0-SNAPSHOT") | |||
.put("sonar.projectDescription", "Description of Foo Project") | |||
.put("sonar.sources", "src") | |||
.build()) | |||
.start(); | |||
assertThat(result.measures()).hasSize(4); | |||
assertThat(result.measures()).contains(new DefaultMeasure<Integer>() | |||
.forMetric(CoreMetrics.LINES) | |||
.onFile(new DefaultInputFile("com.foo.project", "src/sample.xoo")) | |||
.withValue(5)); | |||
assertThat(result.measures()).contains(new DefaultMeasure<String>() | |||
.forMetric(CoreMetrics.SCM_AUTHORS_BY_LINE) | |||
.onFile(new DefaultInputFile("com.foo.project", "src/sample.xoo")) | |||
.withValue("1=;2=julien;3=julien;4=julien;5=simon")); | |||
} | |||
private File prepareProject() throws IOException { | |||
File baseDir = temp.newFolder(); | |||
File srcDir = new File(baseDir, "src"); |