-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update for reducing the validation violations.
- Loading branch information
Showing
25 changed files
with
171 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/com/github/ninerules/rules/primitive/PrimitiveChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.github.ninerules.rules.primitive; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.eclipse.jdt.core.dom.FieldDeclaration; | ||
import org.eclipse.jdt.core.dom.Type; | ||
|
||
public class PrimitiveChecker { | ||
private List<String> list = Arrays.asList("byte", "short", "int", "long", "float", | ||
"double", "boolean", "char", "(java.lang.)?String", "(java.util.)?Date"); | ||
|
||
public boolean check(FieldDeclaration node){ | ||
Type type = node.getType(); | ||
return check(type.toString()); | ||
} | ||
|
||
private boolean check(String type){ | ||
return list.stream() | ||
.filter(item -> type.matches(item)) | ||
.count() > 0; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/com/github/ninerules/rules/results/Results.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.github.ninerules.rules.results; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.github.ninerules.Reporter; | ||
import com.github.ninerules.entities.FileName; | ||
import com.github.ninerules.rules.Violation; | ||
|
||
public class Results { | ||
Map<FileName, List<Violation>> violations = new HashMap<>(); | ||
|
||
public Results(FileName fileName, List<Violation> list){ | ||
violations.put(fileName, list); | ||
} | ||
|
||
private Results(){ | ||
} | ||
|
||
public static final Results empty(){ | ||
return new Results(); | ||
} | ||
|
||
public boolean contains(FileName fileName, Violation violation){ | ||
List<Violation> list = violations.getOrDefault(fileName, new ArrayList<>()); | ||
return list.contains(violation); | ||
} | ||
|
||
public void report(Reporter reporter){ | ||
violations.entrySet() | ||
.stream() | ||
.forEach(item -> report(reporter, item)); | ||
} | ||
|
||
public void report(Reporter reporter, Map.Entry<FileName, List<Violation>> entry){ | ||
FileName name = entry.getKey(); | ||
List<Violation> violations = entry.getValue(); | ||
reporter.report(name, violations); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/github/ninerules/rules/results/ResultsAppender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.github.ninerules.rules.results; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.github.ninerules.entities.FileName; | ||
import com.github.ninerules.rules.Violation; | ||
|
||
public class ResultsAppender { | ||
private Results results; | ||
|
||
public ResultsAppender(Results results){ | ||
this.results = results; | ||
} | ||
|
||
public Results append(Results results){ | ||
results.violations | ||
.entrySet() | ||
.stream() | ||
.forEach(item -> put(item)); | ||
return this.results; | ||
} | ||
|
||
private void put(Map.Entry<FileName, List<Violation>> entry){ | ||
FileName name = entry.getKey(); | ||
List<Violation> list = entry.getValue(); | ||
put(name, list); | ||
} | ||
|
||
private void put(FileName name, List<Violation> list){ | ||
Map<FileName, List<Violation>> map = results.violations; | ||
List<Violation> origList = map.getOrDefault(name, new ArrayList<>()); | ||
origList.addAll(list); | ||
map.put(name, origList); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.