nlpub/watset-java

View on GitHub
src/main/java/org/nlpub/watset/eval/NormalizedModifiedPurity.java

Summary

Maintainability
A
0 mins
Test Coverage

Parameters to purity have the same names but not the same order as the method arguments.
Open

        final var niPU = recall.purity(classes, clusters);

When the names of parameters in a method call match the names of the method arguments, it contributes to clearer, more readable code. However, when the names match, but are passed in a different order than the method arguments, it indicates a mistake in the parameter order which will likely lead to unexpected results.

Noncompliant Code Example

public double divide(int divisor, int dividend) {
  return divisor/dividend;
}

public void doTheThing() {
  int divisor = 15;
  int dividend = 5;

  double result = divide(dividend, divisor);  // Noncompliant; operation succeeds, but result is unexpected
  //...
}

Compliant Solution

public double divide(int divisor, int dividend) {
  return divisor/dividend;
}

public void doTheThing() {
  int divisor = 15;
  int dividend = 5;

  double result = divide(divisor, dividend);
  //...
}

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

        if (intersection.isEmpty()) return 0;

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

            if (cluster.size() != normalizedCluster.size()) throw new IllegalArgumentException("Cluster size changed");

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

        if (denominator == 0) return 0;

Wrong lexicographical order for 'java.util.function.Function.identity' import. Should be before 'java.util.stream.Collectors'.
Open

import static java.util.function.Function.identity;

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

        if (clusters.size() != normalized.size()) throw new IllegalArgumentException("Collection size changed");

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().

<p> tag should be preceded with an empty line.</p>
Open

 * <p>

Checks the Javadoc paragraph.

Checks that:

  • There is one blank line between each of two paragraphs.
  • Each paragraph but the first has <p> immediately before the first word, withno space after.

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

                map(cluster -> cluster.stream().collect(Collectors.groupingBy(identity(), Collectors.reducing(0d, e -> 1d, Double::sum)))).

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

        if (clusters.size() != normalized.size()) throw new IllegalArgumentException("Collection size changed");

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

                forEach(entry -> counter.put(entry.getKey(), counter.getOrDefault(entry.getKey(), 0d) + entry.getValue()));

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

                    mapToDouble(cluster -> cluster.values().stream().mapToDouble(Double::doubleValue).sum()).

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

        final var numerator = clusters.parallelStream().mapToDouble(cluster -> score(cluster, classes)).sum();

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.

<p> tag should be preceded with an empty line.</p>
Open

     * <p>

Checks the Javadoc paragraph.

Checks that:

  • There is one blank line between each of two paragraphs.
  • Each paragraph but the first has <p> immediately before the first word, withno space after.

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

                map(cluster -> cluster.stream().collect(Collectors.groupingBy(identity(), Collectors.reducing(0d, e -> 1d, Double::sum)))).

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 (modified && !(cluster.size() > 1)) return 0;

<p> tag should be placed immediately before the first word, with no space after.</p>
Open

 * <p>

Checks the Javadoc paragraph.

Checks that:

  • There is one blank line between each of two paragraphs.
  • Each paragraph but the first has <p> immediately before the first word, withno space after.

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

                flatMap(cluster -> cluster.entrySet().stream()).

'.' should be on a new line.
Open

                    mapToDouble(cluster -> cluster.values().stream().mapToDouble(Double::doubleValue).sum()).

Wrong lexicographical order for 'java.util.Objects.requireNonNull' import. Should be before 'java.util.stream.Collectors'.
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.

'.' should be on a new line.
Open

            final var normalizedCluster = cluster.entrySet().stream().

'.' should be on a new line.
Open

            denominator = clusters.parallelStream().

<p> tag should be placed immediately before the first word, with no space after.</p>
Open

     * <p>

Checks the Javadoc paragraph.

Checks that:

  • There is one blank line between each of two paragraphs.
  • Each paragraph but the first has <p> immediately before the first word, withno space after.

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

 * Please be especially careful with the {@code hashCode} and {@code equals} methods of the elements.

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

                    collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue() / counter.get(entry.getKey())));

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

            if (cluster.size() != normalizedCluster.size()) throw new IllegalArgumentException("Cluster size changed");

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.

Each variable declaration must be in its own statement.
Open

    final boolean normalized, modified;

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.

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

     * Construct a normalized modified purity calculator that allows turning normalized and/or modified options off.

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 (!normalized) return intersection.size();

Extra separation in import group before 'java.util.Objects.requireNonNull'
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 196).
Open

    public static <V> PrecisionRecall evaluate(NormalizedModifiedPurity<V> precision, NormalizedModifiedPurity<V> recall, Collection<Map<V, Double>> clusters, Collection<Map<V, Double>> 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.

There are no issues that match your filters.

Category
Status