zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java

Summary

Maintainability
F
4 days
Test Coverage

Method processItem has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
Open

    private static final Media processItem(Desktop desktop, FileItem fi, boolean alwaysNative,
            org.zkoss.zk.ui.sys.DiskFileItemFactory factory) throws IOException {
        String name = getBaseName(fi);
        if (name != null) {
            //Not sure whether a name might contain ;jsessionid or similar
Severity: Minor
Found in zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.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

File AuMultipartUploader.java has 552 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* AuMultipartUploader.java

    Purpose:

    Description:
Severity: Major
Found in zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java - About 1 day to fix

    Method processItem has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static final Media processItem(Desktop desktop, FileItem fi, boolean alwaysNative,
                org.zkoss.zk.ui.sys.DiskFileItemFactory factory) throws IOException {
            String name = getBaseName(fi);
            if (name != null) {
                //Not sure whether a name might contain ;jsessionid or similar
    Severity: Major
    Found in zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java - About 2 hrs to fix

      Method getCharset has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          private static String getCharset(String ctype) {
              final String ctypelc = ctype.toLowerCase(java.util.Locale.ENGLISH);
              for (int j = 0; (j = ctypelc.indexOf("charset", j)) >= 0; j += 7) {
                  int k = org.zkoss.lang.Strings.skipWhitespacesBackward(ctype, j - 1);
                  if (k < 0 || ctype.charAt(k) == ';') {
      Severity: Minor
      Found in zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.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 parseRequest has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          public static AuDecoder parseRequest(HttpServletRequest request, AuDecoder decoder) {
              Map<String, Object> params = getFileuploadMetaPerWebApp(
                      WebApps.getCurrent());
              AbstractFileUpload upload = newServletDiskFileUpload(new DiskFileItemFactory.Builder()
                      .setBufferSize((Integer) params.get("sizeThreadHold"))
      Severity: Minor
      Found in zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.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 parseRequest has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static AuDecoder parseRequest(HttpServletRequest request, AuDecoder decoder) {
              Map<String, Object> params = getFileuploadMetaPerWebApp(
                      WebApps.getCurrent());
              AbstractFileUpload upload = newServletDiskFileUpload(new DiskFileItemFactory.Builder()
                      .setBufferSize((Integer) params.get("sizeThreadHold"))
      Severity: Minor
      Found in zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java - About 1 hr to fix

        Method getFileuploadMetaPerWebApp has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static  Map<String, Object> getFileuploadMetaPerWebApp(WebApp webApp) {
                final Map<String, Object> params = new HashMap<String, Object>();
        
                final Configuration conf = webApp.getConfiguration();
                int thrs = conf.getFileSizeThreshold();
        Severity: Minor
        Found in zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java - About 1 hr to fix

          Method reconstructPacket has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static Object reconstructPacket(Object data, Map<String, Object> reqData, Desktop desktop,
                      Map<String, Object> params) throws IOException {
                  if (data instanceof List) {
                      int i = 0;
                      List listData = (List) data;
          Severity: Minor
          Found in zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java - About 1 hr to fix

            Method decode has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    public List<AuRequest> decode(Object request, Desktop desktop) {
                        List<AuRequest> auRequests = _origin.decode(
                                new MultipartRequestWrapper((HttpServletRequest) request,
                                        _queryData), desktop);
            
            
            Severity: Minor
            Found in zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java - About 1 hr to fix

              Method uploadErrorMessage has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private static String uploadErrorMessage(Throwable ex) {
                      log.error("Failed to upload", ex);
                      if (ex instanceof FileUploadSizeException) {
                          try {
                              FileUploadSizeException fex = (FileUploadSizeException) ex;
              Severity: Minor
              Found in zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java - About 1 hr to fix

                Method reconstructPacket has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    private static Object reconstructPacket(Object data, Map<String, Object> reqData, Desktop desktop,
                            Map<String, Object> params) throws IOException {
                        if (data instanceof List) {
                            int i = 0;
                            List listData = (List) data;
                Severity: Minor
                Found in zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java - About 45 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 getFileuploadMetaPerWebApp has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    private static  Map<String, Object> getFileuploadMetaPerWebApp(WebApp webApp) {
                        final Map<String, Object> params = new HashMap<String, Object>();
                
                        final Configuration conf = webApp.getConfiguration();
                        int thrs = conf.getFileSizeThreshold();
                Severity: Minor
                Found in zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.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 getFileuploadMetaPerComp has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    private static Map<String, Object> getFileuploadMetaPerComp(Map<String, Object> params, Desktop desktop, String uuid) {
                
                        // stateless may not have comp at server.
                        Component comp = desktop.getComponentByUuidIfAny(uuid);
                        if (comp != null) {
                Severity: Minor
                Found in zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.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 fi.isInMemory() ? new AImage(name, fi.get()) : new AImage(name, fi.getInputStream());
                Severity: Major
                Found in zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return fi.isInMemory() ? new AMedia(name, null, ctype, fi.get()) : new StreamMedia(name, null, ctype, fi);
                  Severity: Major
                  Found in zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java - About 30 mins to fix

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

                        private static class StreamVideo extends AVideo {
                            private final FileItem _fi;
                            private String _format;
                            private String _ctype;
                    
                    
                    zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java on lines 438..467

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

                    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

                        private static class StreamAudio extends AAudio {
                            private final FileItem _fi;
                            private String _format;
                            private String _ctype;
                    
                    
                    zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java on lines 469..498

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

                    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

                                } else if (ctypelc.startsWith("video/")) {
                                    try {
                                        return fi.isInMemory() ? new AVideo(name, fi.get()) : new StreamVideo(name, fi, ctypelc);
                                    } catch (Throwable ex) {
                                        if (log.isDebugEnabled())
                    Severity: Minor
                    Found in zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java and 1 other location - About 40 mins to fix
                    zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java on lines 555..562

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

                    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

                                } else if (ctypelc.startsWith("audio/")) {
                                    try {
                                        return fi.isInMemory() ? new AAudio(name, fi.get()) : new StreamAudio(name, fi, ctypelc);
                                    } catch (Throwable ex) {
                                        if (log.isDebugEnabled())
                    Severity: Minor
                    Found in zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java and 1 other location - About 40 mins to fix
                    zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java on lines 562..569

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

                    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