Skip to content

Commit

Permalink
Testing that parsers are mentioned in README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Apr 10, 2017
1 parent c015ce9 commit 0f27abf
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This is a library for parsing report files from static code analysis.

It supports:
* [_AndoidLint_](http://developer.android.com/tools/help/lint.html)
* [_AndroidLint_](http://developer.android.com/tools/help/lint.html)
* [_Checkstyle_](http://checkstyle.sourceforge.net/)
* [_ESLint_](https://github.com/sindresorhus/grunt-eslint) with `format: 'checkstyle'`.
* [_PHPCS_](https://github.com/squizlabs/PHP_CodeSniffer) with `phpcs api.php --report=checkstyle`.
Expand Down Expand Up @@ -35,6 +35,7 @@ It supports:
* [_PMD_](https://pmd.github.io/)
* [_PHPPMD_](https://phpmd.org/) with `phpmd api.php xml ruleset.xml`.
* [_ReSharper_](https://www.jetbrains.com/resharper/)
* [_SbtScalac_](http://www.scala-sbt.org/)
* [_Simian_](http://www.harukizaemon.com/simian/)
* [_StyleCop_](https://stylecop.codeplex.com/)
* [_XMLLint_](http://xmlsoft.org/xmllint.html)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

import se.bjurr.violations.lib.model.SEVERITY;
import se.bjurr.violations.lib.model.Violation;

Expand Down Expand Up @@ -75,7 +73,7 @@ private Violation parseBug(XMLStreamReader xmlr) throws XMLStreamException {
return violationBuilder() //
.setReporter(KLOCWORK) //
.setFile(file) //
.setMessage("In method "+method+". "+message) //
.setMessage("In method " + method + ". " + message) //
.setRule(code) //
.setSeverity(getSeverity(severitylevel)) //
.setStartLine(1) //
Expand Down
2 changes: 0 additions & 2 deletions src/test/java/se/bjurr/violations/lib/KlocworkTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import static se.bjurr.violations.lib.reports.Reporter.KLOCWORK;

import java.util.List;

import org.junit.Test;

import se.bjurr.violations.lib.model.Violation;

public class KlocworkTest {
Expand Down
32 changes: 32 additions & 0 deletions src/test/java/se/bjurr/violations/lib/reports/ReporterTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package se.bjurr.violations.lib.reports;

import static org.assertj.core.api.Assertions.assertThat;

import java.io.File;
import java.nio.charset.Charset;
import org.assertj.core.util.Files;
import org.junit.Test;

public class ReporterTest {

@Test
public void test() {
File readmeFile = findReadmeFile(new File("."));
String content = Files.contentOf(readmeFile, Charset.forName("UTF-8"));
for (Reporter shouldBeMentioned : Reporter.values()) {
assertThat(content) //
.as("All parsers should be mentioned in the README.md") //
.containsIgnoringCase(shouldBeMentioned.name());
}
}

private File findReadmeFile(File file) {
for (File candidate : file.listFiles()) {
if (candidate.getName().equals("README.md")) {
return candidate;
}
}

return findReadmeFile(file.getParentFile());
}
}

0 comments on commit 0f27abf

Please sign in to comment.