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

Commit

Permalink
Fix #74, #78 - null pointer exn thrown on no tslint output (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablissimo committed Dec 27, 2016
1 parent 35918a9 commit 0daa50c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -5,7 +5,7 @@
<groupId>com.pablissimo.sonar</groupId>
<artifactId>sonar-typescript-plugin</artifactId>
<packaging>sonar-plugin</packaging>
<version>0.96-SNAPSHOT</version>
<version>0.97-SNAPSHOT</version>

<name>TypeScript</name>
<description>Analyse TypeScript projects</description>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/pablissimo/sonar/TsLintParserImpl.java
Expand Up @@ -23,6 +23,11 @@ public Map<String, List<TsLintIssue>> parse(List<String> toParse) {

for (String batch : toParse) {
TsLintIssue[] batchIssues = gson.fromJson(getFixedUpOutput(batch), TsLintIssue[].class);

if (batchIssues == null) {
continue;
}

for (TsLintIssue batchIssue : batchIssues) {
allIssues.add(batchIssue);
}
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/com/pablissimo/sonar/TsLintParserTest.java
Expand Up @@ -67,4 +67,14 @@ public void fixesUpBrokenBatchedOutputFromTsLintPriorTo_4_0_0() {
assertEquals(1, issues.size());
assertEquals(2, issues.get("Tools.ts").size());
}

@Test
public void parseAGoodProjectWithNoIssues() {
List<String> toParse = new ArrayList<String>();
toParse.add("");

Map<String, List<TsLintIssue>> issues = new TsLintParserImpl().parse(toParse);

assertEquals(0, issues.size());
}
}

0 comments on commit 0daa50c

Please sign in to comment.