SiLeBAT/FSK-Lab

View on GitHub
org.hsh.bfr.db/src/org/hsh/bfr/db/VersionComprator.java

Summary

Maintainability
C
1 day
Test Coverage

Method compare has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    public int compare(Object o1, Object o2) {
        String version1 = (String) o1;
        String version2 = (String) o2;

        VersionTokenizer tokenizer1 = new VersionTokenizer(version1);
Severity: Minor
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/VersionComprator.java - About 4 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 compare has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public int compare(Object o1, Object o2) {
        String version1 = (String) o1;
        String version2 = (String) o2;

        VersionTokenizer tokenizer1 = new VersionTokenizer(version1);
Severity: Minor
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/VersionComprator.java - About 1 hr to fix

Method MoveNext has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public boolean MoveNext() {
        _number = 0;
        _suffix = "";
        // No more characters
        if (_position >= _length)
Severity: Minor
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/VersionComprator.java - About 55 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 0;
Severity: Major
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/VersionComprator.java - About 30 mins to fix

Avoid too many return statements within this method.
Open

            if (empty2) return -1; // Second suffix is empty (1.2a < 1.2)
Severity: Major
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/VersionComprator.java - About 30 mins to fix

Avoid too many return statements within this method.
Open

            if (empty1) return 1; // First suffix is empty (1.2 > 1.2b)
Severity: Major
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/VersionComprator.java - About 30 mins to fix

Avoid too many return statements within this method.
Open

            if (result != 0) return result;
Severity: Major
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/VersionComprator.java - About 30 mins to fix

Avoid too many return statements within this method.
Open

            return 0;
Severity: Major
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/VersionComprator.java - About 30 mins to fix

Avoid too many return statements within this method.
Open

                    return -1;
Severity: Major
Found in org.hsh.bfr.db/src/org/hsh/bfr/db/VersionComprator.java - About 30 mins to fix

Refactor this method to reduce its Cognitive Complexity from 31 to the 15 allowed.
Open

    public int compare(Object o1, Object o2) {

Cognitive Complexity is a measure of how hard the control flow of a method is to understand. Methods with high Cognitive Complexity will be difficult to maintain.

See

There are no issues that match your filters.

Category
Status