karma-runner/karma

View on GitHub

Showing 258 of 258 total issues

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

    processWrapper.on('unhandledRejection', (error) => {
      this.log.error(`UnhandledRejection: ${error.stack || error.message || String(error)}`)
      reportError(error)
    })
Severity: Major
Found in lib/server.js and 1 other location - About 1 hr to fix
lib/server.js on lines 404..407

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

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

    processWrapper.on('uncaughtException', (error) => {
      this.log.error(`UncaughtException: ${error.stack || error.message || String(error)}`)
      reportError(error)
    })
Severity: Major
Found in lib/server.js and 1 other location - About 1 hr to fix
lib/server.js on lines 399..402

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

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 ProgressReporter has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function ProgressReporter (formatError, reportSlow, useColors, browserConsoleLogOptions) {
  BaseReporter.call(this, formatError, reportSlow, useColors, browserConsoleLogOptions)

  this.EXCLUSIVELY_USE_COLORS = false
  this._browsers = []
Severity: Minor
Found in lib/reporters/progress.js - About 1 hr to fix

    Function createReporters has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function createReporters (names, config, emitter, injector) {
      const errorFormatter = createErrorFormatter(config, emitter, SourceMapConsumer)
      const reporters = []
    
      names.forEach((name) => {
    Severity: Minor
    Found in lib/reporter.js - About 1 hr to fix

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

      var socket = io(location.host, {
        reconnectionDelay: 500,
        reconnectionDelayMax: Infinity,
        timeout: BROWSER_SOCKET_TIMEOUT,
        path: KARMA_PROXY_PATH + KARMA_URL_ROOT.slice(1) + 'socket.io',
      Severity: Major
      Found in static/karma.js and 1 other location - About 1 hr to fix
      client/main.js on lines 14..21

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

      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

      var socket = io(location.host, {
        reconnectionDelay: 500,
        reconnectionDelayMax: Infinity,
        timeout: BROWSER_SOCKET_TIMEOUT,
        path: KARMA_PROXY_PATH + KARMA_URL_ROOT.slice(1) + 'socket.io',
      Severity: Major
      Found in client/main.js and 1 other location - About 1 hr to fix
      static/karma.js on lines 350..357

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

      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 createPriorityPreprocessor has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      function createPriorityPreprocessor (config = {}, preprocessorPriority, basePath, instantiatePlugin) {
        _.union.apply(_, Object.values(config)).forEach((name) => instantiatePlugin('preprocessor', name))
        return async function preprocess (file) {
          const buffer = await tryToRead(file.originalPath, log)
          let isBinary = file.isBinary
      Severity: Minor
      Found in lib/preprocessor.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 navigateContextTo has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function navigateContextTo (url) {
          if (self.config.useIframe === false) {
            // run in new window
            if (self.config.runInParent === false) {
              // If there is a window already open, then close it
      Severity: Minor
      Found in client/karma.js - About 1 hr to fix

        Function navigateContextTo has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function navigateContextTo (url) {
            if (self.config.useIframe === false) {
              // run in new window
              if (self.config.runInParent === false) {
                // If there is a window already open, then close it
        Severity: Minor
        Found in static/karma.js - About 1 hr to fix

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

          exports.run = async () => {
            const cliOptions = exports.process()
            const cmd = cliOptions.cmd // prevent config from changing the command
            const cmdNeedsConfig = cmd === 'start' || cmd === 'run' || cmd === 'stop'
            if (cmdNeedsConfig) {
          Severity: Minor
          Found in lib/cli.js - About 1 hr to fix

            Function extend has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function extend() {
                var options, name, src, copy, copyIsArray, clone;
                var target = arguments[0];
                var i = 1;
                var length = arguments.length;
            Severity: Minor
            Found in static/karma.js - About 1 hr to fix

              Function extend has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports = function extend() {
                  var options, name, src, copy, copyIsArray, clone;
                  var target = arguments[0];
                  var i = 1;
                  var length = arguments.length;
              Severity: Minor
              Found in static/context.js - About 1 hr to fix

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

                  async _start (config, launcher, preprocess, fileList, capturedBrowsers, executor, done) {
                    if (config.detached) {
                      this._detach(config, done)
                      return
                    }
                Severity: Minor
                Found in lib/server.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 7 has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                },{}],7:[function(require,module,exports){
                (function (global){
                
                var NativeCustomEvent = global.CustomEvent;
                
                
                Severity: Minor
                Found in static/karma.js - About 1 hr to fix

                  Function 5 has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  },{"./karma":3}],5:[function(require,module,exports){
                  (function (global){
                  
                  var NativeCustomEvent = global.CustomEvent;
                  
                  
                  Severity: Minor
                  Found in static/context.js - About 1 hr to fix

                    Function onLine has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      onLine (line) {
                        if (currentQuestionId) {
                          this.rli.write(this.colors.RESET)
                          line = line.trim().replace(this.colors.ANSWER, '').replace(this.colors.RESET, '')
                    
                    
                    Severity: Minor
                    Found in lib/init/state_machine.js - About 1 hr to fix

                      Function 7 has 34 lines of code (exceeds 25 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 1 hr to fix

                        Function 9 has 34 lines of code (exceeds 25 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 1 hr to fix

                          Function _close has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            _close (exitCode) {
                              const webServer = this._injector.get('webServer')
                              const socketServer = this._injector.get('socketServer')
                              const done = this._injector.get('done')
                          
                          
                          Severity: Minor
                          Found in lib/server.js - About 1 hr to fix

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

                            ContextKarma.getPostMessageCallParentKarmaMethod = function (parentWindow) {
                              return function postMessageCallParentKarmaMethod (method, args) {
                                parentWindow.postMessage({ __karmaMethod: method, __karmaArguments: args }, window.location.origin)
                              }
                            }
                            Severity: Major
                            Found in context/karma.js and 1 other location - About 1 hr to fix
                            static/context.js on lines 291..295

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

                            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