nlpub/watset-java

View on GitHub

Showing 18 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

              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

                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

                Severity
                Category
                Status
                Source
                Language