flowjs/flow.js

View on GitHub

Showing 38 of 38 total issues

Function prepareXhrRequest has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    prepareXhrRequest: function(method, isTest, paramsMethod, blob) {
      // Add data from the query options
      var query = evalOpts(this.flowObj.opts.query, this.fileObj, this, isTest);
      query = extend(query || {}, this.getParams());

Severity: Minor
Found in src/flow.js - About 1 hr to fix

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

        sizeUploaded: function () {
          var size = 0;
          each(this.chunks, function (chunk) {
            size += chunk.sizeUploaded();
          });
    Severity: Minor
    Found in src/flow.js and 1 other location - About 55 mins to fix
    src/flow.js on lines 665..671

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

    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

        sizeUploaded: function () {
          var size = 0;
          each(this.files, function (file) {
            size += file.sizeUploaded();
          });
    Severity: Minor
    Found in src/flow.js and 1 other location - About 55 mins to fix
    src/flow.js on lines 1023..1029

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

    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

            maxFileSizeErrorCallback: function(file, errorCount) {
              return alert(file.fileName(+' is too large, please upload files less than ' + this.formatSize(this.getOpt('maxFileSize')) + '.'));
            }
    Severity: Minor
    Found in samples/java/web/resumable.js and 1 other location - About 55 mins to fix
    samples/java/web/resumable.js on lines 40..42

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

    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

            minFileSizeErrorCallback: function(file, errorCount) {
              return alert(file.fileName(+' is too small, please upload files larger than ' + this.formatSize(this.getOpt('minFileSize')) + '.'));
            },
    Severity: Minor
    Found in samples/java/web/resumable.js and 1 other location - About 55 mins to fix
    samples/java/web/resumable.js on lines 44..46

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

    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

    Function validateRequest has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        function validateRequest(chunkNumber, chunkSize, totalSize, identifier, filename, fileSize) {
    Severity: Minor
    Found in samples/Node.js/flow-node.js - About 45 mins to fix

      Consider simplifying this complex logical expression.
      Open

              if ((!ie10plus || ie10plus && file.size > 0) && !(file.size % 4096 === 0 && (file.name === '.' || file.fileName === '.'))) {
                var uniqueIdentifier = this.generateUniqueIdentifier(file);
                if (this.opts.allowDuplicateUploads || !this.getFromUniqueIdentifier(uniqueIdentifier)) {
                  var f = new FlowFile(this, file, uniqueIdentifier);
                  if (this.fire('fileAdded', f, event)) {
      Severity: Major
      Found in src/flow.js - About 40 mins to fix

        Function webAPIFileRead has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          function webAPIFileRead(fileObj, startByte, endByte, fileType, chunk) {
        Severity: Minor
        Found in src/flow.js - About 35 mins to fix

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

              public static long toLong(String value, long def) {
                  if (isEmpty(value)) {
                      return def;
                  }
          
          
          Severity: Minor
          Found in samples/java/src/resumable/js/upload/HttpUtils.java and 1 other location - About 35 mins to fix
          samples/java/src/resumable/js/upload/HttpUtils.java on lines 36..46

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

          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

              public static int toInt(String value, int def) {
                  if (isEmpty(value)) {
                      return def;
                  }
                  try {
          Severity: Minor
          Found in samples/java/src/resumable/js/upload/HttpUtils.java and 1 other location - About 35 mins to fix
          samples/java/src/resumable/js/upload/HttpUtils.java on lines 17..28

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

          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

          Avoid too many return statements within this function.
          Open

                    return 'error';
          Severity: Major
          Found in src/flow.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                      return 'pending';
            Severity: Major
            Found in src/flow.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                              return 'invalid_flow_request4';
              Severity: Major
              Found in samples/Node.js/flow-node.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                return 'invalid_flow_request5';
                Severity: Major
                Found in samples/Node.js/flow-node.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return 'pending';
                  Severity: Major
                  Found in samples/java/web/resumable.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return 'valid';
                    Severity: Major
                    Found in samples/Node.js/flow-node.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                return 'success';
                      Severity: Major
                      Found in src/flow.js - About 30 mins to fix

                        Function exports has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        module.exports = function(grunt) {
                          // Project configuration.
                          grunt.initConfig({
                            pkg: grunt.file.readJSON('package.json'),
                            uglify: {
                        Severity: Minor
                        Found in Gruntfile.js - 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

                        Severity
                        Category
                        Status
                        Source
                        Language