codeclimate/javascript-test-reporter

View on GitHub

Showing 28 of 28 total issues

Function getInfo has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  getInfo: function() {
    var env = process.env;

    if (env.TRAVIS) {
      return {
Severity: Major
Found in ci_info.js - About 3 hrs to fix

    Method 'getInfo' has a complexity of 11.
    Open

      getInfo: function() {
    Severity: Minor
    Found in ci_info.js by eslint

    Limit Cyclomatic Complexity (complexity)

    Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

    function a(x) {
        if (true) {
            return x; // 1st path
        } else if (false) {
            return x+1; // 2nd path
        } else {
            return 4; // 3rd path
        }
    }

    Rule Details

    This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

    Examples of incorrect code for a maximum of 2:

    /*eslint complexity: ["error", 2]*/
    
    function a(x) {
        if (true) {
            return x;
        } else if (false) {
            return x+1;
        } else {
            return 4; // 3rd path
        }
    }

    Examples of correct code for a maximum of 2:

    /*eslint complexity: ["error", 2]*/
    
    function a(x) {
        if (true) {
            return x;
        } else {
            return 4;
        }
    }

    Options

    Optionally, you may specify a max object property:

    "complexity": ["error", 2]

    is equivalent to

    "complexity": ["error", { "max": 2 }]

    Deprecated: the object property maximum is deprecated. Please use the property max instead.

    When Not To Use It

    If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

    Further Reading

    Related Rules

    • [max-depth](max-depth.md)
    • [max-len](max-len.md)
    • [max-nested-callbacks](max-nested-callbacks.md)
    • [max-params](max-params.md)
    • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

    Function getInfo has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      getInfo: function() {
        var env = process.env;
    
        if (env.TRAVIS) {
          return {
    Severity: Minor
    Found in ci_info.js - 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

    Function sourceFiles has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Formatter.prototype.sourceFiles = function(data) {
      var source_files = [];
      var self = this;
      data.forEach(function(elem, index) {
        var content;
    Severity: Minor
    Found in formatter.js - About 1 hr to fix

      Function format has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Formatter.prototype.format = function(coverageData, callback) {
        var self = this;
      
        self.parse(coverageData, function(parseError, data) {
          if (parseError) {
      Severity: Minor
      Found in formatter.js - About 1 hr to fix

        Function exports has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function(data, cb) {
          var memo = {};
          var parsedData = [];
        
          var lines = data.split('\n');
        Severity: Minor
        Found in gocover_parse.js - About 1 hr to fix

          Function postJson has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          var postJson = function(data, opts) {
            opts = opts || {};
          
            options.rejectUnauthorized = !opts.skip_certificate;
          
          
          Severity: Minor
          Found in http_client.js - About 1 hr to fix

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

                } else if (env.APPVEYOR) {
                  return {
                    name:             "appveyor",
                    build_identifier: env.APPVEYOR_BUILD_NUMBER,
                    branch:           env.APPVEYOR_REPO_BRANCH,
            Severity: Major
            Found in ci_info.js and 4 other locations - About 40 mins to fix
            ci_info.js on lines 25..80
            ci_info.js on lines 39..80
            ci_info.js on lines 47..80
            ci_info.js on lines 63..80

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

            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 5 locations. Consider refactoring.
            Open

                } else if (env.CI_NAME && env.CI_NAME.match(/codeship/i)) {
                  return {
                    name:             "codeship",
                    build_identifier: env.CI_BUILD_NUMBER,
                    build_url:        env.CI_BUILD_URL,
            Severity: Major
            Found in ci_info.js and 4 other locations - About 40 mins to fix
            ci_info.js on lines 25..80
            ci_info.js on lines 39..80
            ci_info.js on lines 55..80
            ci_info.js on lines 63..80

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

            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 5 locations. Consider refactoring.
            Open

                } else if (env.JENKINS_URL) {
                  return {
                    name:             "jenkins",
                    build_identifier: env.BUILD_NUMBER,
                    build_url:        env.BUILD_URL,
            Severity: Major
            Found in ci_info.js and 4 other locations - About 40 mins to fix
            ci_info.js on lines 39..80
            ci_info.js on lines 47..80
            ci_info.js on lines 55..80
            ci_info.js on lines 63..80

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

            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 5 locations. Consider refactoring.
            Open

                } else if (env.BUILDKITE) {
                  return {
                    name:             "buildkite",
                    build_identifier: env.BUILDKITE_BUILD_ID,
                    build_url:        env.BUILDKITE_BUILD_URL,
            Severity: Major
            Found in ci_info.js and 4 other locations - About 40 mins to fix
            ci_info.js on lines 25..80
            ci_info.js on lines 39..80
            ci_info.js on lines 47..80
            ci_info.js on lines 55..80

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

            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 5 locations. Consider refactoring.
            Open

                } else if (env.WERCKER) {
                  return {
                    name:               "wercker",
                    build_identifier:   env.WERCKER_BUILD_ID,
                    build_url:          env.WERCKER_BUILD_URL,
            Severity: Major
            Found in ci_info.js and 4 other locations - About 40 mins to fix
            ci_info.js on lines 25..80
            ci_info.js on lines 47..80
            ci_info.js on lines 55..80
            ci_info.js on lines 63..80

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

            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 {};
            Severity: Major
            Found in ci_info.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return {
                      name:             "gitlab-ci",
                      build_identifier: env.CI_BUILD_ID,
                      branch:           env.CI_BUILD_REF_NAME,
                      commit_sha:       env.CI_BUILD_REF
              Severity: Major
              Found in ci_info.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return {
                        name:             "tddium",
                        build_identifier: env.TDDIUM_SESSION_ID,
                        worker_id:        env.TDDIUM_TID
                      };
                Severity: Major
                Found in ci_info.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        return {
                          name:             "buildkite",
                          build_identifier: env.BUILDKITE_BUILD_ID,
                          build_url:        env.BUILDKITE_BUILD_URL,
                          branch:           env.BUILDKITE_BRANCH,
                  Severity: Major
                  Found in ci_info.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                          return {
                            name:             "codeship",
                            build_identifier: env.CI_BUILD_NUMBER,
                            build_url:        env.CI_BUILD_URL,
                            branch:           env.CI_BRANCH,
                    Severity: Major
                    Found in ci_info.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            return {
                              name:             "appveyor",
                              build_identifier: env.APPVEYOR_BUILD_NUMBER,
                              branch:           env.APPVEYOR_REPO_BRANCH,
                              commit_sha:       env.APPVEYOR_REPO_COMMIT,
                      Severity: Major
                      Found in ci_info.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              return {
                                name:               "wercker",
                                build_identifier:   env.WERCKER_BUILD_ID,
                                build_url:          env.WERCKER_BUILD_URL,
                                branch:             env.WERCKER_GIT_BRANCH,
                        Severity: Major
                        Found in ci_info.js - About 30 mins to fix

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

                            committedAt: function(cb) {
                              childProcess.exec("git log -1 --pretty=format:%ct", function (error, stdout, stderr) {
                                var result = null;
                                var timestamp = null;
                                if (stdout) {
                          Severity: Minor
                          Found in git_info.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