Showing 7,775 of 7,775 total issues

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

    public static List<String> addProperties(String key, List<String> values) {
        if (key == null) throw new NullPointerException();
        if (key.length() == 0) throw new IllegalArgumentException();

        synchronized (_props) {
Severity: Major
Found in zcommon/src/main/java/org/zkoss/lang/Library.java and 1 other location - About 1 hr to fix
zcommon/src/main/java/org/zkoss/lang/Library.java on lines 149..160

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

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 zzRefill has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  private boolean zzRefill() throws java.io.IOException {

    /* first: make room (if you can) */
    if (zzStartRead > 0) {
      System.arraycopy(zzBuffer, zzStartRead,
Severity: Minor
Found in zcommon/src/main/java/org/zkoss/json/parser/Yylex.java - About 1 hr to fix

    Method normalize has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static final String normalize(String path) {
            if (path == null)
                return "";
    
            //remove consecutive slashes
    Severity: Minor
    Found in zcommon/src/main/java/org/zkoss/io/Files.java - About 1 hr to fix

      Method checkNamespacePrefix has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static final void checkNamespacePrefix(String prefix, Locator loc) {
              if (prefix == null || prefix.length() == 0)
                  return; //OK: null or empty
      
              String reason = null;
      Severity: Minor
      Found in zcommon/src/main/java/org/zkoss/idom/Verifier.java - About 1 hr to fix

        Method write has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                private Method write(ELContext ctx) {
                    if (this.write == null) {
                        this.write = Util.getMethod(this.owner, descriptor.getWriteMethod());
                        
                        //20110921, henrichen: Introspector is too strict for Setter(must return void), here we loosen it
        Severity: Minor
        Found in zel/src/main/java/org/zkoss/zel/BeanELResolver.java - About 1 hr to fix

          Method Boolean has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            final public void Boolean() throws ParseException {
              switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
              case TRUE:
                AstTrue jjtn001 = new AstTrue(JJTTRUE);
                boolean jjtc001 = true;
          Severity: Minor
          Found in zel/src/main/java/org/zkoss/zel/impl/parser/ELParser.java - About 1 hr to fix

            Method buildParameters has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                static Object[] buildParameters(Class<?>[] parameterTypes,
                        boolean isVarArgs,Object[] params) {
                    ExpressionFactory factory = getExpressionFactory();
                    Object[] parameters = null;
                    if (parameterTypes.length > 0) {
            Severity: Minor
            Found in zel/src/main/java/org/zkoss/zel/Util.java - About 1 hr to fix

              Method buildStaticModel has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static TreeNode<User> buildStaticModel(String data) {
                      DefaultTreeNode<User> root = node("",
                              node(data + "-1",
                                      node(data + "-1-1",
                                              node(data + "-1-1-1"),

                Method addTreeNode has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private BugOasiTreeNode<BugFormModel> addTreeNode(
                            BugOasiTreeNode<BugFormModel> parent,
                            BugOasiTreeNode<BugFormModel> newnod, BugFormModel myrow, boolean open,
                            Integer pos) {
                        if (parent == null) {

                  Method buildStaticModel has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static TreeNode<String> buildStaticModel(String data) {
                          DefaultTreeNode<String> root = node("",
                                  node(data + "-1",
                                          node(data + "-1-1",
                                                  node(data + "-1-1-1"),
                  Severity: Minor
                  Found in zktest/src/main/java/org/zkoss/zktest/test2/B80_ZK_2865Model.java - About 1 hr to fix

                    Method outSpecialJS has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static final String outSpecialJS(Desktop desktop) {
                            final StringBuffer sb = new StringBuffer();
                    
                            //output application name
                            String oldnm = (String) desktop.getAttribute(ATTR_APPNM);
                    Severity: Minor
                    Found in zk/src/main/java/org/zkoss/zk/ui/sys/HtmlPageRenders.java - About 1 hr to fix

                      Method parseLibProperty has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static void parseLibProperty(Element el) {
                              final String nm = IDOMs.getRequiredElementValue(el, "name");
                              Element valueElmn = el.getElement("value");
                              Element appendableElmn = el.getElement("appendable");
                              boolean appendable = appendableElmn != null ? "true".equals(appendableElmn.getText(true)) : false;
                      Severity: Minor
                      Found in zk/src/main/java/org/zkoss/zk/ui/sys/ConfigParser.java - About 1 hr to fix

                        Method injectByMethod has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private boolean injectByMethod(Method md, Class<?> parmcls, Class<?> argcls, Object arg, String fdname) {
                                if (argcls == null || parmcls.isAssignableFrom(argcls)) {
                                    final Field fd = _fldMaps.get(fdname);
                                    if (fd != null && fd.getType().equals(parmcls)) {
                                        final boolean old = fd.isAccessible();
                        Severity: Minor
                        Found in zk/src/main/java/org/zkoss/zk/ui/util/ConventionWire.java - About 1 hr to fix

                          Method lookup has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static final LanguageDefinition lookup(String name) {
                                  init();
                          
                                  if (name == null || name.length() == 0)
                                      name = "xul/html";
                          Severity: Minor
                          Found in zk/src/main/java/org/zkoss/zk/ui/metainfo/LanguageDefinition.java - About 1 hr to fix

                            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)
                            Severity: Minor
                            Found in zk/src/main/java/org/zkoss/zk/ui/metainfo/Parser.java - About 1 hr to fix

                              Method setPageBefore has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public void setPageBefore(Page page, Component refRoot) {
                                      beforeComponentPageChanged(page);
                                      if (refRoot != null && (page == null || refRoot.getParent() != null || refRoot.getPage() != page))
                                          refRoot = null;
                                      if (refRoot != null /*&& refRoot.getPage() == page (checked)*/
                              Severity: Minor
                              Found in zk/src/main/java/org/zkoss/zk/ui/AbstractComponent.java - About 1 hr to fix

                                Method addResponse has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public void addResponse(String key, AuResponse response, int priority) {
                                        if (response == null)
                                            throw new IllegalArgumentException();
                                
                                        //relative fix BUG ZK-1464
                                Severity: Minor
                                Found in zk/src/main/java/org/zkoss/zk/ui/impl/UiVisualizer.java - About 1 hr to fix

                                  Method onEvent has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                          public void onEvent(Event event) throws Exception {
                                              final long max = System.currentTimeMillis() + getMaxSchedTime();
                                              if (log.isDebugEnabled()) {
                                                  log.debug("Handling schedule server push, _schedInfos is empty: [{}]", !scheduledServerPush());
                                              }
                                  Severity: Minor
                                  Found in zk/src/main/java/org/zkoss/zk/ui/impl/DesktopImpl.java - About 1 hr to fix

                                    Method meterAuClient has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        private static void meterAuClient(PerformanceMeter pfmeter, Execution exec, String hdr, boolean complete) {
                                            for (int j = 0;;) {
                                                int k = hdr.indexOf(',', j);
                                                String ids = k >= 0 ? hdr.substring(j, k) : j == 0 ? hdr : hdr.substring(j);
                                    
                                    
                                    Severity: Minor
                                    Found in zk/src/main/java/org/zkoss/zk/ui/impl/UiEngineImpl.java - About 1 hr to fix

                                      Method getDeviceByClient has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          public static final Device getDeviceByClient(String userAgent) throws DeviceNotFoundException {
                                              String[] devTypes;
                                              synchronized (_devmap) {
                                                  Collection<String> c = _devmap.keySet();
                                                  devTypes = c.toArray(new String[c.size()]);
                                      Severity: Minor
                                      Found in zk/src/main/java/org/zkoss/zk/device/Devices.java - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language