org.hsh.bfr.db/src/org/hsh/bfr/db/VersionComprator.java
Method compare
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
Open
public int compare(Object o1, Object o2) {
String version1 = (String) o1;
String version2 = (String) o2;
VersionTokenizer tokenizer1 = new VersionTokenizer(version1);
- Read upRead up
- Create a ticketCreate a ticket
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
Open
public int compare(Object o1, Object o2) {
String version1 = (String) o1;
String version2 = (String) o2;
VersionTokenizer tokenizer1 = new VersionTokenizer(version1);
- Create a ticketCreate a ticket
Method MoveNext
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
public boolean MoveNext() {
_number = 0;
_suffix = "";
// No more characters
if (_position >= _length)
- Read upRead up
- Create a ticketCreate a ticket
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
Open
if (empty2) return -1; // Second suffix is empty (1.2a < 1.2)
- Create a ticketCreate a ticket
Avoid too many return
statements within this method. Open
Open
if (empty1) return 1; // First suffix is empty (1.2 > 1.2b)
- Create a ticketCreate a ticket
Avoid too many return
statements within this method. Open
Open
if (result != 0) return result;
- Create a ticketCreate a ticket
Refactor this method to reduce its Cognitive Complexity from 31 to the 15 allowed. Open
Open
public int compare(Object o1, Object o2) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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.