Skip to content

Commit

Permalink
Formatting code
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Oct 2, 2016
1 parent 908436b commit 0934794
Show file tree
Hide file tree
Showing 22 changed files with 86 additions and 70 deletions.
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,27 @@ Changelog of Git Changelog.
## Unreleased
### No issue

**Formatting code**


[86012292c5f70a4](https://github.com/tomasbjerre/git-changelog-lib/commit/86012292c5f70a4) Tomas Bjerre *2016-10-02 12:34:32*


## 1.9
### GitHub [#4](https://github.com/tomasbjerre/violations-lib/issues/4)

**ESLint**


[e9f338ef44d3a45](https://github.com/tomasbjerre/git-changelog-lib/commit/e9f338ef44d3a45) Tomas Bjerre *2016-10-01 11:25:19*


### No issue

**Preliminary support for StyleCop**


[82b0da58252b97e](https://github.com/tomasbjerre/git-changelog-lib/commit/82b0da58252b97e) Tomas Bjerre *2016-10-01 10:22:55*
[81e30321fa1619b](https://github.com/tomasbjerre/git-changelog-lib/commit/81e30321fa1619b) Tomas Bjerre *2016-10-01 10:24:14*

**Support for FxCop**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public List<Violation> parseFile(File file) throws Exception {
.setRule(rule)//
.setMessage(id + ": " + summary + "\n" + message + "\n" + explanation)//
.build()//
);
);

}
return violations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public List<Violation> parseFile(File file) throws Exception {
.setMessage(msg + ". " + verbose)//
.setRule(id)//
.build()//
);
);
}
}
return violations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public List<Violation> parseFile(File file) throws Exception {
.setSeverity(toSeverity(severity))//
.setMessage(message + ": " + evidence)//
.build()//
);
);
}
}
return violations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public List<Violation> parseFile(File file) throws Exception {
.setMessage(message)//
.setRule(rule)//
.build()//
);
);
}
}
return violations;
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/se/bjurr/violations/lib/parsers/CppLintParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
import static se.bjurr.violations.lib.model.SEVERITY.INFO;
import static se.bjurr.violations.lib.model.SEVERITY.WARN;
import static se.bjurr.violations.lib.model.Violation.violationBuilder;
/**
* PyLint. Format used by Flake8.
*/
import static se.bjurr.violations.lib.parsers.ViolationParserUtils.getLines;
import static se.bjurr.violations.lib.parsers.ViolationParserUtils.getParts;
import static se.bjurr.violations.lib.reports.Reporter.CPPLINT;

import java.io.File;
import java.util.List;

import com.google.common.io.Files;

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

import com.google.common.io.Files;

/**
* PyLint. Format used by Flake8.
*/
public class CppLintParser implements ViolationsParser {

@Override
Expand All @@ -48,7 +48,7 @@ public List<Violation> parseFile(File file) throws Exception {
.setSeverity(toSeverity(severity))//
.setMessage(message)//
.build()//
);
);
}
return violations;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private void parseBugInstance(XMLStreamReader xmlr, List<Violation> violations,
.setSource(classname)//
.setSpecific(FINDBUGS_SPECIFIC_RANK, rank)//
.build()//
);
);
}
}
if (eventType == XMLStreamConstants.END_ELEMENT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public List<Violation> parseFile(File file) throws Exception {
.setSeverity(toSeverity(severity))//
.setMessage(message)//
.build()//
);
);
}
return violations;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public List<Violation> parseFile(File file) throws Exception {
.setSeverity(toSeverity(severity))//
.setMessage(message)//
.build()//
);
);
}
}
return violations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public List<Violation> parseFile(File file) throws Exception {
.setSeverity(toSeverity(severity))//
.setMessage(message + ": " + evidence)//
.build()//
);
);
}
}
return violations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public List<Violation> parseFile(File file) throws Exception {
.setRule(rule)//
.setMessage(ruleSet + " " + externalInfoUrl)//
.build()//
);
);
}
}
return violations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public List<Violation> parseFile(File file) throws Exception {
.setSeverity(toSeverity(severity))//
.setMessage(message)//
.build()//
);
);
}
return violations;
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/se/bjurr/violations/lib/parsers/PiTestParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public List<Violation> parseFile(File file) throws Exception {
.setMessage(message)//
.setSpecifics(//
of(//
"detected", detected,//
"mutatedMethod", mutatedMethod,//
"mutatedClass", mutatedClass,//
"status", status,//
"detected", detected, //
"mutatedMethod", mutatedMethod, //
"mutatedClass", mutatedClass, //
"status", status, //
"methodDescription", methodDescription))//
.build()//
);
);
}
return violations;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public List<Violation> parseFile(File file) throws Exception {
.setMessage(message)//
.setRule(typeId)//
.build()//
);
);
}
return violations;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import java.io.File;
import java.util.List;

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

