Showing 4,841 of 7,782 total issues

Consider simplifying this complex logical expression.
Open

                            if (forward && useCache) {

                                // Seek `elem` from a previously-cached index

                                // ...in a gzip-friendly way
Severity: Critical
Found in zk/src/main/resources/web/js/zk/ext/jquery.js - About 2 hrs to fix

    Consider simplifying this complex logical expression.
    Open

            if (a && getParsingFlags(m).overflow === -2) {
                overflow =
                    a[MONTH] < 0 || a[MONTH] > 11
                        ? MONTH
                        : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH])
    Severity: Critical
    Found in zk/src/main/resources/web/js/zk/ext/moment.js - About 2 hrs to fix

      Consider simplifying this complex logical expression.
      Open

              if (((domRight >= viewLeft && domRight <= viewRight)
                      || (domLeft >= viewLeft && domLeft <= viewRight)
                      || (domLeft <= viewLeft && domRight >= viewRight))
                  && ((domTop >= viewTop && domTop <= viewBottom)
                      || (domBottom >= viewTop && domBottom <= viewBottom)
      Severity: Critical
      Found in zul/src/main/resources/web/js/zul/Scrollbar.ts - About 2 hrs to fix

        Method escape has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            static String escape(final String text,
                                 final JavaScriptEscapeType escapeType, final JavaScriptEscapeLevel escapeLevel) {
        
                if (text == null) {
                    return null;
        Severity: Major
        Found in zcommon/src/main/java/org/zkoss/lang/JavaScriptEscapeUtil.java - About 2 hrs to fix

          Method defineFunction has 66 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public void defineFunction(String prefix, String function, String className,
                      String methodName) throws ClassNotFoundException,
                      NoSuchMethodException {
          
                  if (prefix == null || function == null || className == null ||
          Severity: Major
          Found in zel/src/main/java/org/zkoss/zel/ELProcessor.java - About 2 hrs to fix

            Method coerceToNumber has 66 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected static final Number coerceToNumber(final String val,
                        final Class<?> type) throws ELException {
                    if (Long.TYPE == type || Long.class.equals(type)) {
                        try {
                            return Long.valueOf(val);
            Severity: Major
            Found in zel/src/main/java/org/zkoss/zel/impl/lang/ELSupport.java - About 2 hrs to fix

              Method process has 66 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected boolean process(Session sess, HttpServletRequest request, HttpServletResponse response, String originPath,
                          boolean bRichlet) throws ServletException, IOException {
              
                      // Fix Server-Side Request Forgery (SSRF)
                      String path = Https.sanitizePath(originPath);
              Severity: Major
              Found in zk/src/main/java/org/zkoss/zk/ui/http/RichletFilter.java - About 2 hrs to fix

                Method setShadowHost has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public void setShadowHost(Component host, Component insertBefore) {
                        if (getParent() != null) {
                            throw new UiException("As a shadow child cannot be a shadow root. [" + this + "]");
                        }
                        if (host == null) {
                Severity: Major
                Found in zk/src/main/java/org/zkoss/zk/ui/HtmlShadowElement.java - About 2 hrs to fix

                  Method adjustInsertionForRemove has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private boolean adjustInsertionForRemove(HtmlShadowElement se, Component removed) {
                          Component old = null;
                          Direction direction = inRange(se, removed);
                          switch (direction) {
                          case PREVIOUS:
                  Severity: Major
                  Found in zk/src/main/java/org/zkoss/zk/ui/HtmlShadowElement.java - About 2 hrs to fix

                    Method renderTab has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public void renderTab(Tab item, final Object data, final int index) throws Exception {
                            final Tabbox tabbox = item.getTabbox();
                            final Tabs tabs = tabbox.getTabs();
                            final int size = tabbox.getModel().getSize();
                            final String tmn = "model";
                    Severity: Major
                    Found in zkbind/src/main/java/org/zkoss/bind/impl/BindTabboxRenderer.java - About 2 hrs to fix

                      Method render has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              public void render(Treeitem ti, final Object node, final int index) {
                                  Tree tree = ti.getTree();
                                  final Template tm = tree.getTemplate("model");
                                  if (tm == null) {
                                      Treecell tc = new Treecell(Objects.toString(node));
                      Severity: Major
                      Found in zul/src/main/java/org/zkoss/zul/Tree.java - About 2 hrs to fix

                        Function hierarchy has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        d3.layout.hierarchy = function() {
                          var sort = d3_layout_hierarchySort,
                              children = d3_layout_hierarchyChildren,
                              value = d3_layout_hierarchyValue;
                        
                        
                        Severity: Major
                        Found in zktest/src/main/webapp/js/d3.layout.js - About 2 hrs to fix

                          Method LambdaExpressionOrInvocation has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            final public void LambdaExpressionOrInvocation() throws ParseException {
                                                                                   /*@bgen(jjtree) LambdaExpression */
                            AstLambdaExpression jjtn000 = new AstLambdaExpression(JJTLAMBDAEXPRESSION);
                            boolean jjtc000 = true;
                            jjtree.openNodeScope(jjtn000);
                          Severity: Major
                          Found in zel/src/main/java/org/zkoss/zel/impl/parser/ELParser.java - About 2 hrs to fix

                            Method wireServiceCommand has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public static final void wireServiceCommand(final Component comp, final Object controller) {
                                    Reflections.forMethods(controller.getClass(), Command.class, new Reflections.MethodRunner<Command>() {
                                        public void onMethod(Class<?> clazz, final Method method, Command annotation) {
                                            if ((method.getModifiers() & Modifier.STATIC) != 0)
                                                throw new UiException("Cannot add forward to static method: " + method.getName());
                            Severity: Major
                            Found in zk/src/main/java/org/zkoss/zk/ui/util/ConventionWires.java - About 2 hrs to fix

                              Method execCreate0 has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private static final Component[] execCreate0(CreateInfo ci, NodeInfo parentInfo, Component parent,
                                          Component insertBefore) {
                                      final List<Component> created = new LinkedList<Component>();
                                      final Page page = ci.page;
                                      final PageDefinition pagedef = parentInfo.getPageDefinition();
                              Severity: Major
                              Found in zk/src/main/java/org/zkoss/zk/ui/impl/UiEngineImpl.java - About 2 hrs to fix

                                Method save has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public void save(BindContext ctx) {
                                        final Binder binder = getBinder();
                                        final Component comp = getComponent(); //ctx.getComponent();
                                        final Form form = getFormBean(ctx);
                                
                                
                                Severity: Major
                                Found in zkbind/src/main/java/org/zkoss/bind/impl/SaveFormBindingImpl.java - About 2 hrs to fix

                                  Method onChange has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                          public void onChange(GroupsDataEvent event) {
                                              int type = event.getType(), j0 = event.getIndex0(), j1 = event.getIndex1();
                                  
                                              switch (type) {
                                              case GroupsDataEvent.CONTENTS_CHANGED:
                                  Severity: Major
                                  Found in zul/src/main/java/org/zkoss/zul/impl/GroupsListModel.java - About 2 hrs to fix

                                    Function relayout has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      function relayout() {
                                        var subgroups = {},
                                            groupSums = [],
                                            groupIndex = d3.range(n),
                                            subgroupIndex = [],
                                    Severity: Major
                                    Found in zktest/src/main/webapp/js/d3.layout.js - About 2 hrs to fix

                                      Method get has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          @SuppressWarnings("unchecked")
                                          public V get(Object src) {
                                              WaitLock lock = null;
                                              for (;;) {
                                                  Info ri = null;
                                      Severity: Minor
                                      Found in zcommon/src/main/java/org/zkoss/util/resource/ResourceCache.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 getByFallback has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          public static Locale getByFallback(Collection<Locale> values, Locale locale) {
                                              if (values.contains(locale))
                                                  return locale;
                                      
                                              final String lang = locale.getLanguage();
                                      Severity: Minor
                                      Found in zcommon/src/main/java/org/zkoss/util/Locales.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

                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language