File Include.java
has 408 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* Include.java
Purpose:
Description:
Include
has 37 methods (exceeds 20 allowed). Consider refactoring. Open
public class Include extends XulElement implements Includer, DynamicPropertied, AfterCompose, IdSpace {
private static final Logger log = LoggerFactory.getLogger(Include.class);
private static final String ATTR_RENDERED = "org.zkoss.zul.Include.rendered";
private String _src;
private Map<String, Object> _dynams;
Method renderProperties
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws java.io.IOException {
super.renderProperties(renderer);
setChildPage(null);
render(renderer, "comment", _comment);
- 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 afterCompose
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public void afterCompose() {
_afterComposed = true;
fixModeOnly();
if (_instantMode) {
final Execution exec = getExecution();
- 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 renderProperties
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws java.io.IOException {
super.renderProperties(renderer);
setChildPage(null);
render(renderer, "comment", _comment);
Method fixModeOnly
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private void fixModeOnly() { //called by afterCompose
if ("auto".equals(_mode)) {
if (_src != null && !_progressing && !_localized) {
// according to the spec if query string exists, it should be defer
// mode automatically.
- 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 include
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private void include(Writer out) throws IOException {
final Desktop desktop = getDesktop();
final Execution exec = getExecution();
final String src = exec.toAbsoluteURI(_src, false);
final Map<String, Object> old = setupDynams(exec);
- 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 include
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void include(Writer out) throws IOException {
final Desktop desktop = getDesktop();
final Execution exec = getExecution();
final String src = exec.toAbsoluteURI(_src, false);
final Map<String, Object> old = setupDynams(exec);
Method applyChangesToContent
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private void applyChangesToContent() {
if (_src == null) {
if (!getChildren().isEmpty())
getChildren().clear();
else if (!_instantMode && getChildPage() != 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 afterCompose
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void afterCompose() {
_afterComposed = true;
fixModeOnly();
if (_instantMode) {
final Execution exec = getExecution();
Method setMode
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public void setMode(String mode) throws WrongValueException {
if (!_mode.equals(mode)) {
if (!"auto".equals(mode) && !"instant".equals(mode) && !"defer".equals(mode))
throw new WrongValueException("Unknown mode: " + mode);
if ((_localized || _progressing) && "instant".equals(mode))
- 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 setLocalized
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public void setLocalized(boolean localized) {
if (_localized != localized) {
if (localized && "instant".equals(_mode))
throw new UnsupportedOperationException("localized not supported in instant mode yet");
- 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 restoreDynams
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static void restoreDynams(Execution exec, Map<String, Object> old) {
if (old != null)
for (Map.Entry<String, Object> me : old.entrySet()) {
final String nm = me.getKey();
final Object val = me.getValue();
- 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 setProgressing
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public void setProgressing(boolean progressing) {
if (_progressing != progressing) {
if (progressing && "instant".equals(_mode))
throw new UnsupportedOperationException("progressing not allowed in instant mode");
- 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
public void setEnclosingTag(String tag) {
if (tag == null || tag.length() == 0)
throw new IllegalArgumentException();
if (!_tag.equals(tag)) {
_tag = tag;
- 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 54.
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 4 locations. Consider refactoring. Open
if (!"auto".equals(mode) && !"instant".equals(mode) && !"defer".equals(mode))
throw new WrongValueException("Unknown mode: " + mode);
- 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 40.
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