Skip to content
This repository has been archived by the owner on Jul 8, 2019. It is now read-only.

Fixes issue #118. #119

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/main/java/com/pablissimo/sonar/TsLintSensor.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.pablissimo.sonar.model.TsLintIssue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.rule.ActiveRule;
import org.sonar.api.batch.sensor.Sensor;
import org.sonar.api.batch.sensor.SensorContext;
Expand All @@ -14,6 +15,7 @@
import org.sonar.api.rule.RuleKey;

import java.io.File;
import java.io.IOException;
import java.util.*;

public class TsLintSensor implements Sensor {
Expand Down Expand Up @@ -67,9 +69,10 @@ public void execute(SensorContext ctx) {
ruleNames.add(rule.ruleKey().rule());
}

FileSystem fs = ctx.fileSystem();
List<String> paths = new ArrayList<>();

for (InputFile file : ctx.fileSystem().inputFiles(ctx.fileSystem().predicates().hasLanguage(TypeScriptLanguage.LANGUAGE_KEY))) {
for (InputFile file : fs.inputFiles(fs.predicates().hasLanguage(TypeScriptLanguage.LANGUAGE_KEY))) {
if (shouldSkipFile(file.file(), skipTypeDefFiles)) {
continue;
}
Expand All @@ -87,6 +90,15 @@ public void execute(SensorContext ctx) {
return;
}

File baseDir = fs.baseDir();
String baseDirPath = baseDir.getPath();
String baseDirCanonicalPath = null;
try {
baseDirCanonicalPath = baseDir.getCanonicalPath();
} catch (IOException e) {
LOG.error("Failed to canonicalize " + baseDirPath, e);
}

// Each issue bucket will contain info about a single file
for (Map.Entry<String, List<TsLintIssue>> kvp : issues.entrySet()) {
String filePath = kvp.getKey();
Expand All @@ -96,7 +108,10 @@ public void execute(SensorContext ctx) {
continue;
}

File matchingFile = ctx.fileSystem().resolvePath(filePath);
if (baseDirCanonicalPath != null) {
filePath = filePath.replace(baseDirCanonicalPath, baseDirPath);
}
File matchingFile = fs.resolvePath(filePath);
InputFile inputFile = null;

if (shouldSkipFile(matchingFile, skipTypeDefFiles)) {
Expand All @@ -105,7 +120,7 @@ public void execute(SensorContext ctx) {

if (matchingFile != null) {
try {
inputFile = ctx.fileSystem().inputFile(ctx.fileSystem().predicates().is(matchingFile));
inputFile = fs.inputFile(fs.predicates().is(matchingFile));
}
catch (IllegalArgumentException e) {
LOG.error("Failed to resolve " + filePath + " to a single path", e);
Expand Down
Empty file modified travis.sh
100755 → 100644
Empty file.