nlpub/watset-java

View on GitHub

Showing 638 of 638 total issues

Method apply has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public ClusteringAlgorithm<V> apply(Graph<V, E> graph) {
        switch (algorithm) {
            case EMPTY:
                return EmptyClustering.<V, E>builder().apply(graph);
Severity: Minor
Found in src/main/java/org/nlpub/watset/util/ClusteringAlgorithmProvider.java - About 2 hrs 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

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

    public static <V> void write(BufferedWriter writer, List<NodeEmbedding<V>> embeddings, SpaceStrategy spaceStrategy) throws IOException {
        if (embeddings.isEmpty()) {
            throw new IllegalArgumentException("embeddings should not be empty");
        }

Severity: Minor
Found in src/main/java/org/nlpub/watset/util/Word2VecFormat.java - About 2 hrs 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

Method extractClusters has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

        protected Map<V, Set<V>> extractClusters() {
            final var leaves = new HashSet<>(graph.vertexSet().size());
            final var clusters = new HashMap<V, Set<V>>();

            for (final var u : digraph.vertexSet()) {
Severity: Minor
Found in src/main/java/org/nlpub/watset/graph/MaxMax.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

Method evaluate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public PrecisionRecall evaluate(Set<Pair<V, V>> clusterPairs, Set<Pair<V, V>> classPairs) {
        final var union = new HashSet<>(clusterPairs);
        union.addAll(classPairs);

        final var preds = new boolean[union.size()];
Severity: Minor
Found in src/main/java/org/nlpub/watset/eval/Pairwise.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

Method apply has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @Override
    public ClusteringAlgorithm<V> apply(Graph<V, E> graph) {
        switch (algorithm) {
            case EMPTY:
                return EmptyClustering.<V, E>builder().apply(graph);

    Method main has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static void main(String[] args) {
            var graph = SimpleWeightedGraph.<String, DefaultWeightedEdge>createBuilder(DefaultWeightedEdge.class).
                    addVertices("a", "b", "c", "d", "e").
                    addEdge("a", "b").
                    addEdge("a", "c").
    Severity: Minor
    Found in examples/HardClustering.java - About 1 hr to fix

      Method compute has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

              public Clustering<V> compute() {
                  if (graph.vertexSet().isEmpty()) {
                      return new ClusteringImpl<>(Collections.emptyList());
                  }
      
      
      Severity: Minor
      Found in src/main/java/org/nlpub/watset/graph/MarkovClustering.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

      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

      Method run has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Override
          public void run() {
              final var clusters = transform(getClusters());
              final var classes = transform(getClasses());
      
      
      Severity: Minor
      Found in src/main/java/org/nlpub/watset/cli/PurityCommand.java - About 1 hr to fix

        Method process has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                protected void process() throws IOException {
                    output = File.createTempFile("mcl", "output");
                    output.deleteOnExit();
        
                    final var input = writeInputFile();
        Severity: Minor
        Found in src/main/java/org/nlpub/watset/graph/MarkovClusteringExternal.java - About 1 hr to fix

          Method write has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static <V> void write(BufferedWriter writer, List<NodeEmbedding<V>> embeddings, SpaceStrategy spaceStrategy) throws IOException {
                  if (embeddings.isEmpty()) {
                      throw new IllegalArgumentException("embeddings should not be empty");
                  }
          
          
          Severity: Minor
          Found in src/main/java/org/nlpub/watset/util/Word2VecFormat.java - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                                        if (digraph.containsVertex(v)) queue.addAll(Graphs.successorListOf(digraph, v));
            Severity: Major
            Found in src/main/java/org/nlpub/watset/graph/MaxMax.java - About 45 mins to fix

              Method argrandmax has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static <V, S extends Comparable<S>> Optional<V> argrandmax(Iterable<V> iterable, Function<V, S> scorer, Random random) {
                      final var results = new ArrayList<V>();
                      S score = null;
              
                      for (final var current : iterable) {
              Severity: Minor
              Found in src/main/java/org/nlpub/watset/util/Maximizer.java - About 45 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

              Method run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  @Override
                  public void run() {
                      final var clusters = transform(getClusters());
                      final var classes = transform(getClasses());
              
              
              Severity: Minor
              Found in src/main/java/org/nlpub/watset/cli/PurityCommand.java - About 45 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

              Method computeWeights has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                      private void computeWeights() {
                          for (final var edge : graph.edgeSet()) {
                              final var u = graph.getEdgeSource(edge);
                              final var v = graph.getEdgeTarget(edge);
                              final var weight = graph.getEdgeWeight(edge);
              Severity: Minor
              Found in src/main/java/org/nlpub/watset/graph/MaxMax.java - About 45 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

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

                  @SuppressWarnings("unused")
                  public final static class LocalParameters {
                      /**
                       * The local clustering algorithm.
                       */
              Severity: Minor
              Found in src/main/java/org/nlpub/watset/cli/Command.java and 1 other location - About 45 mins to fix
              src/main/java/org/nlpub/watset/cli/Command.java on lines 108..121

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

              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

                  @SuppressWarnings("unused")
                  public final static class GlobalParameters {
                      /**
                       * The global clustering algorithm.
                       */
              Severity: Minor
              Found in src/main/java/org/nlpub/watset/cli/Command.java and 1 other location - About 45 mins to fix
              src/main/java/org/nlpub/watset/cli/Command.java on lines 90..103

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

              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

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

                      var graph = SimpleWeightedGraph.<String, DefaultWeightedEdge>createBuilder(DefaultWeightedEdge.class).
                              addVertices("a", "b", "c", "d", "e").
                              addEdge("a", "b").
                              addEdge("a", "c").
                              addEdge("a", "c").
              Severity: Minor
              Found in examples/HardClustering.java and 1 other location - About 40 mins to fix
              examples/FuzzyClustering.java on lines 27..33

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

              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

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

                      var graph = SimpleWeightedGraph.<String, DefaultWeightedEdge>createBuilder(DefaultWeightedEdge.class).
                              addVertices("a", "b", "c", "d", "e").
                              addEdge("a", "b").
                              addEdge("a", "c").
                              addEdge("a", "c").
              Severity: Minor
              Found in examples/FuzzyClustering.java and 1 other location - About 40 mins to fix
              examples/HardClustering.java on lines 30..36

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

              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

                          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

              Severity
              Category
              Status
              Source
              Language