nlpub/watset-java

View on GitHub

Showing 638 of 638 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            if (normalized) {
                writer.write(String.format(Locale.ROOT, "niPU: %f", results.getRecall()));
            } else {
                writer.write(String.format(Locale.ROOT, "iPU: %f", results.getRecall()));
            }
Severity: Minor
Found in src/main/java/org/nlpub/watset/cli/PurityCommand.java and 1 other location - About 40 mins to fix
src/main/java/org/nlpub/watset/cli/PurityCommand.java on lines 71..75

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 48.

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

Further Reading

Method write has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public static void write(BufferedWriter writer, ClusteringAlgorithm.Clustering<String> clustering) throws IOException {
        final Iterable<Set<String>> clusters = () -> clustering.getClusters().stream().
                sorted((smaller, larger) -> Integer.compare(larger.size(), smaller.size())).
                iterator();

Severity: Minor
Found in src/main/java/org/nlpub/watset/util/ILEFormat.java - About 35 mins 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

Avoid too many return statements within this method.
Open

                return mclOfficial.apply(graph);
Severity: Major
Found in src/main/java/org/nlpub/watset/util/ClusteringAlgorithmProvider.java - About 30 mins to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public static class RowNormalizeVisitor extends DefaultRealMatrixChangingVisitor {
            /**
             * The row norms.
             */
            private final RealVector norms;
    Severity: Minor
    Found in src/main/java/org/nlpub/watset/util/Matrices.java and 1 other location - About 30 mins to fix
    src/main/java/org/nlpub/watset/util/Matrices.java on lines 236..263

    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 40.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public static class ColumnNormalizeVisitor extends DefaultRealMatrixChangingVisitor {
            /**
             * The row sums.
             */
            private final RealVector sums;
    Severity: Minor
    Found in src/main/java/org/nlpub/watset/util/Matrices.java and 1 other location - About 30 mins to fix
    src/main/java/org/nlpub/watset/util/Matrices.java on lines 268..295

    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 40.

    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

    Further Reading

    Method argmax has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public static <V, S extends Comparable<S>> Optional<V> argmax(Iterable<V> iterable, Predicate<V> checker, Function<V, S> scorer) {
            V result = null;
            S score = null;
    
            for (final var current : iterable) {
    Severity: Minor
    Found in src/main/java/org/nlpub/watset/util/Maximizer.java - About 25 mins 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

    Wrong lexicographical order for 'java.util.Objects.requireNonNull' import. Should be before 'org.jgrapht.graph.SimpleWeightedGraph'.
    Open

    import static java.util.Objects.requireNonNull;

    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.lang.System.Logger.Level' import. Should be before 'org.nlpub.watset.graph.NodeEmbedding'.
    Open

    import java.lang.System.Logger.Level;

    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.nio.file.Path' import. Should be before 'org.nlpub.watset.graph.*'.
    Open

    import java.nio.file.Path;

    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.Objects.requireNonNullElse' import. Should be before 'org.nlpub.watset.graph.*'.
    Open

    import static java.util.Objects.requireNonNullElse;

    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.

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

                    final int numTrials = params.containsKey("n") ? Integer.parseInt(params.get("n")) : 10;

    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.

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

    import java.util.Locale;

    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.

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

            return (first.hashCode() <= second.hashCode()) ? Pair.of(first, second) : Pair.of(second, first);

    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 128).
    Open

        public PrecisionRecall evaluate(Collection<? extends Collection<V>> clusters, Collection<? extends Collection<V>> classes) {

    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

            return clusters.stream().

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

    import static java.util.Objects.requireNonNull;

    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.

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

            @Parameter(names = {"-s", "--seed"}, description = "Random seed", converter = RandomConverter.class)

    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.

    Extra separation in import group before 'java.io.IOException'
    Open

    import java.io.IOException;
    Severity: Minor
    Found in examples/PickleClustering.java by checkstyle

    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.

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

            var clusterCounts = NormalizedModifiedPurity.normalize(NormalizedModifiedPurity.transform(clusters));
    Severity: Minor
    Found in examples/EvaluateClustering.java by checkstyle

    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.

    Severity
    Category
    Status
    Source
    Language