nlpub/watset-java

View on GitHub
src/main/java/org/nlpub/watset/graph/WatsetClustering.java

Summary

Maintainability
A
1 hr
Test Coverage

Method getContexts has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        @Override
        public Map<Sense<V>, Map<Sense<V>, Number>> getContexts() {
            if (isNull(contexts)) {
                contexts = new HashMap<>(senseGraph.vertexSet().size());

Severity: Minor
Found in src/main/java/org/nlpub/watset/graph/WatsetClustering.java - About 1 hr to fix

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

Line is longer than 100 characters (found 112).
Open

    class WatsetClusteringImpl<V> extends ClusteringAlgorithm.ClusteringImpl<V> implements WatsetClustering<V> {

Checks for long lines.

Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Line is longer than 100 characters (found 116).
Open

                    final Sense<V> source = senseGraph.getEdgeSource(edge), target = senseGraph.getEdgeTarget(edge);

Checks for long lines.

Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

'+' should be on a new line.
Open

                            senseGraph.vertexSet().size() +

'+' should be on a new line.
Open

                            ", but got " +

Using the '.*' form of import should be avoided - java.util.*.
Open

import java.util.*;

Checks that there are no import statements that use the * notation.

Rationale: Importing all classes from a package or staticmembers from a class leads to tight coupling between packagesor classes and might lead to problems when a new version of alibrary introduces name clashes.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Each variable declaration must be in its own statement.
Open

                    final Sense<V> source = senseGraph.getEdgeSource(edge), target = senseGraph.getEdgeTarget(edge);

Checks that each variable declaration is in its own statement and onits own line.

Rationale: the Java code conventions chapter 6.1 recommends thatdeclarations should be one per line/statement.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Extra separation in import group before 'java.util.*'
Open

import java.util.*;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Extra separation in import group before 'java.util.Objects.isNull'
Open

import static java.util.Objects.isNull;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

'+' should be on a new line.
Open

                    throw new IllegalStateException("Mismatch in number of senses: expected " +

Line is longer than 100 characters (found 144).
Open

        public WatsetClusteringImpl(List<Set<V>> clusters, Map<V, Map<V, Integer>> inventory, Graph<Sense<V>, DefaultWeightedEdge> senseGraph) {

Checks for long lines.

Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

'if' construct must use '{}'s.
Open

                    if (!contexts.containsKey(source)) contexts.put(source, new HashMap<>());

Wrong lexicographical order for 'java.util.Objects.isNull' import. Should be before 'org.nlpub.watset.util.Sense'.
Open

import static java.util.Objects.isNull;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Wrong lexicographical order for 'java.util.*' import. Should be before 'org.nlpub.watset.util.Sense'.
Open

import java.util.*;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

'if' construct must use '{}'s.
Open

                    if (!contexts.containsKey(target)) contexts.put(target, new HashMap<>());

There are no issues that match your filters.

Category
Status