Method parseCst
has a Cognitive Complexity of 76 (exceeds 5 allowed). Consider refactoring. Open
private void parseCst(String constraint) {
String regex = null, errmsg = null, regexFlags = "";
l_out:
for (int j = 0, k = 0, len = constraint.length(); k >= 0; j = k + 1) {
for (; ; ++j) {
- 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 validate
has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring. Open
public void validate(Component comp, Object value) throws WrongValueException {
if (!_finishParseCst) {
if (_raw != null) parseCst(_raw);
_finishParseCst = true;
}
- 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
File SimpleConstraint.java
has 333 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* SimpleConstraint.java
Purpose:
Description:
Method parseConstraint
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
protected int parseConstraint(String constraint) throws UiException {
if (constraint.equals("no positive"))
return NO_POSITIVE;
else if (constraint.equals("no negative"))
return NO_NEGATIVE;
- 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 parseCst
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void parseCst(String constraint) {
String regex = null, errmsg = null, regexFlags = "";
l_out:
for (int j = 0, k = 0, len = constraint.length(); k >= 0; j = k + 1) {
for (; ; ++j) {
Method validate
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void validate(Component comp, Object value) throws WrongValueException {
if (!_finishParseCst) {
if (_raw != null) parseCst(_raw);
_finishParseCst = true;
}
Method parseConstraint
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected int parseConstraint(String constraint) throws UiException {
if (constraint.equals("no positive"))
return NO_POSITIVE;
else if (constraint.equals("no negative"))
return NO_NEGATIVE;
Method getClientConstraint
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public String getClientConstraint() {
if (_raw != null)
return '\'' + Strings.escape(_raw, Strings.ESCAPE_JAVASCRIPT) + '\'';
final StringBuffer sb = new StringBuffer("new zul.inp.SimpleConstraint(");
- 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 getRegex
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private Pattern getRegex(String regex, String regexFlags) {
if (regex == null || regex.length() == 0)
return null;
if (regexFlags.length() == 0) {
return Pattern.compile(regex);
- 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 deeply nested control flow statements. Open
if (k >= len) { //no ending /
k = -1;
break;
}
Avoid deeply nested control flow statements. Open
if (matcher.find()) {
regexFlags = matcher.group(0).trim();
}
Avoid deeply nested control flow statements. Open
if (cc == '/') {
hasEndingSlash = true;
break; //ending / found
}
Avoid deeply nested control flow statements. Open
if (cc == '\\')
++k; //skip one
Avoid too many return
statements within this method. Open
return START_AFTER;
Avoid too many return
statements within this method. Open
return END_BEFORE;
Avoid too many return
statements within this method. Open
return NO_FUTURE;
Avoid too many return
statements within this method. Open
return AFTER_START;
Avoid too many return
statements within this method. Open
return NO_ZERO;
Avoid too many return
statements within this method. Open
return BEFORE_START;
Avoid too many return
statements within this method. Open
return SERVER;
Avoid too many return
statements within this method. Open
return STRICT;
Avoid too many return
statements within this method. Open
return START_BEFORE;
Avoid too many return
statements within this method. Open
return NO_NEGATIVE;
Avoid too many return
statements within this method. Open
return NO_POSITIVE;
Avoid too many return
statements within this method. Open
return 0;
Avoid too many return
statements within this method. Open
return NO_TODAY;
Avoid too many return
statements within this method. Open
return OVERLAP_END;
Avoid too many return
statements within this method. Open
return AFTER_END;
Avoid too many return
statements within this method. Open
return NO_PAST;
Avoid too many return
statements within this method. Open
return OVERLAP;
Avoid too many return
statements within this method. Open
return END_AFTER;
Avoid too many return
statements within this method. Open
return BEFORE_END;
Avoid too many return
statements within this method. Open
return NO_EMPTY;
Similar blocks of code found in 2 locations. Consider refactoring. Open
private int getMessageForNumberDenied() {
switch (_flags & (NO_POSITIVE | NO_NEGATIVE | NO_ZERO)) {
case (NO_POSITIVE | NO_ZERO):
return MZul.NO_POSITIVE_ZERO;
case (NO_POSITIVE):
- Read upRead up
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 129.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
private int getMessageForDateDenied() {
switch (_flags & (NO_FUTURE | NO_PAST | NO_TODAY)) {
case (NO_FUTURE | NO_TODAY):
return MZul.NO_FUTURE_TODAY;
case (NO_FUTURE):
- Read upRead up
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 129.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (cmp > 0) {
if ((_flags & NO_FUTURE) != 0)
throw wrongValue(comp, getMessageForDateDenied());
} else if (cmp == 0) {
if ((_flags & NO_TODAY) != 0)
- Read upRead up
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 88.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (cmp > 0) {
if ((_flags & NO_POSITIVE) != 0)
throw wrongValue(comp, getMessageForNumberDenied());
} else if (cmp == 0) {
if ((_flags & NO_ZERO) != 0)
- Read upRead up
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 88.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76