diff --git a/src/main/java/com/pablissimo/sonar/LOCSensor.java b/src/main/java/com/pablissimo/sonar/LOCSensor.java index 328803c..c23f678 100644 --- a/src/main/java/com/pablissimo/sonar/LOCSensor.java +++ b/src/main/java/com/pablissimo/sonar/LOCSensor.java @@ -4,6 +4,9 @@ import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.sonar.api.batch.Sensor; import org.sonar.api.batch.SensorContext; import org.sonar.api.batch.fs.FileSystem; @@ -13,6 +16,8 @@ import org.sonar.api.resources.Project; public class LOCSensor implements Sensor { + private static final Logger LOG = LoggerFactory.getLogger(LOCSensor.class); + private FileSystem fileSystem; /** @@ -42,7 +47,7 @@ public void analyse(Project project, SensorContext sensorContext) { public String toString() { return getClass().getSimpleName(); } - + protected BufferedReader getReaderFromFile(InputFile inputFile) throws FileNotFoundException { return new BufferedReader(new FileReader(inputFile.file())); } @@ -53,9 +58,9 @@ private int getNonCommentLineCount(InputFile inputFile) { try { br = this.getReaderFromFile(inputFile); - boolean isEOF = false; + boolean isEOF; boolean isCommentOpen = false; - boolean isACommentLine = false; + boolean isACommentLine; do { String line = br.readLine(); @@ -102,11 +107,9 @@ private int getNonCommentLineCount(InputFile inputFile) { br.close(); } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + LOG.error("File not found", e); } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + LOG.error("Error while reading BufferedReader", e); } return value; } diff --git a/src/main/java/com/pablissimo/sonar/TsCoverageSensor.java b/src/main/java/com/pablissimo/sonar/TsCoverageSensor.java index ca1eb3e..8034429 100644 --- a/src/main/java/com/pablissimo/sonar/TsCoverageSensor.java +++ b/src/main/java/com/pablissimo/sonar/TsCoverageSensor.java @@ -113,7 +113,7 @@ protected LCOVParser getParser(File baseDirectory) { } private void saveZeroValueForResource(org.sonar.api.resources.File resource, SensorContext context) { - PropertiesBuilder lineHitsData = new PropertiesBuilder(CoreMetrics.COVERAGE_LINE_HITS_DATA); + PropertiesBuilder lineHitsData = new PropertiesBuilder<>(CoreMetrics.COVERAGE_LINE_HITS_DATA); for (int x = 1; x < context.getMeasure(resource, CoreMetrics.LINES).getIntValue(); x++) { lineHitsData.add(x, 0); @@ -151,4 +151,4 @@ public File getIOFile(File baseDir, String path) { return file; } -} \ No newline at end of file +} diff --git a/src/main/java/com/pablissimo/sonar/TsLintSensor.java b/src/main/java/com/pablissimo/sonar/TsLintSensor.java index de7d8e5..c699aff 100644 --- a/src/main/java/com/pablissimo/sonar/TsLintSensor.java +++ b/src/main/java/com/pablissimo/sonar/TsLintSensor.java @@ -54,9 +54,7 @@ public TsLintSensor(Settings settings, FileSystem fileSystem, ResourcePerspectiv } public boolean shouldExecuteOnProject(Project project) { - boolean toReturn = hasFilesToAnalyze(); - - return toReturn; + return hasFilesToAnalyze(); } private boolean hasFilesToAnalyze() { @@ -85,7 +83,7 @@ else if (pathToTsLintConfig == null) { RuleQuery ruleQuery = RuleQuery.create().withRepositoryKey(TsRulesDefinition.REPOSITORY_NAME); Collection allRules = this.ruleFinder.findAll(ruleQuery); - HashSet ruleNames = new HashSet(); + HashSet ruleNames = new HashSet<>(); for (Rule rule : allRules) { ruleNames.add(rule.getKey()); } diff --git a/src/main/java/com/pablissimo/sonar/TypeScriptLanguage.java b/src/main/java/com/pablissimo/sonar/TypeScriptLanguage.java index 9cb0bd7..bbeef90 100644 --- a/src/main/java/com/pablissimo/sonar/TypeScriptLanguage.java +++ b/src/main/java/com/pablissimo/sonar/TypeScriptLanguage.java @@ -6,7 +6,7 @@ public class TypeScriptLanguage extends AbstractLanguage { public static final String LANGUAGE_NAME = "TypeScript"; public static final String LANGUAGE_KEY = "ts"; public static final String[] LANGUAGE_EXTENSIONS = { "ts", "tsx" }; - public static final String LANGUAGE_DEFINITION_EXTENSION = "d.ts"; + protected static final String LANGUAGE_DEFINITION_EXTENSION = "d.ts"; public TypeScriptLanguage(){ super(LANGUAGE_KEY, LANGUAGE_NAME); diff --git a/src/main/java/com/pablissimo/sonar/model/TsLintConfig.java b/src/main/java/com/pablissimo/sonar/model/TsLintConfig.java index 67bebe0..aacd996 100644 --- a/src/main/java/com/pablissimo/sonar/model/TsLintConfig.java +++ b/src/main/java/com/pablissimo/sonar/model/TsLintConfig.java @@ -7,7 +7,7 @@ public class TsLintConfig { private Map rules; public TsLintConfig() { - this.rules = new HashMap(); + this.rules = new HashMap<>(); } public Map getRules() {