Method addByRawValueInV6
has a Cognitive Complexity of 91 (exceeds 5 allowed). Consider refactoring. Open
private void addByRawValueInV6(String annotName, String rval,
Location loc) {
final Map<String, String[]> attrs = new LinkedHashMap<String, String[]>(
4);
final int len = rval.length();
- 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 isAnnotation
has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring. Open
public static boolean isAnnotation(String val) {
int len = val.length();
if (len >= 4) {
len = (val = val.trim()).length();
if (len >= 4 && val.charAt(0) == '@') {
- 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 parseValueArray
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
private static String[] parseValueArray(String rval, Location loc) {
final List<String> attrs = new ArrayList<String>();
final int len = rval.length();
char quot = (char) 0;
final StringBuffer sb = new StringBuffer(len);
- 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 AnnotationHelper.java
has 336 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* AnnotationHelper.java
Purpose:
Description:
Method addByCompoundValue
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public void addByCompoundValue(String cval, Location loc) {
final int len = cval.length();
if (cval.charAt(1) == '{' && cval.charAt(len - 1) == '}') { //Format 1
addInV5(cval.substring(2, len - 1));
return;
- 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 addByRawValueInV6
has 86 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void addByRawValueInV6(String annotName, String rval,
Location loc) {
final Map<String, String[]> attrs = new LinkedHashMap<String, String[]>(
4);
final int len = rval.length();
Method addInV5
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private void addInV5(String cval) {
final char[] seps1 = {'(', ' '}, seps2 = {')'};
for (int j = 0, len = cval.length(); j < len;) {
j = Strings.skipWhitespaces(cval, j);
int k = Strings.nextSeparator(cval, j, seps1, true, true, false);
- 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 parseValueArray
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static String[] parseValueArray(String rval, Location loc) {
final List<String> attrs = new ArrayList<String>();
final int len = rval.length();
char quot = (char) 0;
final StringBuffer sb = new StringBuffer(len);
Method isAnnotation
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static boolean isAnnotation(String val) {
int len = val.length();
if (len >= 4) {
len = (val = val.trim()).length();
if (len >= 4 && val.charAt(0) == '@') {
Method addByCompoundValue
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void addByCompoundValue(String cval, Location loc) {
final int len = cval.length();
if (cval.charAt(1) == '{' && cval.charAt(len - 1) == '}') { //Format 1
addInV5(cval.substring(2, len - 1));
return;
Method addInV5
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void addInV5(String cval) {
final char[] seps1 = {'(', ' '}, seps2 = {')'};
for (int j = 0, len = cval.length(); j < len;) {
j = Strings.skipWhitespaces(cval, j);
int k = Strings.nextSeparator(cval, j, seps1, true, true, false);
Avoid deeply nested control flow statements. Open
if (j < len && val.charAt(j) == '(')
return true;
Consider simplifying this complex logical expression. Open
if ((cc < 'a' || cc > 'z') && (cc < 'A'
|| cc > 'Z') && (cc < '0' || cc > '9'))
return false;
Consider simplifying this complex logical expression. Open
if ((cc >= 'a' && cc <= 'z') || (cc >= 'A' && cc <= 'Z')
|| cc == '_' || cc == '$') {
for (; j < len; ++j) {
switch (cc = val.charAt(j)) {
case '(':
Avoid too many return
statements within this method. Open
return false;
Similar blocks of code found in 2 locations. Consider refactoring. Open
public void applyAnnotations(ComponentInfo compInfo, String propName,
boolean clear) {
for (AnnotInfo info : _annots) {
compInfo.addAnnotation(propName, info.name, info.attrs, info.loc);
}
- 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 46.
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
public void applyAnnotations(ShadowInfo compInfo, String propName,
boolean clear) {
for (AnnotInfo info : _annots) {
compInfo.addAnnotation(propName, info.name, info.attrs, info.loc);
}
- 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 46.
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