Showing 7,775 of 7,775 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
Open

            el = zk.gecko && el != document.body ?
                _ofsParent(el) : el.offsetParent as HTMLElement;
Severity: Minor
Found in zk/src/main/resources/web/js/zk/dom.ts and 1 other location - About 30 mins to fix
zk/src/main/resources/web/js/zk/dom.ts on lines 236..237

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 45.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            && ((domTop >= viewTop && domTop <= viewBottom)
                || (domBottom >= viewTop && domBottom <= viewBottom)
                || (domTop <= viewTop && domBottom >= viewBottom))) {
Severity: Minor
Found in zul/src/main/resources/web/js/zul/Scrollbar.ts and 1 other location - About 30 mins to fix
zul/src/main/resources/web/js/zul/Scrollbar.ts on lines 367..369

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 45.

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

Further Reading

Method resolveDependency has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static void resolveDependency(XMLResource xr,
    List<Resource> rcs, Map<String, XMLResource> rcmap, Set<String> resolving, String elName) {
        if (!resolving.add(xr.name))
            throw new IllegalStateException("Recusrive reference among "+resolving);

Severity: Minor
Found in zcommon/src/main/java/org/zkoss/util/resource/ClassLocator.java - About 25 mins to fix

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 removeFromLastVisited has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private boolean removeFromLastVisited(F o) {
        if (_lastVisited != null)
            for (Iterator<F> it = _lastVisited.iterator(); it.hasNext();) {
                if (it.next() == o) { //not equals (more restricted)
                    it.remove();
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/util/ComodifiableIterator.java - About 25 mins to fix

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 redraw has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public void redraw(java.io.Writer out) throws java.io.IOException {
        if (_tagnm == null)
            throw new UiException("The tag name is not initialized yet");

        final Execution exec = Executions.getCurrent();
Severity: Minor
Found in zhtml/src/main/java/org/zkoss/zhtml/impl/AbstractTag.java - About 25 mins to fix

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 getSubstyleValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static final String getSubstyleValue(final String style, int j) {
        final int len = style.length();
        int k = -1, l = j;
        for (; l < len; ++l) {
            final char cc = style.charAt(l);
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/html/HTMLs.java - About 25 mins to fix

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 put has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    @SuppressWarnings("unchecked")
    private static void put(Map map, String name, String value, boolean multiple) {
        if (multiple) {
            List l = (List)map.get(name);
            if (l == null)
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/util/Maps.java - About 25 mins to fix

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 getEndingParenthesis has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static final char getEndingParenthesis(char cc) {
        return cc == '{' ? '}': cc == '(' ? ')': cc == '[' ? ']': (char)0;
    }
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/util/Maps.java - About 25 mins to fix

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 sanitizeURL has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static URL sanitizeURL(URL url) throws MalformedURLException, URISyntaxException {
        if (url == null) return null;

        final String urlString = url.getPath();
        // avoid java.net.MalformedURLException: no !/ in spec
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/util/URLs.java - About 25 mins to fix

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 resolveFunction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public Function resolveFunction(String prefix, String name) {
        Function m = _first != null ? _first.resolveFunction(prefix, name): null;
        return m != null ? m:
            _second != null ? _second.resolveFunction(prefix, name): null;
    }
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/xel/util/DualFunctionMapper.java - About 25 mins to fix

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 equals has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof JavaScript))
            return false;
        final JavaScript js = (JavaScript)o;
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/html/JavaScript.java - About 25 mins to fix

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 removeBy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    @SuppressWarnings("unchecked")
    synchronized public boolean removeBy(Comparable val, boolean atMostOne) {
        final List l = new LinkedList();
        boolean found = false;
        for (int j = 0; j < _ary.length; ++j)
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/util/FastReadArray.java - About 25 mins to fix

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 resolveClass has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public Class<?> resolveClass(String name) {
        Class<?> m = _first instanceof FunctionMapperExt ?
            ((FunctionMapperExt)_first).resolveClass(name): null;
        return m != null ? m:
            _second instanceof FunctionMapperExt ?
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/xel/util/DualFunctionMapper.java - About 25 mins to fix

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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public V get(Object key) {
        V val = _cache.get(key);
        if (val == null && _moreInWriteCache)
            synchronized (this) {
                if (_writeCache != null && (val = _writeCache.get(key)) != null)
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/util/FastReadCache.java - About 25 mins to fix

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 toOctalString has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public final static String toOctalString(byte[] array, String prefix) {
        StringBuffer sb = new StringBuffer(array.length*
                (3 + (prefix == null ? 0 : prefix.length())) + 8);
        if (prefix == null) {
            for (int i=0; i< array.length; i++) {
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/util/ArraysX.java - About 25 mins to fix

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 setDynaProp has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private void setDynaProp(String name, Object value) {
        if (value == null) {
            if (_props != null)
                _props.remove(name);
        } else {
Severity: Minor
Found in zhtml/src/main/java/org/zkoss/zhtml/impl/AbstractTag.java - About 25 mins to fix

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 getChecksum has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static final char getChecksum(String val, String skips) {
        if (skips == null) skips = SKIPS;

        final int len = val.length();
        int cksum = 0;
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/util/Checksums.java - About 25 mins to fix

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 equals has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof Key))
                return false;
            Key k = (Key)o;
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/util/resource/PropertyBundle.java - About 25 mins to fix

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 skipParenthesis has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static int skipParenthesis(String src, int j, char beg, char end) {
        for (int len = src.length(), depth = 0; ++j < len;) {
            final char cc = src.charAt(j);
            if (cc == '\\') ++j; //skip next
            else if (cc == beg) ++depth;
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/util/Maps.java - About 25 mins to fix

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 getChecksum has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static final char getChecksum(StringBuffer val, String skips) {
        if (skips == null) skips = SKIPS;

        final int len = val.length();
        int cksum = 0;
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/util/Checksums.java - About 25 mins to fix

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

Severity
Category
Status
Source
Language