File HtmlPageRenders.java
has 845 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* HtmlPageRenders.java
Purpose:
Description:
Method outLangJavaScripts
has a Cognitive Complexity of 71 (exceeds 5 allowed). Consider refactoring. Open
public static final String outLangJavaScripts(Execution exec, WebApp wapp, String deviceType) {
if (exec.isAsyncUpdate(null) || exec.getAttribute(ATTR_LANG_JS_GENED) != null)
return ""; //nothing to generate
exec.setAttribute(ATTR_LANG_JS_GENED, Boolean.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 outPageContent
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
public static final void outPageContent(Execution exec, Page page, Writer out, boolean au) throws IOException {
final Desktop desktop = page.getDesktop();
final PageCtrl pageCtrl = (PageCtrl) page;
final Component owner = pageCtrl.getOwner();
boolean contained = owner == null && exec.isIncluded();
- 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 outPageContent
has 129 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static final void outPageContent(Execution exec, Page page, Writer out, boolean au) throws IOException {
final Desktop desktop = page.getDesktop();
final PageCtrl pageCtrl = (PageCtrl) page;
final Component owner = pageCtrl.getOwner();
boolean contained = owner == null && exec.isIncluded();
HtmlPageRenders
has 35 methods (exceeds 20 allowed). Consider refactoring. Open
public class HtmlPageRenders {
// private static final Logger log = LoggerFactory.getLogger(HtmlPageRenders.class);
/** Denotes whether style sheets are generated for this request. */
private static final String ATTR_LANG_CSS_GENED = "javax.zkoss.zk.lang.css.generated";
Method getStyleSheets
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
public static final List<StyleSheet> getStyleSheets(Execution exec, WebApp wapp, String deviceType) {
if (wapp == null)
wapp = exec.getDesktop().getWebApp();
if (deviceType == null)
deviceType = exec.getDesktop().getDeviceType();
- 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 outLangJavaScripts
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static final String outLangJavaScripts(Execution exec, WebApp wapp, String deviceType) {
if (exec.isAsyncUpdate(null) || exec.getAttribute(ATTR_LANG_JS_GENED) != null)
return ""; //nothing to generate
exec.setAttribute(ATTR_LANG_JS_GENED, Boolean.TRUE);
Method append
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
private static void append(StringBuffer sb, StyleSheet ss, Execution exec, Page page) {
String href = ss.getHref();
String media = ss.getMedia();
if (href != null) {
try {
- 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 outEndJavaScriptFunc
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
private static void outEndJavaScriptFunc(Execution exec, Writer out, String extra, boolean aupg, boolean afterLoad)
throws IOException {
final String ac = outResponseJavaScripts(exec, true);
if (aupg) {
if (extra.length() > 0 || ac.length() > 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 outHeaderZkTags
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public static String outHeaderZkTags(Execution exec, Page page) {
String s1 = outHeaders(exec, page, true), s2 = outZkTags(exec, null, null), s3 = outHeaders(exec, page, false);
return s1 != null ? s2 != null ? s3 != null ? s1 + s2 + s3 : s1 + s2 : s3 != null ? s1 + s3 : s1
: //s2 null
s2 != null ? s3 != null ? s2 + s3 : s2 : s3 != null ? s3 : null; //s2 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 outZkTags
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static String outZkTags(Execution exec, WebApp wapp, String deviceType) {
if (exec.getAttribute(ATTR_ZK_TAGS_GENERATED) != null)
return null;
exec.setAttribute(ATTR_ZK_TAGS_GENERATED, Boolean.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 outLangStyleSheets
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static final String outLangStyleSheets(Execution exec, WebApp wapp, String deviceType) {
if (exec.isAsyncUpdate(null) || exec.getAttribute(ATTR_LANG_CSS_GENED) != null)
return ""; //nothing to generate
exec.setAttribute(ATTR_LANG_CSS_GENED, Boolean.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 getStyleSheets
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static final List<StyleSheet> getStyleSheets(Execution exec, WebApp wapp, String deviceType) {
if (wapp == null)
wapp = exec.getDesktop().getWebApp();
if (deviceType == null)
deviceType = exec.getDesktop().getDeviceType();
Method outSpecialJS
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static final String outSpecialJS(Desktop desktop) {
final StringBuffer sb = new StringBuffer();
//output application name
String oldnm = (String) desktop.getAttribute(ATTR_APPNM);
- 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 append
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private static void append(StringBuffer sb, JavaScript js) {
sb.append("\n<script type=\"text/javascript\"");
if (js.getSrc() != null) {
String url;
try {
- 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 outStandalone
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static final void outStandalone(Execution exec, Component comp, Writer out) throws IOException {
if (ComponentRedraws.beforeRedraw(false) >= 0)
throw new InternalError("Not possible: " + comp);
final String extra;
Method outEndJavaScriptFunc
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static void outEndJavaScriptFunc(Execution exec, Writer out, String extra, boolean aupg, boolean afterLoad)
throws IOException {
final String ac = outResponseJavaScripts(exec, true);
if (aupg) {
if (extra.length() > 0 || ac.length() > 0) {
Method outZkTags
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static String outZkTags(Execution exec, WebApp wapp, String deviceType) {
if (exec.getAttribute(ATTR_ZK_TAGS_GENERATED) != null)
return null;
exec.setAttribute(ATTR_ZK_TAGS_GENERATED, Boolean.TRUE);
Method outDivTemplateEnd
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private static void outDivTemplateEnd(Page page, Writer out) throws IOException {
final Desktop dt;
if (page != null && (dt = page.getDesktop()) != null) {
if (dt.getAttribute(ATTR_DESKTOP_CLIENTINFO) != null) {
dt.removeAttribute(ATTR_DESKTOP_CLIENTINFO);
- 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 outSpecialJS
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static final String outSpecialJS(Desktop desktop) {
final StringBuffer sb = new StringBuffer();
//output application name
String oldnm = (String) desktop.getAttribute(ATTR_APPNM);
Method outLangStyleSheets
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static final String outLangStyleSheets(Execution exec, WebApp wapp, String deviceType) {
if (exec.isAsyncUpdate(null) || exec.getAttribute(ATTR_LANG_CSS_GENED) != null)
return ""; //nothing to generate
exec.setAttribute(ATTR_LANG_CSS_GENED, Boolean.TRUE);
Method outStandalone
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static final void outStandalone(Execution exec, Component comp, Writer out) throws IOException {
if (ComponentRedraws.beforeRedraw(false) >= 0)
throw new InternalError("Not possible: " + comp);
final String extra;
- 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 isGroupingAllowed
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private static final boolean isGroupingAllowed(Desktop desktop) {
final String name = "org.zkoss.zk.ui.input.grouping.allowed";
if (desktop != null) {
final Collection<Page> pages = desktop.getPages();
if (!pages.isEmpty()) {
- 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 outResponseJavaScripts
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static final String outResponseJavaScripts(Execution exec, boolean directJS) {
final ExecutionCtrl execCtrl = (ExecutionCtrl) exec;
final Collection<AuResponse> responses = execCtrl.getResponses();
if (responses == null || responses.isEmpty())
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 setContentType
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static final void setContentType(Execution exec, Page page) {
String contentType = ((PageCtrl) page).getContentType();
if (contentType == null) {
contentType = page.getDesktop().getDevice().getContentType();
if (contentType == 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 outInitCrashScript
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static final String outInitCrashScript(Execution exec, WebApp wapp) {
if (exec.isAsyncUpdate(null))
return ""; //nothing to generate
if (wapp == 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 outEndJavaScriptFunc
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private static void outEndJavaScriptFunc(Execution exec, Writer out, String extra, boolean aupg, boolean afterLoad)
Method getAutomaticTimeout
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static Boolean getAutomaticTimeout(Desktop desktop) {
if (desktop != null)
for (Page page : desktop.getPages()) {
Boolean b = ((PageCtrl) page).getAutomaticTimeout();
if (b != 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
private static String getContextURI(Execution exec) {
if (exec != null) {
String s = exec.getContextURI();
int j = s.lastIndexOf('/'); //might have jsessionid=...
return j >= 0 ? s.substring(0, j) + s.substring(j + 1) : s;
- 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 69.
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 (extra.length() > 0) {
out.write(",'");
out.write(Strings.escape(extra, Strings.ESCAPE_JAVASCRIPT));
out.write('\'');
}
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
public static final RenderContext getRenderContext(Execution exec) {
if (exec == null)
exec = Executions.getCurrent();
return exec != null ? (RenderContext) exec.getAttribute(ATTR_RENDER_CONTEXT) : null;
}
- 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 42.
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