Showing 146 of 168 total issues
Method execute
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
getLog().info("Reverse modeling starting ...");
try {
String[] dirPaths = rootDir.split(":");
ClassMethodDistributionAstNodeVisitor
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class ClassMethodDistributionAstNodeVisitor extends VoidVisitorAdapter<ClassMethodReport> {
private static Set<String> ignoredMethodNames = new HashSet<>();
private static Set<Class> ignoredMethodAnnotation = new HashSet<>();
private static Set<Class> ignoredClassAnnotation = new HashSet<>();
static {
Method parse
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Map<KeyElement.Type, KeyPropertyEntry> parse(AnnotationExpr keyElement) {
List<KeyElement.Type> types = new ArrayList<>();
KeyPropertyEntry entry = new KeyPropertyEntry();
entry.setJavadoc(JavaParserUtil.javadocFirstLineOf(bodyDeclaration));
if (fieldDeclaration != null) {
Method visit
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void visit(final MethodDeclaration methodDeclaration, final KeyRuleReport report) {
super.visit(methodDeclaration, report);
if (!methodDeclaration.isAnnotationPresent(KeyRule.class)) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method parse
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public AggregateEntry parse(AnnotationExpr aggregateAnnotationExpr) {
AggregateEntry entry = new AggregateEntry();
entry.setPackageName(packageDeclaration.getNameAsString());
NormalAnnotationExpr expr = (NormalAnnotationExpr) aggregateAnnotationExpr;
for (MemberValuePair memberValuePair : expr.getPairs()) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method match
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
@Override
public final boolean match(@NonNull IIdentity identity) {
Class<? extends BasePattern> patternClazz = this.getClass();
Class<? extends IIdentity> identityClazz = identity.getClass();
String cacheKey = patternClazz.getName() + ":" + identityClazz.getName(); // pure perf
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Similar blocks of code found in 2 locations. Consider refactoring. Open
for (int i = 0; i < rawModels.size(); i++) {
for (int j = i + 1; j < rawModels.size(); j++) {
KeyModelEntry model1 = rawModels.get(i);
KeyModelEntry model2 = rawModels.get(j);
double similarity = similarityAnalyzer.rawModelSimilarity(model1, model2);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 134.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
for (int i = 0; i < keyModelEntries.size(); i++) {
for (int j = i + 1; j < keyModelEntries.size(); j++) {
KeyModelEntry model1 = keyModelEntries.get(i);
KeyModelEntry model2 = keyModelEntries.get(j);
double similarity = similarityAnalyzer.similarity(model1, model2);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 134.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method displayRelations
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public Set<Pair> displayRelations() {
Set<Pair> result = new TreeSet<>();
for (Pair self : relations) {
if (ignored(self)) {
continue;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method parse
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public KeyFlowEntry parse(AnnotationExpr keyFlow) {
KeyFlowEntry entry = new KeyFlowEntry(className, methodName,
JavaParserUtil.javadocFirstLineOf(methodDeclaration));
entry.setRealArguments(JavaParserUtil.extractMethodArguments(methodDeclaration));
Method export
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
synchronized void export() {
// domains
this.domains = new ArrayList<>(InternalIndexer.domainDefMap.size());
domains.addAll(InternalIndexer.domainDefMap.values().stream().map(domainDef -> new Domain(domainDef.getCode(), domainDef.getName())).collect(Collectors.toList()));
Method visit
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void visit(final FieldDeclaration fieldDeclaration, final KeyModelReport report) {
super.visit(fieldDeclaration, report);
ClassOrInterfaceDeclaration parentClass = JavaParserUtil.getClass(fieldDeclaration.getParentNode().get());
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method visit
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void visit(final FieldDeclaration fieldDeclaration, final KeyModelReport report) {
super.visit(fieldDeclaration, report);
ClassOrInterfaceDeclaration parentClass = JavaParserUtil.getClass(fieldDeclaration.getParentNode().get());
Method writeClazzDefinition
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void writeClazzDefinition(AggregateEntry aggregateEntry, KeyModelEntry keyModelEntry) throws SQLException, ClassNotFoundException {
List<String> sqlList = new LinkedList<>();
for (KeyElement.Type type : keyModelEntry.types()) {
for (KeyPropertyEntry propertyEntry : keyModelEntry.keyPropertiesByType(type)) {
sqlList.add(String.format(EntityInsert,
Method visit
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void visit(final MethodDeclaration methodDeclaration, final KeyRuleReport report) {
super.visit(methodDeclaration, report);
if (!methodDeclaration.isAnnotationPresent(KeyRule.class)) {
Method packageOfKeyRelationRightClass
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public static String packageOfKeyRelationRightClass(AnnotationExpr keyRelation, ClassExpr rightClassExpr) {
CompilationUnit cu = null;
Node node = keyRelation.getParentNode().get();
for (; ; ) {
Optional<Node> parent = node.getParentNode();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method skipMethod
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private boolean skipMethod(MethodDeclaration methodDeclaration, ClassOrInterfaceDeclaration parentClass) {
if (methodDeclaration.isAnnotationPresent(AllowedAccessors.class)) {
// 指定类可访问的方法,忽略
return true;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method cluster
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public List<List<String>> cluster(List<double[]> vectors, List<String> labels, Map<String, double[]> vectorMap) {
// 随机初始化簇中心
List<double[]> centroids = new ArrayList<>();
for (int i = 0; i < numClusters; i++) {
centroids.add(vectors.get(random.nextInt(vectors.size())));
Method executeSteps
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
private List<String> executeSteps(String activityCode, List<String> stepCodes, Stack<IRevokableDomainStep> executedSteps, Model model,
SchedulingTaskExecutor taskExecutor, Set<String> asyncStepCodes) throws RuntimeException {
if (asyncStepCodes == null || taskExecutor == null) {
// the sentry
asyncStepCodes = emptyAsyncSteps;
Method execute
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
getLog().info("Reverse modeling starting ...");
try {
String[] dirPaths = rootDir.split(":");
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"