Method buildRootCtx
has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring. Open
private ComponentMatchCtx buildRootCtx() {
Component rt = _root == null ? _page.getFirstRoot() : _root;
if (_posOffset > 0) {
Selector selector = _selectorList.get(0);
for (int i = 0; i < _posOffset; i++) {
- 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 ComponentIterator.java
has 507 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
*
*/
package org.zkoss.zk.ui.select.impl;
ComponentIterator
has 33 methods (exceeds 20 allowed). Consider refactoring. Open
public class ComponentIterator implements Iterator<Component> {
private final Page _page;
private final Component _root;
private final List<Selector> _selectorList;
Method buildNextShadowCtx
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
private ComponentMatchCtx buildNextShadowCtx() {
Component comp = _currCtx.getComponent();
boolean isShadow = comp instanceof ShadowElement;
Component child = getNextUntrackedChild(comp);
if (!isShadow) {
- 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 buildNextShadowRootSiblingCtx
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
private ComponentMatchCtx buildNextShadowRootSiblingCtx(ComponentMatchCtx ctx, HtmlShadowElement htmlShadowElement) {
ctx.moveToNextShadowSibling(htmlShadowElement);
//TODO need to match selectors
for (Selector selector : _selectorList) {
int i = selector.getSelectorIndex();
- 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 buildCompCtx0
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
private ComponentMatchCtx buildCompCtx0(ComponentMatchCtx ctx) {
for (Selector selector : _selectorList) {
int i = selector.getSelectorIndex();
int posEnd = _posOffset > 0 ? _posOffset - 1 : 0;
int len = selector.size();
- 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 getCommonSeqLength
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
private static int getCommonSeqLength(List<Selector> list) {
List<String> strs = null;
int max = 0;
for (Selector selector : list) {
if (strs == null) {
- 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 buildFirstChildCtx
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
private ComponentMatchCtx buildFirstChildCtx(ComponentMatchCtx parent) {
ComponentMatchCtx ctx = new ComponentMatchCtx(parent.getComponent().getFirstChild(), parent);
parent._lastChild = ctx;
if (_posOffset == 0)
matchLevel0(ctx);
- 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 buildRootCtx
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
private ComponentMatchCtx buildRootCtx() {
Component rt = _root == null ? _page.getFirstRoot() : _root;
if (_posOffset > 0) {
Selector selector = _selectorList.get(0);
for (int i = 0; i < _posOffset; i++) {
Method buildFirstShadowRootCtx
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private ComponentMatchCtx buildFirstShadowRootCtx(ComponentMatchCtx parent, HtmlShadowElement htmlShadowElement) {
ComponentMatchCtx ctx = new ComponentMatchCtx(htmlShadowElement, parent);
parent._lastShadowRoot = ctx;
if (_posOffset == 0)
matchLevel0(ctx);
- 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 buildNextShadowCtx
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
private ComponentMatchCtx buildNextShadowCtx() {
Component comp = _currCtx.getComponent();
boolean isShadow = comp instanceof ShadowElement;
Component child = getNextUntrackedChild(comp);
if (!isShadow) {
Method buildNextShadowRootSiblingCtx
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private ComponentMatchCtx buildNextShadowRootSiblingCtx(ComponentMatchCtx ctx, HtmlShadowElement htmlShadowElement) {
ctx.moveToNextShadowSibling(htmlShadowElement);
//TODO need to match selectors
for (Selector selector : _selectorList) {
int i = selector.getSelectorIndex();
Method buildCompCtx0
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private ComponentMatchCtx buildCompCtx0(ComponentMatchCtx ctx) {
for (Selector selector : _selectorList) {
int i = selector.getSelectorIndex();
int posEnd = _posOffset > 0 ? _posOffset - 1 : 0;
int len = selector.size();
Method buildChildCtxWithShadowOrComponent
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private ComponentMatchCtx buildChildCtxWithShadowOrComponent(Component comp, HtmlShadowElement htmlShadowElement, boolean isFirstShadow) {
if (comp != null && htmlShadowElement != null) {
try {
switch (HtmlShadowElement.inRange(htmlShadowElement, comp)) {
case PREVIOUS:
- 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 seekNext
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private Component seekNext() {
if (_index < 0) {
_currCtx = buildRootCtx();
} else {
if (_lookingForShadow) {
- 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 buildChildCtx
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private ComponentMatchCtx buildChildCtx(Component comp) {
_trackedUuid.add(comp.getUuid());
ComponentMatchCtx parent = _currCtx;
boolean insideShadow = false;
if (parent.getComponent() instanceof ShadowElement) {
- 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 (!isDescendant(rt2, rt))
return null;
Avoid deeply nested control flow statements. Open
if (rt2.getPreviousSibling() != rt)
return null;
Avoid deeply nested control flow statements. Open
if (!isGeneralSibling(rt2, rt))
return null;
Avoid deeply nested control flow statements. Open
if (rt2 instanceof ShadowElement) {
if (((ShadowElement) rt2).getShadowHost() != rt)
return null;
} else if (rt2.getParent() != rt) {
return null;
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return buildNextShadowCtx();
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return ctx;
Method lookingForShadow
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static boolean lookingForShadow(List<Selector> list) {
for (Selector s : list) {
for (SimpleSelectorSequence seq : s) {
if (!seq.getPseudoElements().isEmpty()) {
return 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
Method buildNextCtx
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private ComponentMatchCtx buildNextCtx() {
if (_allIds)
return null;
// TODO: how to skip tree branches
- 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 isDescendant
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static boolean isDescendant(Component c1, Component c2) {
if (c1 == c2)
return true; // first c1 can be IdSpace
while ((c1 = c1.getParent()) != null) {
if (c1 == c2)
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
for (int j = len - 2; j >= posEnd; j--) {
Combinator cb = selector.getCombinator(j);
ComponentMatchCtx parent = ctx.getParent();
// ZK-2944: descendant and child combinator should have nothing to do with the previous matching status, clear it
- 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 318.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
for (int j = len - 2; j >= posEnd; j--) {
Combinator cb = selector.getCombinator(j);
ComponentMatchCtx parent = ctx.getParent();
// ZK-2944: descendant and child combinator should have nothing to do with the previous matching status, clear it
- 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 318.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
case CHILD:
if (parent.isQualified(i, j) && match(selector, ctx, j + 1))
ctx.setQualified(i, j + 1);
break;
- 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 44.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
case CHILD:
if (parent.isQualified(i, j) && match(selector, ctx, j + 1))
ctx.setQualified(i, j + 1);
break;
- 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 44.
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