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

Commit

Permalink
Merge pull request #32 from DevFactory/release/multiple-code-improvem…
Browse files Browse the repository at this point in the history
…ents-fix-1

Multiple code improvements - squid:S1854, squid:S1148, squid:S2386, squid:S2293, squid:S1488
  • Loading branch information
Pablissimo committed Apr 21, 2016
2 parents d1a6faf + 6bd7061 commit 5e9b15a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
17 changes: 10 additions & 7 deletions src/main/java/com/pablissimo/sonar/LOCSensor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

/**
Expand Down Expand Up @@ -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()));
}
Expand All @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/pablissimo/sonar/TsCoverageSensor.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected LCOVParser getParser(File baseDirectory) {
}

private void saveZeroValueForResource(org.sonar.api.resources.File resource, SensorContext context) {
PropertiesBuilder<Integer, Integer> lineHitsData = new PropertiesBuilder<Integer, Integer>(CoreMetrics.COVERAGE_LINE_HITS_DATA);
PropertiesBuilder<Integer, Integer> lineHitsData = new PropertiesBuilder<>(CoreMetrics.COVERAGE_LINE_HITS_DATA);

for (int x = 1; x < context.getMeasure(resource, CoreMetrics.LINES).getIntValue(); x++) {
lineHitsData.add(x, 0);
Expand Down Expand Up @@ -151,4 +151,4 @@ public File getIOFile(File baseDir, String path) {

return file;
}
}
}
6 changes: 2 additions & 4 deletions src/main/java/com/pablissimo/sonar/TsLintSensor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -85,7 +83,7 @@ else if (pathToTsLintConfig == null) {

RuleQuery ruleQuery = RuleQuery.create().withRepositoryKey(TsRulesDefinition.REPOSITORY_NAME);
Collection<Rule> allRules = this.ruleFinder.findAll(ruleQuery);
HashSet<String> ruleNames = new HashSet<String>();
HashSet<String> ruleNames = new HashSet<>();
for (Rule rule : allRules) {
ruleNames.add(rule.getKey());
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/pablissimo/sonar/TypeScriptLanguage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/pablissimo/sonar/model/TsLintConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class TsLintConfig {
private Map<String, Object> rules;

public TsLintConfig() {
this.rules = new HashMap<String, Object>();
this.rules = new HashMap<>();
}

public Map<String, Object> getRules() {
Expand Down

0 comments on commit 5e9b15a

Please sign in to comment.