nlpub/watset-java

View on GitHub
examples/HardClustering.java

Summary

Maintainability
A
2 hrs
Test Coverage

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

    Replace this use of System.out or System.err by a logger.
    Open

            System.out.println(empty.getClustering());
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    When logging a message there are several important requirements which must be fulfilled:

    • The user must be able to easily retrieve the logs
    • The format of all logged message must be uniform to allow the user to easily read the log
    • Logged data must actually be recorded
    • Sensitive data must only be logged securely

    If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended.

    Noncompliant Code Example

    System.out.println("My Message");  // Noncompliant
    

    Compliant Solution

    logger.log("My Message");
    

    See

    Replace this use of System.out or System.err by a logger.
    Open

            System.out.print("Singleton: ");
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    When logging a message there are several important requirements which must be fulfilled:

    • The user must be able to easily retrieve the logs
    • The format of all logged message must be uniform to allow the user to easily read the log
    • Logged data must actually be recorded
    • Sensitive data must only be logged securely

    If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended.

    Noncompliant Code Example

    System.out.println("My Message");  // Noncompliant
    

    Compliant Solution

    logger.log("My Message");
    

    See

    Replace this use of System.out or System.err by a logger.
    Open

            System.out.print("Chinese Whispers: ");
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    When logging a message there are several important requirements which must be fulfilled:

    • The user must be able to easily retrieve the logs
    • The format of all logged message must be uniform to allow the user to easily read the log
    • Logged data must actually be recorded
    • Sensitive data must only be logged securely

    If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended.

    Noncompliant Code Example

    System.out.println("My Message");  // Noncompliant
    

    Compliant Solution

    logger.log("My Message");
    

    See

    Replace this use of System.out or System.err by a logger.
    Open

            System.out.println(components.getClustering());
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    When logging a message there are several important requirements which must be fulfilled:

    • The user must be able to easily retrieve the logs
    • The format of all logged message must be uniform to allow the user to easily read the log
    • Logged data must actually be recorded
    • Sensitive data must only be logged securely

    If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended.

    Noncompliant Code Example

    System.out.println("My Message");  // Noncompliant
    

    Compliant Solution

    logger.log("My Message");
    

    See

    Replace this use of System.out or System.err by a logger.
    Open

            System.out.print("Empty: ");
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    When logging a message there are several important requirements which must be fulfilled:

    • The user must be able to easily retrieve the logs
    • The format of all logged message must be uniform to allow the user to easily read the log
    • Logged data must actually be recorded
    • Sensitive data must only be logged securely

    If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended.

    Noncompliant Code Example

    System.out.println("My Message");  // Noncompliant
    

    Compliant Solution

    logger.log("My Message");
    

    See

    Replace this use of System.out or System.err by a logger.
    Open

            System.out.print("Girvan-Newman (k=2): ");
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    When logging a message there are several important requirements which must be fulfilled:

    • The user must be able to easily retrieve the logs
    • The format of all logged message must be uniform to allow the user to easily read the log
    • Logged data must actually be recorded
    • Sensitive data must only be logged securely

    If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended.

    Noncompliant Code Example

    System.out.println("My Message");  // Noncompliant
    

    Compliant Solution

    logger.log("My Message");
    

    See

    Replace this use of System.out or System.err by a logger.
    Open

            System.out.print("k Spanning Tree (k=2): ");
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    When logging a message there are several important requirements which must be fulfilled:

    • The user must be able to easily retrieve the logs
    • The format of all logged message must be uniform to allow the user to easily read the log
    • Logged data must actually be recorded
    • Sensitive data must only be logged securely

    If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended.

    Noncompliant Code Example

    System.out.println("My Message");  // Noncompliant
    

    Compliant Solution

    logger.log("My Message");
    

    See

    Replace this use of System.out or System.err by a logger.
    Open

            System.out.print("Spectral Clustering (k=2): ");
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    When logging a message there are several important requirements which must be fulfilled:

    • The user must be able to easily retrieve the logs
    • The format of all logged message must be uniform to allow the user to easily read the log
    • Logged data must actually be recorded
    • Sensitive data must only be logged securely

    If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended.

    Noncompliant Code Example

    System.out.println("My Message");  // Noncompliant
    

    Compliant Solution

    logger.log("My Message");
    

    See

    Replace this use of System.out or System.err by a logger.
    Open

            System.out.println(spectral.getClustering());
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    When logging a message there are several important requirements which must be fulfilled:

    • The user must be able to easily retrieve the logs
    • The format of all logged message must be uniform to allow the user to easily read the log
    • Logged data must actually be recorded
    • Sensitive data must only be logged securely

    If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended.

    Noncompliant Code Example

    System.out.println("My Message");  // Noncompliant
    

    Compliant Solution

    logger.log("My Message");
    

    See

    Replace this use of System.out or System.err by a logger.
    Open

            System.out.println(singleton.getClustering());
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    When logging a message there are several important requirements which must be fulfilled:

    • The user must be able to easily retrieve the logs
    • The format of all logged message must be uniform to allow the user to easily read the log
    • Logged data must actually be recorded
    • Sensitive data must only be logged securely

    If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended.

    Noncompliant Code Example

    System.out.println("My Message");  // Noncompliant
    

    Compliant Solution

    logger.log("My Message");
    

    See

    Replace this use of System.out or System.err by a logger.
    Open

            System.out.print("Together: ");
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    When logging a message there are several important requirements which must be fulfilled:

    • The user must be able to easily retrieve the logs
    • The format of all logged message must be uniform to allow the user to easily read the log
    • Logged data must actually be recorded
    • Sensitive data must only be logged securely

    If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended.

    Noncompliant Code Example

    System.out.println("My Message");  // Noncompliant
    

    Compliant Solution

    logger.log("My Message");
    

    See

    Replace this use of System.out or System.err by a logger.
    Open

            System.out.println(kst.getClustering());
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    When logging a message there are several important requirements which must be fulfilled:

    • The user must be able to easily retrieve the logs
    • The format of all logged message must be uniform to allow the user to easily read the log
    • Logged data must actually be recorded
    • Sensitive data must only be logged securely

    If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended.

    Noncompliant Code Example

    System.out.println("My Message");  // Noncompliant
    

    Compliant Solution

    logger.log("My Message");
    

    See

    Replace this use of System.out or System.err by a logger.
    Open

            System.out.print("Graph: ");
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    When logging a message there are several important requirements which must be fulfilled:

    • The user must be able to easily retrieve the logs
    • The format of all logged message must be uniform to allow the user to easily read the log
    • Logged data must actually be recorded
    • Sensitive data must only be logged securely

    If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended.

    Noncompliant Code Example

    System.out.println("My Message");  // Noncompliant
    

    Compliant Solution

    logger.log("My Message");
    

    See

    Replace this use of System.out or System.err by a logger.
    Open

            System.out.println(graph);
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    When logging a message there are several important requirements which must be fulfilled:

    • The user must be able to easily retrieve the logs
    • The format of all logged message must be uniform to allow the user to easily read the log
    • Logged data must actually be recorded
    • Sensitive data must only be logged securely

    If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended.

    Noncompliant Code Example

    System.out.println("My Message");  // Noncompliant
    

    Compliant Solution

    logger.log("My Message");
    

    See

    Replace this use of System.out or System.err by a logger.
    Open

            System.out.println(cw.getClustering());
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    When logging a message there are several important requirements which must be fulfilled:

    • The user must be able to easily retrieve the logs
    • The format of all logged message must be uniform to allow the user to easily read the log
    • Logged data must actually be recorded
    • Sensitive data must only be logged securely

    If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended.

    Noncompliant Code Example

    System.out.println("My Message");  // Noncompliant
    

    Compliant Solution

    logger.log("My Message");
    

    See

    Replace this use of System.out or System.err by a logger.
    Open

            System.out.print("Markov Clustering: ");
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    When logging a message there are several important requirements which must be fulfilled:

    • The user must be able to easily retrieve the logs
    • The format of all logged message must be uniform to allow the user to easily read the log
    • Logged data must actually be recorded
    • Sensitive data must only be logged securely

    If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended.

    Noncompliant Code Example

    System.out.println("My Message");  // Noncompliant
    

    Compliant Solution

    logger.log("My Message");
    

    See

    Replace this use of System.out or System.err by a logger.
    Open

            System.out.println(mcl.getClustering());
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    When logging a message there are several important requirements which must be fulfilled:

    • The user must be able to easily retrieve the logs
    • The format of all logged message must be uniform to allow the user to easily read the log
    • Logged data must actually be recorded
    • Sensitive data must only be logged securely

    If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended.

    Noncompliant Code Example

    System.out.println("My Message");  // Noncompliant
    

    Compliant Solution

    logger.log("My Message");
    

    See

    Replace this use of System.out or System.err by a logger.
    Open

            System.out.println(gn.getClustering());
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    When logging a message there are several important requirements which must be fulfilled:

    • The user must be able to easily retrieve the logs
    • The format of all logged message must be uniform to allow the user to easily read the log
    • Logged data must actually be recorded
    • Sensitive data must only be logged securely

    If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended.

    Noncompliant Code Example

    System.out.println("My Message");  // Noncompliant
    

    Compliant Solution

    logger.log("My Message");
    

    See

    Replace this use of System.out or System.err by a logger.
    Open

            System.out.println(together.getClustering());
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    When logging a message there are several important requirements which must be fulfilled:

    • The user must be able to easily retrieve the logs
    • The format of all logged message must be uniform to allow the user to easily read the log
    • Logged data must actually be recorded
    • Sensitive data must only be logged securely

    If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended.

    Noncompliant Code Example

    System.out.println("My Message");  // Noncompliant
    

    Compliant Solution

    logger.log("My Message");
    

    See

    Replace this use of System.out or System.err by a logger.
    Open

            System.out.print("Components: ");
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    When logging a message there are several important requirements which must be fulfilled:

    • The user must be able to easily retrieve the logs
    • The format of all logged message must be uniform to allow the user to easily read the log
    • Logged data must actually be recorded
    • Sensitive data must only be logged securely

    If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended.

    Noncompliant Code Example

    System.out.println("My Message");  // Noncompliant
    

    Compliant Solution

    logger.log("My Message");
    

    See

    This block of commented-out lines of code should be removed.
    Open

     * Licensed under the Apache License, Version 2.0 (the "License");
    Severity: Major
    Found in examples/HardClustering.java by sonar-java

    Programmers should not comment out code as it bloats programs and reduces readability.

    Unused code should be deleted and can be retrieved from source control history if required.

    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

    '.' should be on a new line.
    Open

            var graph = SimpleWeightedGraph.<String, DefaultWeightedEdge>createBuilder(DefaultWeightedEdge.class).
    Severity: Minor
    Found in examples/HardClustering.java by checkstyle

    '.' should be on a new line.
    Open

                    addVertices("a", "b", "c", "d", "e").
    Severity: Minor
    Found in examples/HardClustering.java by checkstyle

    '.' should be on a new line.
    Open

                    addEdge("a", "c").
    Severity: Minor
    Found in examples/HardClustering.java by checkstyle

    '.' should be on a new line.
    Open

                    addEdge("a", "c").
    Severity: Minor
    Found in examples/HardClustering.java by checkstyle

    '.' should be on a new line.
    Open

                    addEdge("a", "b").
    Severity: Minor
    Found in examples/HardClustering.java by checkstyle

    '.' should be on a new line.
    Open

                    addEdge("d", "e").
    Severity: Minor
    Found in examples/HardClustering.java by checkstyle

    Using the '.*' form of import should be avoided - org.nlpub.watset.graph.*.
    Open

    import org.nlpub.watset.graph.*;
    Severity: Minor
    Found in examples/HardClustering.java by checkstyle

    Checks that there are no import statements that use the * notation.

    Rationale: Importing all classes from a package or staticmembers from a class leads to tight coupling between packagesor classes and might lead to problems when a new version of alibrary introduces name clashes.

    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

            var graph = SimpleWeightedGraph.<String, DefaultWeightedEdge>createBuilder(DefaultWeightedEdge.class).
    Severity: Minor
    Found in examples/HardClustering.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.

    There are no issues that match your filters.

    Category
    Status