import com.google.common.io.Files;

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

public class XMLLintParser implements ViolationsParser {

@Override
Expand All @@ -41,7 +41,7 @@ public List<Violation> parseFile(File file) throws Exception {
.setSeverity(ERROR)//
.setMessage(message)//
.build()//
);
);
}
return violations;
}
Expand Down
20 changes: 10 additions & 10 deletions src/test/java/se/bjurr/violations/lib/AccumulatedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ public void testThatViolationsCanBeFiltered() {
.withAtLeastSeverity(ERROR)//
.orderedBy(FILE)//
.violations())//
.hasSize(1);
.hasSize(1);

assertThat(violationsAccumulatedReporterApi//
.withAtLeastSeverity(WARN)//
.orderedBy(FILE)//
.violations())//
.hasSize(8);
.hasSize(8);

assertThat(violationsAccumulatedReporterApi//
.withAtLeastSeverity(INFO)//
.orderedBy(FILE)//
.violations())//
.hasSize(10);
.hasSize(10);
}

@Test
Expand All @@ -49,28 +49,28 @@ public void testThatViolationsCanBeOrdered() {
.orderedBy(FILE)//
.violations()//
.get(0).getFile())//
.isEqualTo("../../../web/js-file.js");
.isEqualTo("../../../web/js-file.js");

assertThat(reverse(violationsAccumulatedReporterApi//
.withAtLeastSeverity(INFO)//
.orderedBy(FILE)//
.violations())//
.get(0).getFile())//
.isEqualTo("/src/main/java/se/bjurr/violations/lib/example/OtherClass.java");
.get(0).getFile())//
.isEqualTo("/src/main/java/se/bjurr/violations/lib/example/OtherClass.java");

assertThat(violationsAccumulatedReporterApi//
.withAtLeastSeverity(INFO)//
.orderedBy(SEVERITY)//
.violations()//
.get(0).getSeverity())//
.isEqualTo(INFO);
.isEqualTo(INFO);

assertThat(reverse(violationsAccumulatedReporterApi//
.withAtLeastSeverity(INFO)//
.orderedBy(SEVERITY)//
.violations())//
.get(0).getSeverity())//
.isEqualTo(ERROR);
.get(0).getSeverity())//
.isEqualTo(ERROR);

}

