zul/src/main/java/org/zkoss/zul/Datebox.java

Summary

Maintainability
F
6 days
Test Coverage

File Datebox.java has 603 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* Datebox.java

    Purpose:

    Description:
Severity: Major
Found in zul/src/main/java/org/zkoss/zul/Datebox.java - About 1 day to fix

    Method loadSymbols has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
    Open

        public static Map loadSymbols(Locale locale) {
            WaitLock lock = null;
            for (;;) {
                final Object o;
                synchronized (_symbols) {
    Severity: Minor
    Found in zul/src/main/java/org/zkoss/zul/Datebox.java - About 1 day 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

    Datebox has 51 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class Datebox extends DateTimeFormatInputElement {
    
        private static final Logger log = LoggerFactory.getLogger(Datebox.class);
        public static final String DEFAULT_FORMAT = "yyyy/MM/dd";
    
    
    Severity: Major
    Found in zul/src/main/java/org/zkoss/zul/Datebox.java - About 7 hrs to fix

      Method loadSymbols has 146 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static Map loadSymbols(Locale locale) {
              WaitLock lock = null;
              for (;;) {
                  final Object o;
                  synchronized (_symbols) {
      Severity: Major
      Found in zul/src/main/java/org/zkoss/zul/Datebox.java - About 5 hrs to fix

        Method renderProperties has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws java.io.IOException {
                super.renderProperties(renderer);
                if (!_btnVisible)
                    renderer.render("buttonVisible", false);
                if (!_lenient)
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Datebox.java - About 2 hrs 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 setDisplayedTimeZones has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            public void setDisplayedTimeZones(List<TimeZone> dtzones) {
                if (dtzones != null && dtzones.isEmpty())
                    dtzones = null;
                if (_dtzones != dtzones) {
                    _dtzones = dtzones;
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Datebox.java - About 1 hr 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 renderProperties has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws java.io.IOException {
                super.renderProperties(renderer);
                if (!_btnVisible)
                    renderer.render("buttonVisible", false);
                if (!_lenient)
        Severity: Minor
        Found in zul/src/main/java/org/zkoss/zul/Datebox.java - About 1 hr to fix

          Method getRealFormat has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public String getRealFormat() {
                  final String format = getFormat();
                  if (format == null || format.length() == 0)
                      return getDefaultFormat(); //backward compatible
          
          
          Severity: Minor
          Found in zul/src/main/java/org/zkoss/zul/Datebox.java - About 1 hr 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 setFormat has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              public void setFormat(String format) throws WrongValueException {
                  if (format == null) {
                      format = "";
                  } else if (format.length() != 0) {
                      boolean bCustom;
          Severity: Minor
          Found in zul/src/main/java/org/zkoss/zul/Datebox.java - About 55 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 setTimeZone has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public void setTimeZone(TimeZone tzone) {
                  if (_tzone != tzone) {
                      if (_dtzones != null) {
                          tzone = _dtzones.contains(tzone) ? tzone : _dtzones.get(0);
                      }
          Severity: Minor
          Found in zul/src/main/java/org/zkoss/zul/Datebox.java - About 35 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 setDisplayedTimeZones has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public void setDisplayedTimeZones(String dtzones) {
                  if (dtzones == null || dtzones.length() == 0) {
                      setDisplayedTimeZones((List<TimeZone>) null);
                      return;
                  }
          Severity: Minor
          Found in zul/src/main/java/org/zkoss/zul/Datebox.java - About 35 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

          Avoid too many return statements within this method.
          Open

                  return -111; //not found
          Severity: Major
          Found in zul/src/main/java/org/zkoss/zul/Datebox.java - About 30 mins to fix

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

                private static Object[] getRealSymbols(Locale locale, Datebox box) {
                    if (locale != null) {
                        final String localeName = locale.toString();
                        if (org.zkoss.zk.ui.impl.Utils.markClientInfoPerDesktop(box.getDesktop(),
                                box.getClass().getName() + localeName)) {
            Severity: Minor
            Found in zul/src/main/java/org/zkoss/zul/Datebox.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

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

                        for (int j = firstDayOfWeek, k = 0; k < 7; ++k) {
                            cal.set(Calendar.DAY_OF_WEEK, j);
                            sdow[k] = df.format(cal.getTime());
                            if (++j > Calendar.SATURDAY)
                                j = Calendar.SUNDAY;
            Severity: Major
            Found in zul/src/main/java/org/zkoss/zul/Datebox.java and 1 other location - About 3 hrs to fix
            zk/src/main/java/org/zkoss/zk/ui/http/Wpds.java on lines 225..238

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

            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

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

                        for (int j = 0; j < 12; ++j) {
                            cal.set(Calendar.MONTH, j);
                            smon[j] = df.format(cal.getTime());
            
                            if (zhlang) {
            Severity: Major
            Found in zul/src/main/java/org/zkoss/zul/Datebox.java and 1 other location - About 3 hrs to fix
            zk/src/main/java/org/zkoss/zk/ui/http/Wpds.java on lines 254..266

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

            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

                    for (;;) {
                        final Object o;
                        synchronized (_symbols) {
                            o = _symbols.get(locale);
                            if (o == null)
            Severity: Major
            Found in zul/src/main/java/org/zkoss/zul/Datebox.java and 1 other location - About 1 hr to fix
            zcommon/src/main/java/org/zkoss/util/resource/impl/LabelLoaderImpl.java on lines 221..238

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

            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

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

                        for (int j = firstDayOfWeek, k = 0; k < 7; ++k) {
                            cal.set(Calendar.DAY_OF_WEEK, j);
                            fdow[k] = df.format(cal.getTime());
                            if (++j > Calendar.SATURDAY)
                                j = Calendar.SUNDAY;
            Severity: Major
            Found in zul/src/main/java/org/zkoss/zul/Datebox.java and 1 other location - About 1 hr to fix
            zk/src/main/java/org/zkoss/zk/ui/http/Wpds.java on lines 245..250

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

            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

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

                protected class ExtraCtrl extends FormatInputElement.ExtraCtrl implements Blockable {
                    public boolean shallBlock(AuRequest request) {
                        // B50-3316103: special case of readonly component: do not block onChange and onSelect
                        final String cmd = request.getCommand();
                        if (Events.ON_OPEN.equals(cmd))
            Severity: Minor
            Found in zul/src/main/java/org/zkoss/zul/Datebox.java and 1 other location - About 50 mins to fix
            zul/src/main/java/org/zkoss/zul/Combobox.java on lines 952..961

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

            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

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

                protected DateFormat getDateFormat(String fmt) {
                    final DateFormat df = new SimpleDateFormat(fmt, _locale != null ? _locale : Locales.getCurrent());
                    final TimeZone tz = _tzone != null ? _tzone : TimeZones.getCurrent();
                    df.setTimeZone(tz);
                    return df;
            Severity: Minor
            Found in zul/src/main/java/org/zkoss/zul/Datebox.java and 1 other location - About 50 mins to fix
            zul/src/main/java/org/zkoss/zul/Timebox.java on lines 274..279

            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

            Further Reading

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

                        for (int j = 0; j < 12; ++j) {
                            cal.set(Calendar.MONTH, j);
                            fmon[j] = df.format(cal.getTime());
                        }
            Severity: Minor
            Found in zul/src/main/java/org/zkoss/zul/Datebox.java and 1 other location - About 40 mins to fix
            zk/src/main/java/org/zkoss/zk/ui/http/Wpds.java on lines 270..273

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

            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

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

                    try {
                        date = df.parse(value);
                    } catch (ParseException ex) {
                        throw showCustomError(new WrongValueException(this, MZul.DATE_REQUIRED, new Object[] { value, fmt }));
                    }
            Severity: Minor
            Found in zul/src/main/java/org/zkoss/zul/Datebox.java and 1 other location - About 30 mins to fix
            zul/src/main/java/org/zkoss/zul/Timebox.java on lines 257..261

            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

            Further Reading

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

                    if (!"day".equals(selectLevel) && !"month".equals(selectLevel) && !"year".equals(selectLevel))
                        throw new WrongValueException("Only allowed day, month, and year, not " + selectLevel);
            Severity: Major
            Found in zul/src/main/java/org/zkoss/zul/Datebox.java and 3 other locations - About 30 mins to fix
            zul/src/main/java/org/zkoss/zul/Include.java on lines 328..329
            zul/src/main/java/org/zkoss/zul/Splitter.java on lines 117..118
            zul/src/main/java/org/zkoss/zul/Toolbar.java on lines 74..75

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 40.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            There are no issues that match your filters.

            Category
            Status