karma-runner/karma

View on GitHub

Showing 193 of 258 total issues

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

function describeStart (yargs) {
  yargs
    .usage('Karma - Spectacular Test Runner for JavaScript.\n\n' +
      'START - Start the server / do a single run.\n\n' +
      'Usage:\n' +
Severity: Minor
Found in lib/cli.js - About 1 hr to fix

    Function createRunnerMiddleware has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    function createRunnerMiddleware (emitter, fileList, capturedBrowsers, reporter, executor,
      /* config.protocol */ protocol, /* config.hostname */ hostname, /* config.port */
      port, /* config.urlRoot */ urlRoot, config) {
    Severity: Major
    Found in lib/middleware/runner.js - About 1 hr to fix

      Function factory has 10 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        id, fullName, /* capturedBrowsers */ collection, emitter, socket, timer,
        /* config.browserDisconnectTimeout */ disconnectDelay,
        /* config.browserNoActivityTimeout */ noActivityTimeout,
        /* config.singleRun */ singleRun,
        /* config.client */ clientConfig) {
      Severity: Major
      Found in lib/browser.js - About 1 hr to fix

        Function complete has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        function complete (env) {
          if (env.count === 1) {
            return sendCompletion(env.words[0].startsWith('-') ? ['--help', '--version'] : Object.keys(options), env)
          } else if (env.count === 2 && !env.words[1].startsWith('-')) {
            return sendCompletionFiles(env)
        Severity: Minor
        Found in lib/completion.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 DotsReporter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        function DotsReporter (formatError, reportSlow, useColors, browserConsoleLogOptions) {
          BaseReporter.call(this, formatError, reportSlow, useColors, browserConsoleLogOptions)
        
          const DOTS_WRAP = 80
          this.EXCLUSIVELY_USE_COLORS = false
        Severity: Minor
        Found in lib/reporters/dots.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 createSourceFilesMiddleware has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function createSourceFilesMiddleware (filesPromise, serveFile, basePath, urlRoot) {
          return function (request, response, next) {
            const requestedFilePath = composeUrl(request.url, basePath, urlRoot)
            // When a path contains HTML-encoded characters (e.g %2F used by Jenkins for branches with /)
            const requestedFilePathUnescaped = composeUrl(querystring.unescape(request.url), basePath, urlRoot)
        Severity: Minor
        Found in lib/middleware/source_files.js - About 1 hr to fix

          Function init has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.init = function (config) {
            logger.setupFromConfig(config)
          
            const colorScheme = !helper.isDefined(config.colors) || config.colors ? COLOR_SCHEME.ON : COLOR_SCHEME.OFF
            // need to be registered before creating readlineInterface
          Severity: Minor
          Found in lib/init.js - About 1 hr to fix

            Function files has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              get files () {
                const served = []
                const included = {}
                const lookup = {}
                this._patterns.forEach((p) => {
            Severity: Minor
            Found in lib/file-list.js - About 1 hr to fix

              Function describeRun has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function describeRun (yargs) {
                yargs
                  .usage('Karma - Spectacular Test Runner for JavaScript.\n\n' +
                    'RUN - Run the tests (requires running server).\n\n' +
                    'Usage:\n' +
              Severity: Minor
              Found in lib/cli.js - About 1 hr to fix

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

                  this.complete = function (result) {
                    if (resultsBuffer.length) {
                      socket.emit('result', resultsBuffer)
                      resultsBuffer = []
                    }
                Severity: Minor
                Found in static/karma.js - About 1 hr to fix

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

                    this.complete = function (result) {
                      if (resultsBuffer.length) {
                        socket.emit('result', resultsBuffer)
                        resultsBuffer = []
                      }
                  Severity: Minor
                  Found in client/karma.js - About 1 hr to fix

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

                    function encode (str, opts) {
                        if (typeof str !== 'string') {
                            throw new TypeError('Expected a String');
                        }
                        if (!opts) opts = {};
                    Severity: Minor
                    Found in static/karma.js - About 1 hr to fix

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

                      function encode (str, opts) {
                          if (typeof str !== 'string') {
                              throw new TypeError('Expected a String');
                          }
                          if (!opts) opts = {};
                      Severity: Minor
                      Found in static/context.js - About 1 hr to fix

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

                          this._execCommand = function (cmd, args) {
                            if (!cmd) {
                              log.error(`No binary for ${self.name} browser on your platform.\n  Please, set "${self.ENV_CMD}" env variable.`)
                        
                              // disable restarting
                        Severity: Minor
                        Found in lib/launchers/process.js - About 1 hr to fix

                          Function createProxyHandler has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function createProxyHandler (proxies, urlRoot) {
                            if (!proxies.length) {
                              const nullProxy = (request, response, next) => next()
                              nullProxy.upgrade = () => {}
                              return nullProxy
                          Severity: Minor
                          Found in lib/middleware/proxy.js - About 1 hr to fix

                            Function createPriorityPreprocessor has 28 lines of code (exceeds 25 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

                              Function createInstantiatePlugin has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                              function createInstantiatePlugin (injector) {
                                const emitter = injector.get('emitter')
                                // Cache to avoid report errors multiple times per plugin.
                                const pluginInstances = new Map()
                                return function instantiatePlugin (kind, name) {
                              Severity: Minor
                              Found in lib/plugin.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 parser has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                              const parser = (pattern, out) => {
                                if (pattern.length === 0) return out
                                const p = /^(\[[^\]]*\]|[*+@?]\((.+?)\))/g
                                const matches = p.exec(pattern)
                                if (!matches) {
                              Severity: Minor
                              Found in lib/helper.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 result has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                this.result = function (originalResult) {
                                  var convertedResult = {}
                              
                                  // Convert all array-like objects to real arrays.
                                  for (var propertyName in originalResult) {
                              Severity: Minor
                              Found in static/karma.js - About 1 hr to fix

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

                                  this.result = function (originalResult) {
                                    var convertedResult = {}
                                
                                    // Convert all array-like objects to real arrays.
                                    for (var propertyName in originalResult) {
                                Severity: Minor
                                Found in client/karma.js - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language