Expand All @@ -91,6 +91,6 @@ private ViolationsAccumulatedReporterApi getAccumulatedReporterApi() {
.inFolder(rootFolder) //
.findAll(JSHINT) //
.violations()//
);
);
}
}
49 changes: 24 additions & 25 deletions src/test/java/se/bjurr/violations/lib/AndroidLintTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,45 +26,44 @@ public void testThatViolationsCanBeParsed() {

List<Violation> actual = violationsReporterApi() //
.withPattern(".*/androidlint/.*\\.xml$") //
.inFolder(rootFolder).findAll(ANDROIDLINT) //
.inFolder(rootFolder)//
.findAll(ANDROIDLINT) //
.violations();

assertThat(actual)
.containsExactly(
violationBuilder()
.setReporter(ANDROIDLINT)
.setFile("app/src/main/res/layout/fragment_main.xml")
.setSource(null)
.setStartLine(10)
.setEndLine(10)
.setColumn(9)
assertThat(actual)//
.containsExactly(//
violationBuilder()//
.setReporter(ANDROIDLINT)//
.setFile("app/src/main/res/layout/fragment_main.xml")//
.setSource(null)//
.setStartLine(10)//
.setEndLine(10)//
.setColumn(9)//
.setRule("Correctness")
.setMessage(
"ScrollViewSize: ScrollView size validation\n"
+ "This LinearLayout should use `android:layout_height=&quot;wrap_content&quot;`\n"
+ "ScrollView children must set their `layout_width` or `layout_height` attributes to `wrap_content` rather than `fill_parent` or `match_parent` in the scrolling dimension") //
.setMessage("ScrollViewSize: ScrollView size validation\n"
+ "This LinearLayout should use `android:layout_height=&quot;wrap_content&quot;`\n"
+ "ScrollView children must set their `layout_width` or `layout_height` attributes to `wrap_content` rather than `fill_parent` or `match_parent` in the scrolling dimension") //
.setSeverity(WARN) //
.build(), //
violationBuilder()
.setReporter(ANDROIDLINT)
violationBuilder()//
.setReporter(ANDROIDLINT)//
.setFile(
".gradle/caches/modules-2/files-2.1/com.squareup.okio/okio/1.4.0/5b72bf48563ea8410e650de14aa33ff69a3e8c35/okio-1.4.0.jar") //
.setSource(null) //
.setStartLine(0) //
.setEndLine(0) //
.setColumn(null) //
.setRule("Correctness") //
.setMessage(
"InvalidPackage: Package not included in Android\n"
+ "Invalid package reference in library; not included in Android: `java.nio.file`. Referenced from `okio.Okio`.\n"
+ "This check scans through libraries looking for calls to APIs that are not included in Android.\n"
+ " \n"
+ " When you create Android projects, the classpath is set up such that you can only access classes in the API packages that are included in Android. However, if you add other projects to your libs/ folder, there is no guarantee that those .jar files were built with an Android specific classpath, and in particular, they could be accessing unsupported APIs such as java.applet.\n"
+ " \n"
+ " This check scans through library jars and looks for references to API packages that are not included in Android and flags these. This is only an error if your code calls one of the library classes which wind up referencing the unsupported package.") //
.setMessage("InvalidPackage: Package not included in Android\n"
+ "Invalid package reference in library; not included in Android: `java.nio.file`. Referenced from `okio.Okio`.\n"
+ "This check scans through libraries looking for calls to APIs that are not included in Android.\n"
+ " \n"
+ " When you create Android projects, the classpath is set up such that you can only access classes in the API packages that are included in Android. However, if you add other projects to your libs/ folder, there is no guarantee that those .jar files were built with an Android specific classpath, and in particular, they could be accessing unsupported APIs such as java.applet.\n"
+ " \n"
+ " This check scans through library jars and looks for references to API packages that are not included in Android and flags these. This is only an error if your code calls one of the library classes which wind up referencing the unsupported package.") //
.setSeverity(ERROR) //
.build() //
);
);

}
}
2 changes: 1 addition & 1 deletion src/test/java/se/bjurr/violations/lib/CSSLintTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ public void testThatViolationsCanBeParsed() {
.setRule(null)//
.setSeverity(WARN)//
.build() //
);
);
}
}
2 changes: 1 addition & 1 deletion src/test/java/se/bjurr/violations/lib/CheckstyleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ public void testThatViolationsCanBeParsed() {
.setRule("com.puppycrawl.tools.checkstyle.checks.metrics.BooleanExpressionComplexityCheck")//
.setSeverity(WARN)//
.build()//
);
);
}
}
10 changes: 5 additions & 5 deletions src/test/java/se/bjurr/violations/lib/FindbugsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ public void testThatViolationsCanBeParsed() {
public void testMavenGeneratedFindbugs() {
String rootFolder = getRootFolder();
List<Violation> maven = violationsReporterApi() //
.withPattern(".*/findbugs/fromMaven.xml$") //
.inFolder(rootFolder) //
.findAll(FINDBUGS) //
.violations();
.withPattern(".*/findbugs/fromMaven.xml$") //
.inFolder(rootFolder) //
.findAll(FINDBUGS) //
.violations();

assertThat(maven)//
.hasSize(1);
.hasSize(1);
}
}
2 changes: 1 addition & 1 deletion src/test/java/se/bjurr/violations/lib/LintTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ public void testThatViolationsCanBeParsed() {
.setRule(null)//
.setSeverity(WARN)//
.build() //
);
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void testThatFilePathsAreAlwaysFronSlashes() {
.build()//
.getFile()//
)//
.isEqualTo("c:/path/to/file.xml");
.isEqualTo("c:/path/to/file.xml");
}

}

0 comments on commit 0934794

Please sign in to comment.