karma-runner/karma

View on GitHub

Showing 258 of 258 total issues

Function 9 has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

},{}],9:[function(require,module,exports){
'use strict';

var hasOwn = Object.prototype.hasOwnProperty;
var toStr = Object.prototype.toString;
Severity: Major
Found in static/context.js - About 3 hrs to fix

    Function 9 has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    },{"custom-event":7,"ent/encode":9,"extend":11,"void-elements":13}],9:[function(require,module,exports){
    var punycode = require('punycode');
    var revEntities = require('./reversed.json');
    
    module.exports = encode;
    Severity: Minor
    Found in static/karma.js - About 3 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

    Function 7 has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    },{"custom-event":5,"ent/encode":7,"extend":9,"void-elements":11}],7:[function(require,module,exports){
    var punycode = require('punycode');
    var revEntities = require('./reversed.json');
    
    module.exports = encode;
    Severity: Minor
    Found in static/context.js - About 3 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

    Function ProcessLauncher has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    function ProcessLauncher (spawn, tempDir, timer, processKillTimeout) {
      const self = this
      let onExitCallback
      const killTimeout = processKillTimeout || 2000
      // Will hold output from the spawned child process
    Severity: Minor
    Found in lib/launchers/process.js - About 3 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

    Function stringify has 76 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function stringify (obj, depth) {
      if (depth === 0) {
        return '...'
      }
    
    
    Severity: Major
    Found in static/karma.js - About 3 hrs to fix

      Function createRunnerMiddleware has 76 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function createRunnerMiddleware (emitter, fileList, capturedBrowsers, reporter, executor,
        /* config.protocol */ protocol, /* config.hostname */ hostname, /* config.port */
        port, /* config.urlRoot */ urlRoot, config) {
        helper.saveOriginalArgs(config)
        return function (request, response, next) {
      Severity: Major
      Found in lib/middleware/runner.js - About 3 hrs to fix

        Function stringify has 76 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function stringify (obj, depth) {
          if (depth === 0) {
            return '...'
          }
        
        
        Severity: Major
        Found in static/context.js - About 3 hrs to fix

          Function stringify has 76 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function stringify (obj, depth) {
            if (depth === 0) {
              return '...'
            }
          
          
          Severity: Major
          Found in common/stringify.js - About 3 hrs to fix

            Function constructor has 72 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              constructor (cliOptionsOrConfig, done) {
                super()
                cliOptionsOrConfig = cliOptionsOrConfig || {}
                this.log = logger.create('karma-server')
                done = helper.isFunction(done) ? done : process.exit
            Severity: Major
            Found in lib/server.js - About 2 hrs to fix

              Function encode has 71 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function encode(input) {
                      var n,
                          delta,
                          handledCPCount,
                          basicLength,
              Severity: Major
              Found in static/karma.js - About 2 hrs to fix

                Function encode has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function encode(input) {
                        var n,
                            delta,
                            handledCPCount,
                            basicLength,
                Severity: Major
                Found in static/context.js - About 2 hrs to fix

                  File cli.js has 285 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  'use strict'
                  
                  const path = require('path')
                  const yargs = require('yargs')
                  const fs = require('graceful-fs')
                  Severity: Minor
                  Found in lib/cli.js - About 2 hrs to fix

                    Function 4 has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                    },{"../common/util":6,"./constants":1,"./karma":2,"./updater":4}],4:[function(require,module,exports){
                    var VERSION = require('./constants').VERSION
                    
                    function StatusUpdater (socket, titleElement, bannerElement, browsersElement) {
                      function updateBrowsersInfo (browsers) {
                    Severity: Minor
                    Found in static/karma.js - 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

                    Function 4 has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    },{"../common/util":6,"./constants":1,"./karma":2,"./updater":4}],4:[function(require,module,exports){
                    var VERSION = require('./constants').VERSION
                    
                    function StatusUpdater (socket, titleElement, bannerElement, browsersElement) {
                      function updateBrowsersInfo (browsers) {
                    Severity: Major
                    Found in static/karma.js - About 2 hrs to fix

                      Function run has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function run (cliOptionsOrConfig, done) {
                        cliOptionsOrConfig = cliOptionsOrConfig || {}
                        done = helper.isFunction(done) ? done : process.exit
                      
                        let config
                      Severity: Major
                      Found in lib/runner.js - About 2 hrs to fix

                        Function StatusUpdater has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function StatusUpdater (socket, titleElement, bannerElement, browsersElement) {
                          function updateBrowsersInfo (browsers) {
                            if (!browsersElement) {
                              return
                            }
                        Severity: Major
                        Found in static/karma.js - About 2 hrs to fix

                          Function StatusUpdater has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function StatusUpdater (socket, titleElement, bannerElement, browsersElement) {
                            function updateBrowsersInfo (browsers) {
                              if (!browsersElement) {
                                return
                              }
                          Severity: Major
                          Found in client/updater.js - About 2 hrs to fix

                            Function createServeFile has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function createServeFile (fs, directory, config) {
                              const cache = Object.create(null)
                            
                              return function (filepath, rangeHeader, response, transform, content, doNotCache) {
                                let responseData
                            Severity: Major
                            Found in lib/middleware/common.js - About 2 hrs to fix

                              Function constructor has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                constructor () {
                                  this.LOG_DISABLE = constant.LOG_DISABLE
                                  this.LOG_ERROR = constant.LOG_ERROR
                                  this.LOG_WARN = constant.LOG_WARN
                                  this.LOG_INFO = constant.LOG_INFO
                              Severity: Major
                              Found in lib/config.js - About 2 hrs to fix

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

                                      if (helper.isArray(data.addedFiles)) {
                                        await Promise.all(data.addedFiles.map(async function (filepath) {
                                          await fileList.addFile(path.resolve(config.basePath, filepath))
                                          fullRefresh = false
                                        }))
                                Severity: Major
                                Found in lib/middleware/runner.js and 2 other locations - About 2 hrs to fix
                                lib/middleware/runner.js on lines 66..71
                                lib/middleware/runner.js on lines 80..85

                                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

                                Severity
                                Category
                                Status
                                Source
                                Language