silentbalanceyh/vertx-zero

View on GitHub
vertx-gaia/vertx-up/src/main/java/io/vertx/up/unity/Upload.java

Summary

Maintainability
D
2 days
Test Coverage

Method toFile has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
Open

    static <T> T toFile(final Set<FileUpload> fileUploads, final Class<?> expected, final Function<String, Buffer> consumer) {
        /*
         * Size = 0
         * Size = 1
         * Size > 1
Severity: Minor
Found in vertx-gaia/vertx-up/src/main/java/io/vertx/up/unity/Upload.java - About 7 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 toFile has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    static <T> T toFile(final Set<FileUpload> fileUploads, final Class<?> expected, final Function<String, Buffer> consumer) {
        /*
         * Size = 0
         * Size = 1
         * Size > 1
Severity: Major
Found in vertx-gaia/vertx-up/src/main/java/io/vertx/up/unity/Upload.java - About 2 hrs to fix

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

        static <T> T toFile(final FileUpload fileUpload, final Class<?> expected, final Function<String, Buffer> consumer) {
            final String filename = fileUpload.uploadedFileName();
            if (FileUpload.class.isAssignableFrom(expected)) {
                /*
                 * FileUpload ( interface )
    Severity: Minor
    Found in vertx-gaia/vertx-up/src/main/java/io/vertx/up/unity/Upload.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 toFile has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        static <T> T toFile(final FileUpload fileUpload, final Class<?> expected, final Function<String, Buffer> consumer) {
            final String filename = fileUpload.uploadedFileName();
            if (FileUpload.class.isAssignableFrom(expected)) {
                /*
                 * FileUpload ( interface )
    Severity: Minor
    Found in vertx-gaia/vertx-up/src/main/java/io/vertx/up/unity/Upload.java - About 1 hr to fix

      Avoid too many return statements within this method.
      Open

                  return (T) fileUpload;
      Severity: Major
      Found in vertx-gaia/vertx-up/src/main/java/io/vertx/up/unity/Upload.java - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                                return (T) fileUploads.stream()
                                    .map(item -> toFile(item, componentCls, consumer))
                                    .toArray();
        Severity: Major
        Found in vertx-gaia/vertx-up/src/main/java/io/vertx/up/unity/Upload.java - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                              return (T) Collections.emptyList();
          Severity: Major
          Found in vertx-gaia/vertx-up/src/main/java/io/vertx/up/unity/Upload.java - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return (T) ZeroSerializer.getValue(expected, filename);
            Severity: Major
            Found in vertx-gaia/vertx-up/src/main/java/io/vertx/up/unity/Upload.java - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                                  return null;
              Severity: Major
              Found in vertx-gaia/vertx-up/src/main/java/io/vertx/up/unity/Upload.java - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                    return (T) bytes;
                Severity: Major
                Found in vertx-gaia/vertx-up/src/main/java/io/vertx/up/unity/Upload.java - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return null;
                  Severity: Major
                  Found in vertx-gaia/vertx-up/src/main/java/io/vertx/up/unity/Upload.java - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                        return null;
                    Severity: Major
                    Found in vertx-gaia/vertx-up/src/main/java/io/vertx/up/unity/Upload.java - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                          return (T) stream.collect(Collectors.toSet());
                      Severity: Major
                      Found in vertx-gaia/vertx-up/src/main/java/io/vertx/up/unity/Upload.java - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                            return (T) stream.collect(Collectors.toList());
                        Severity: Major
                        Found in vertx-gaia/vertx-up/src/main/java/io/vertx/up/unity/Upload.java - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                              return (T) Collections.emptySet();
                          Severity: Major
                          Found in vertx-gaia/vertx-up/src/main/java/io/vertx/up/unity/Upload.java - About 30 mins to fix

                            There are no issues that match your filters.

                            Category
                            Status