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);
- Read upRead up
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");
}
- Read upRead up
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()) {
- Read upRead up
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()];
- Read upRead up
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").
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());
}
- Read upRead up
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());
- Read upRead up
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());
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();
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");
}
Avoid deeply nested control flow statements. Open
if (digraph.containsVertex(v)) queue.addAll(Graphs.successorListOf(digraph, v));
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) {
- Read upRead up
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());
- Read upRead up
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);
- Read upRead up
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();
- Read upRead up
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);
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) {
- Read upRead up
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"