Skip to content

Commit

Permalink
Merge 6e1f358 into d8ad439
Browse files Browse the repository at this point in the history
  • Loading branch information
tamada committed Nov 2, 2017
2 parents d8ad439 + 6e1f358 commit c277dd4
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 15 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,12 @@ tramp
.cask/


### https://raw.github.com/github/gitignore/9da1b5d8ce4e009ff627c4fe49a4488b2a3f60d4/Global/jenv.gitignore

# JEnv local Java version configuration file
.java-version

# Used by previous versions of JEnv
.jenv-version


Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/github/ninerules/NineRulesValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ public NineRulesValidator(StrictLevel level){
}

public Results validate(List<Path> list){
return validateOf(list.stream(), level)
return validateOf(list.stream())
.orElse(Results.empty());
}

private Optional<Results> validateOf(Stream<Path> stream, StrictLevel level){
return stream.map(path -> validate(path, level))
private Optional<Results> validateOf(Stream<Path> stream){
return stream.map(this::validate)
.reduce(Results::append);
}

private Results validate(Path path, StrictLevel level){
private Results validate(Path path){
Target target = parse(path);
return new Rules(level).validate(target);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import com.github.ninerules.rules.jdtvisitor.JdtValidator;

public class NoAccessorValidator extends JdtValidator{
public static final Message SETTER = new Message("setter method found");
public static final Message GETTER = new Message("getter method found");
public static final Message SETTER = new Message("setter method found.");
public static final Message GETTER = new Message("getter method found.");

private AccessorChecker checker = new AccessorChecker();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.github.ninerules.rules.jdtvisitor.FieldCollectingValidator;

public class FieldCountValidator extends FieldCollectingValidator {
public static final Message FIELD_COUNT = new Message("field count is more than %s");
public static final Message FIELD_COUNT = new Message("field count is more than %s.");

private FieldChecker checker = new FieldChecker();
private Predicate<FieldDeclaration> predicate = item -> !checker.checkStaticAndFinal(item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.github.ninerules.rules.jdtvisitor.JdtValidator;

public class IndentLevelValidator extends JdtValidator{
public static final Message INDENT_LEVEL = new Message("Indentation level is too much (more than %s indent level)");
public static final Message INDENT_LEVEL = new Message("indentation level is too much (more than %s indent level).");

public IndentLevelValidator(StrictLevel level) {
super(level);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.github.ninerules.rules.stringvisitor.PlainSourceValidator;

public class OneDotPerLineValidator extends PlainSourceValidator{
public static final Message ONE_DOT = new Message("Many dots per line (more than %s dots)");
public static final Message ONE_DOT = new Message("many dots per line (more than %s dots).");
private static final Pattern PATTERN = Pattern.compile("\\.");

private StringFilterManager filter = new StringFilterManager();
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/com/github/ninerules/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ public void testSrcTestResourcesHello() throws Exception{
assertThat(lines.length, is(17));
assertThat(lines[ 0], is("src/test/resources/hello/src/main/java/sample/hello/GodObject.java"));
assertThat(lines[ 1], is("line: 53, else statement found."));
assertThat(lines[ 2], is("line: 13,14,15,16, field count is more than 2"));
assertThat(lines[ 2], is("line: 13,14,15,16, field count is more than 2."));
assertThat(lines[ 3], is("line: 13,14,15,16, not first class collection."));
assertThat(lines[ 4], is("line: 43, Indentation level is too much (more than 1 indent level)"));
assertThat(lines[ 5], is("line: 28, Many dots per line (more than 1 dots)"));
assertThat(lines[ 6], is("line: 29, Many dots per line (more than 1 dots)"));
assertThat(lines[ 4], is("line: 43, indentation level is too much (more than 1 indent level)."));
assertThat(lines[ 5], is("line: 28, many dots per line (more than 1 dots)."));
assertThat(lines[ 6], is("line: 29, many dots per line (more than 1 dots)."));
assertThat(lines[ 7], is("line: 13,14,15,16, no primitives."));
assertThat(lines[ 8], is("line: 43, method is too long (over 3 lines)."));
assertThat(lines[ 9], is("line: 65, source code is too long (over 50 lines)."));
assertThat(lines[10], is("src/test/resources/hello/src/main/java/sample/hello/GodObjectButNotTarget.java"));
assertThat(lines[11], is("src/test/resources/hello/src/main/java/sample/hello/HelloWorld.java"));
assertThat(lines[12], is("line: 10, setter method found"));
assertThat(lines[13], is("line: 14, getter method found"));
assertThat(lines[12], is("line: 10, setter method found."));
assertThat(lines[13], is("line: 14, getter method found."));
assertThat(lines[14], is("line: 18, method is too long (over 3 lines)."));
assertThat(lines[15], is("src/test/resources/hello/src/main/java/sample/hello/Launcher.java"));
assertThat(lines[16], is("line: 10, method is too long (over 3 lines)."));
Expand Down

0 comments on commit c277dd4

Please sign in to comment.