Method parseItem
has a Cognitive Complexity of 303 (exceeds 5 allowed). Consider refactoring. Open
private Object parseItem(PageDefinition pgdef, NodeInfo parent, Element el, AnnotationHelper annHelper,
boolean bNativeContent, ParsingState parsingState) throws Exception {
final String nm = el.getLocalName();
final Namespace ns = el.getNamespace();
final String pref = ns != null ? ns.getPrefix() : "";
- 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 Parser.java
has 1497 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* Parser.java
Purpose:
Description:
Method parseItems
has a Cognitive Complexity of 139 (exceeds 5 allowed). Consider refactoring. Open
private void parseItems(final PageDefinition pgdef, final NodeInfo parent, Collection items,
AnnotationHelper annHelper, boolean bNativeContent) throws Exception {
LanguageDefinition parentlang = getLanguageDefinition(parent);
if (parentlang == null)
parentlang = pgdef.getLanguageDefinition();
- 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 parseShadowElement
has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring. Open
private static NodeInfo parseShadowElement(PageDefinition pgdef, NodeInfo parent, Element el,
AnnotationHelper annHelper) throws Exception {
String ifc = null, unless = null, name = el.getLocalName();
AnnotationHelper attrAnnHelper = null;
final LanguageDefinition lookup = LanguageDefinition.lookup("xul/html");
- 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
Parser
has 62 methods (exceeds 20 allowed). Consider refactoring. Open
public class Parser {
private static final Logger log = LoggerFactory.getLogger(Parser.class);
private final WebApp _wapp;
private final Locator _locator;
Method parseItem
has 223 lines of code (exceeds 25 allowed). Consider refactoring. Open
private Object parseItem(PageDefinition pgdef, NodeInfo parent, Element el, AnnotationHelper annHelper,
boolean bNativeContent, ParsingState parsingState) throws Exception {
final String nm = el.getLocalName();
final Namespace ns = el.getNamespace();
final String pref = ns != null ? ns.getPrefix() : "";
Method optimizeNativeInfos
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
private static void optimizeNativeInfos(NativeInfo compInfo) {
//Optimize 1: merge to prolog, if the first children are
//native and have no child
for (Iterator it = compInfo.getChildren().iterator(); it.hasNext();) {
final NodeInfo o = (NodeInfo) it.next();
- 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 addAttribute
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
private void addAttribute(ComponentInfo compInfo, Namespace attrns, String name, String value, ConditionImpl cond,
org.zkoss.xml.Locator xl) throws Exception {
if (Events.isValid(name)) {
boolean bZkAttr = attrns == null;
if (!bZkAttr) {
- 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 modifyAttrValueIfSimplified
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
private static String modifyAttrValueIfSimplified(String attrName, String attrValue) {
boolean isCommand = attrValue.matches("@(global-)?command\\(.*\\)");
if (attrValue.matches("@\\(.*\\)") || isCommand) {
if (Events.isValid(attrName) || isCommand) {
int attrValueIndex = attrValue.indexOf("(") + 1;
- 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 parse
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
public PageDefinition parse(Document doc, String extension) throws Exception {
//1. parse the page and import directive if any
final List<ProcessingInstruction> pis = new LinkedList<ProcessingInstruction>();
final List<String[]> imports = new LinkedList<String[]>();
final List<String> impclses = new LinkedList<String>();
- 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 parseComponentDirective
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
private void parseComponentDirective(PageDefinition pgdef, ProcessingInstruction pi, Map<String, String> params)
throws Exception {
final String name = params.remove("name");
noELnorEmpty("name", name, pi);
- 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 parse
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
private void parse(PageDefinition pgdef, ProcessingInstruction pi) throws Exception {
final String target = pi.getTarget();
final Map<String, String> params = pi.parseData();
if ("page".equals(target)) {
parsePageDirective(pgdef, pi, params);
- 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 parseZk
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
private static ZkInfo parseZk(NodeInfo parent, Element el, AnnotationHelper annHelper) throws Exception {
if (annHelper.clear())
log.warn(message("Annotations are ignored since <zk> doesn't support them", el));
final ZkInfo zi = new ZkInfo(parent, 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 parseItems
has 111 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void parseItems(final PageDefinition pgdef, final NodeInfo parent, Collection items,
AnnotationHelper annHelper, boolean bNativeContent) throws Exception {
LanguageDefinition parentlang = getLanguageDefinition(parent);
if (parentlang == null)
parentlang = pgdef.getLanguageDefinition();
Method parseEvaluatorDirective
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
private static void parseEvaluatorDirective(PageDefinition pgdef, ProcessingInstruction pi,
Map<String, String> params) throws Exception {
final String clsnm = params.remove("class");
if (clsnm != null && clsnm.length() > 0) {
noELnorEmpty("class", clsnm, pi);
- 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 parseZScript
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
private void parseZScript(NodeInfo parent, Element el, AnnotationHelper annHelper) {
if (el.getAttributeItem("forEach") != null)
throw new UiException(message("forEach not applicable to <zscript>", el));
if (annHelper.clear())
log.warn(message("Annotations are ignored since <zscript> doesn't support them", el));
- 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 parseComponentDirective
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void parseComponentDirective(PageDefinition pgdef, ProcessingInstruction pi, Map<String, String> params)
throws Exception {
final String name = params.remove("name");
noELnorEmpty("name", name, pi);
Method parseShadowElement
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static NodeInfo parseShadowElement(PageDefinition pgdef, NodeInfo parent, Element el,
AnnotationHelper annHelper) throws Exception {
String ifc = null, unless = null, name = el.getLocalName();
AnnotationHelper attrAnnHelper = null;
final LanguageDefinition lookup = LanguageDefinition.lookup("xul/html");
Method parseTemplate
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
private static TemplateInfo parseTemplate(NodeInfo parent, Element el, AnnotationHelper annHelper)
throws Exception {
if (annHelper.clear())
log.warn(message("Annotations are ignored since <template> doesn't support them", el));
if (el.getAttributeItem("forEach") != 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 parseCustomAttributes
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
private static void parseCustomAttributes(LanguageDefinition langdef, NodeInfo parent, Element el,
AnnotationHelper annHelper) throws Exception {
//if (!el.getElements().isEmpty())
// throw new UiException(message("Child elements are not allowed for <custom-attributes>", el));
- 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 parse
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
public PageDefinition parse(Document doc, String extension) throws Exception {
//1. parse the page and import directive if any
final List<ProcessingInstruction> pis = new LinkedList<ProcessingInstruction>();
final List<String[]> imports = new LinkedList<String[]>();
final List<String> impclses = new LinkedList<String>();
Method parsePageDirective
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
private static void parsePageDirective(PageDefinition pgdef, ProcessingInstruction pi, Map<String, String> params)
throws Exception {
for (Map.Entry<String, String> me : pi.parseData().entrySet()) {
final String nm = me.getKey();
final String 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 textAsAllowed
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
private boolean textAsAllowed(LanguageDefinition langdef, Collection<Item> items, boolean bNativeContent) {
boolean textAsAllowed = true;
String xmlFound = null; //whether a XML fragment
String zkElem = null; //a ZK element
boolean empty = true; //whether there is anything other than whitespace
- 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 parse
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void parse(PageDefinition pgdef, ProcessingInstruction pi) throws Exception {
final String target = pi.getTarget();
final Map<String, String> params = pi.parseData();
if ("page".equals(target)) {
parsePageDirective(pgdef, pi, params);
Method modifyAttrValueIfSimplified
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static String modifyAttrValueIfSimplified(String attrName, String attrValue) {
boolean isCommand = attrValue.matches("@(global-)?command\\(.*\\)");
if (attrValue.matches("@\\(.*\\)") || isCommand) {
if (Events.isValid(attrName) || isCommand) {
int attrValueIndex = attrValue.indexOf("(") + 1;
Method optimizeNativeInfos
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static void optimizeNativeInfos(NativeInfo compInfo) {
//Optimize 1: merge to prolog, if the first children are
//native and have no child
for (Iterator it = compInfo.getChildren().iterator(); it.hasNext();) {
final NodeInfo o = (NodeInfo) it.next();
Method addAttribute
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void addAttribute(ComponentInfo compInfo, Namespace attrns, String name, String value, ConditionImpl cond,
org.zkoss.xml.Locator xl) throws Exception {
if (Events.isValid(name)) {
boolean bZkAttr = attrns == null;
if (!bZkAttr) {
Method parseVariables
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private static void parseVariables(LanguageDefinition langdef, NodeInfo parent, Element el,
AnnotationHelper annHelper) throws Exception {
//if (!el.getElements().isEmpty())
// throw new UiException(message("Child elements are not allowed for <variables> element", el));
- 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 parseZScript
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void parseZScript(NodeInfo parent, Element el, AnnotationHelper annHelper) {
if (el.getAttributeItem("forEach") != null)
throw new UiException(message("forEach not applicable to <zscript>", el));
if (annHelper.clear())
log.warn(message("Annotations are ignored since <zscript> doesn't support them", el));
Method parsePageDirective
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static void parsePageDirective(PageDefinition pgdef, ProcessingInstruction pi, Map<String, String> params)
throws Exception {
for (Map.Entry<String, String> me : pi.parseData().entrySet()) {
final String nm = me.getKey();
final String val = me.getValue();
Method toAbsoluteURI
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private String toAbsoluteURI(String uri) {
if (uri != null && uri.length() > 0) {
final char cc = uri.charAt(0);
if (cc != '/' && cc != '~' && !Servlets.isUniversalURL(uri)) {
final String dir = getLocator().getDirectory();
- 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 parseInitDirective
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private void parseInitDirective(PageDefinition pgdef, ProcessingInstruction pi, Map<String, String> params)
throws Exception {
final String clsnm = params.remove("class");
final String zsrc = params.remove("zscript");
- 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 parseZk
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static ZkInfo parseZk(NodeInfo parent, Element el, AnnotationHelper annHelper) throws Exception {
if (annHelper.clear())
log.warn(message("Annotations are ignored since <zk> doesn't support them", el));
final ZkInfo zi = new ZkInfo(parent, null);
Method parseCustomAttributes
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static void parseCustomAttributes(LanguageDefinition langdef, NodeInfo parent, Element el,
AnnotationHelper annHelper) throws Exception {
//if (!el.getElements().isEmpty())
// throw new UiException(message("Child elements are not allowed for <custom-attributes>", el));
Method getLanguageDefinition
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private static final LanguageDefinition getLanguageDefinition(NodeInfo node) {
for (; node != null; node = node.getParent()) {
if (node instanceof ComponentInfo) {
LanguageDefinition langdef = ((ComponentInfo) node).getLanguageDefinition();
if (langdef != 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 parseTemplate
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static TemplateInfo parseTemplate(NodeInfo parent, Element el, AnnotationHelper annHelper)
throws Exception {
if (annHelper.clear())
log.warn(message("Annotations are ignored since <template> doesn't support them", el));
if (el.getAttributeItem("forEach") != null)
Method textAsAllowed
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private boolean textAsAllowed(LanguageDefinition langdef, Collection<Item> items, boolean bNativeContent) {
boolean textAsAllowed = true;
String xmlFound = null; //whether a XML fragment
String zkElem = null; //a ZK element
boolean empty = true; //whether there is anything other than whitespace
Method parseAttribute
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void parseAttribute(PageDefinition pgdef, ComponentInfo parent, Element el, AnnotationHelper annHelper)
throws Exception {
if (el.getAttributeItem("forEach") != null)
throw new UiException(message("forEach not applicable to attribute", el));
Method parseAttribute
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private void parseAttribute(PageDefinition pgdef, ComponentInfo parent, Element el, AnnotationHelper annHelper)
throws Exception {
if (el.getAttributeItem("forEach") != null)
throw new UiException(message("forEach not applicable to attribute", el));
- 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 applyAttrAnnot
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private static void applyAttrAnnot(AnnotationHelper attrAnnHelper, ShadowInfo compInfo, String nm, String val,
boolean selfAllowed, org.zkoss.util.resource.Location loc) {
Method addAttribute
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private void addAttribute(ComponentInfo compInfo, Namespace attrns, String name, String value, ConditionImpl cond,
org.zkoss.xml.Locator xl) throws Exception {
Method applyAttrAnnot
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private static void applyAttrAnnot(AnnotationHelper attrAnnHelper, ComponentInfo compInfo, String nm, String val,
boolean selfAllowed, org.zkoss.util.resource.Location loc) {
Avoid deeply nested control flow statements. Open
if (nsParser.isMatched(attURI)) {
if (nsParser.parse(attr, compInfo, pgdef)) {
handled = true;
break;
}
Avoid deeply nested control flow statements. Open
for (Annotation anno : annotationMap.getAnnotations(propName)) {
compInfo.addAnnotation(propName, anno.getName(), anno.getAttributes(), anno.getLocation());
}
Method parseItem
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private Object parseItem(PageDefinition pgdef, NodeInfo parent, Element el, AnnotationHelper annHelper,
boolean bNativeContent, ParsingState parsingState) throws Exception {
Method isShadowElement
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private static final boolean isShadowElement(LanguageDefinition langdef, PageDefinition pgdef, String nm,
String pref, String uri, boolean bNativeContent) {
Method parseAsProperty
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private void parseAsProperty(PageDefinition pgdef, ComponentInfo compInfo, String name, Collection items,
AnnotationHelper annHelper, ConditionImpl cond) throws Exception {
Avoid deeply nested control flow statements. Open
if (cc == ',') {
sb.append(cc);
modifiedCommandPropertySb.append(modifyAttrValueIfSimplified0(nm, sb.toString().trim(), paramIndex, isNamedParam));
if (paramIndex != 0 && !isNamedParam && nm != null) { // named param and un-named parameters together
throwCommandSimplifiedErrorUsage();
Consider simplifying this complex logical expression. Open
if (!bNativeContent && !bNative && (shouldIgnoreAnnotNamespace
|| (attURI.length() == 0 || LanguageDefinition.ZK_NAMESPACE.endsWith(attURI)))
&& AnnotationHelper.isAnnotation(attvaltrim)) {
if (attrAnnHelper == null)
attrAnnHelper = new AnnotationHelper();
Consider simplifying this complex logical expression. Open
if (!isZkAttr(langdef, attrns) && !isZKNamespace(attURI) && !"xmlns".equals(attPref)
&& !("xmlns".equals(attnm) && "".equals(attPref))
&& !"http://www.w3.org/2001/XMLSchema-instance".equals(attURI)) {
// Bug ZK-2995
Consider simplifying this complex logical expression. Open
if (isZkElement(langdef, e, bNativeContent) && ("attribute".equals(n) || "custom-attributes".equals(n)
|| "variables".equals(n) || "template".equals(n) || "zscript".equals(n))) { //we have to skip zscript because of B50-3259479
zkElem = n;
textAsAllowed = false;
//unable to handle them because EL/zscript might affect
Consider simplifying this complex logical expression. Open
if (!"xmlns".equals(attnm) && !"xml".equals(attnm) && !attURI.contains("w3.org")
&& (attPref == null || (!"xmlns".equals(attPref) && !"xml".equals(attPref))))
warnWrongZkAttr(attr);
Consider simplifying this complex logical expression. Open
if (!"xmlns".equals(attnm) && !"xml".equals(attnm) && !attURI.contains("w3.org")
&& (attPref == null || (!"xmlns".equals(attPref) && !"xml".equals(attPref))))
params.put(attnm, attval);
Method parseItems
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private void parseItems(final PageDefinition pgdef, final NodeInfo parent, Collection items,
AnnotationHelper annHelper, boolean bNativeContent) throws Exception {
Method isZkElement
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private static final boolean isZkElement(LanguageDefinition langdef, String nm, String pref, String uri,
boolean bNativeContent) {
Method isShadowElement
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static final boolean isShadowElement(LanguageDefinition langdef, PageDefinition pgdef, String nm,
String pref, String uri, boolean bNativeContent) {
// feature in 8.0.0, no need to check namespace, if any.
if ("true".equalsIgnoreCase(Library.getProperty("org.zkoss.zk.namespace.tolerant", "false")))
return langdef.hasShadowDefinition(nm) || (!"xul/html".equals(langdef.getName())
- 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 too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return; //done
Method modifyAttrValueIfSimplified0
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static String modifyAttrValueIfSimplified0(String nm, String val, int paramIndex, boolean isNamedParam) {
if (nm == null) {
if (isNamedParam)
throwCommandSimplifiedErrorUsage();
if (paramIndex != -1) //skip command method name
- 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 addDeclaredNamespace
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static void addDeclaredNamespace(NativeInfo nativeInfo, Collection<Namespace> namespaces,
LanguageDefinition langdef) {
for (Namespace ns : namespaces) {
final String uri = ns.getURI();
boolean bNatPrefix = uri.startsWith(LanguageDefinition.NATIVE_NAMESPACE_PREFIX);
- 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
if (!"xmlns".equals(attnm) && !"xml".equals(attnm) && !attURI.contains("w3.org")
&& (attPref == null || (!"xmlns".equals(attPref) && !"xml".equals(attPref))))
- 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 60.
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
if (!"xmlns".equals(attnm) && !"xml".equals(attnm) && !attURI.contains("w3.org")
&& (attPref == null || (!"xmlns".equals(attPref) && !"xml".equals(attPref))))
- 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 60.
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 PageDefinition parse(File file, String path) throws Exception {
//if (log.isDebugEnabled()) log.debug("Parsing "+file);
String extension = Servlets.getExtension(file.getName());
final PageDefinition pgdef = parse(TreeBuilderFactory.makeBuilder(extension).parse(file), extension);
pgdef.setRequestPath(path);
- 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 51.
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 PageDefinition parse(URL url, String path) throws Exception {
//if (log.isDebugEnabled()) log.debug("Parsing "+url);
String extension = Servlets.getExtension(url.toExternalForm());
final PageDefinition pgdef = parse(TreeBuilderFactory.makeBuilder(extension).parse(url), extension);
pgdef.setRequestPath(path);
- 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 51.
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 static void applyAttrAnnot(AnnotationHelper attrAnnHelper, ShadowInfo compInfo, String nm, String val,
boolean selfAllowed, org.zkoss.util.resource.Location loc) {
attrAnnHelper.addByCompoundValue(val.trim(), loc);
attrAnnHelper.applyAnnotations(compInfo, selfAllowed && "self".equals(nm) ? null : nm, true);
}
- 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 47.
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 static void applyAttrAnnot(AnnotationHelper attrAnnHelper, ComponentInfo compInfo, String nm, String val,
boolean selfAllowed, org.zkoss.util.resource.Location loc) {
attrAnnHelper.addByCompoundValue(val.trim(), loc);
attrAnnHelper.applyAnnotations(compInfo, selfAllowed && "self".equals(nm) ? null : nm, true);
}
- 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 47.
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 (NamespaceParser nsParser : _nsParsers) {
if (nsParser.isMatched(attURI)) {
if (nsParser.parse(attr, compInfo, pgdef)) {
handled = true;
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
for (NamespaceParser nsParser : _nsParsers) {
if (nsParser.isMatched(attURI)) {
if (nsParser.parse(attr, compInfo, pgdef)) {
handled = true;
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