karma-runner/karma

View on GitHub

Showing 258 of 258 total issues

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

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

          function processAnswers (answers, basePath, testMainFile) {
            const processedAnswers = {
              basePath: basePath,
              files: answers.files,
              onlyServedFiles: [],
          Severity: Minor
          Found in lib/init.js - About 1 hr to fix

            Function createKarmaMiddleware has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              filesPromise,
              serveStaticFile,
              serveFile,
              injector,
              basePath,
            Severity: Major
            Found in lib/middleware/karma.js - About 1 hr to fix

              Function msg has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  let msg = input.replace(URL_REGEXP, function (stackTracePath, prefix, path, __, ___, line, ____, column) {
              Severity: Major
              Found in lib/reporter.js - About 1 hr to fix

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

                    if (self.state === self.STATE_CAPTURED) {
                      log.error(`${self.name} crashed.\n\t${errorOutput}`)
                      error = 'crashed'
                    }
                Severity: Minor
                Found in lib/launchers/process.js and 1 other location - About 55 mins to fix
                lib/launchers/process.js on lines 113..116

                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

                    if (self.state === self.STATE_BEING_CAPTURED) {
                      log.error(`Cannot start ${self.name}\n\t${errorOutput}`)
                      error = 'cannot start'
                    }
                Severity: Minor
                Found in lib/launchers/process.js and 1 other location - About 55 mins to fix
                lib/launchers/process.js on lines 118..121

                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

                function normalizeUrlRoot (urlRoot) {
                  const normalizedUrlRoot = normalizeUrl(urlRoot)
                
                  if (normalizedUrlRoot !== urlRoot) {
                    log.warn(`urlRoot normalized to "${normalizedUrlRoot}"`)
                Severity: Minor
                Found in lib/config.js and 1 other location - About 55 mins to fix
                lib/config.js on lines 95..103

                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

                function normalizeProxyPath (proxyPath) {
                  const normalizedProxyPath = normalizeUrl(proxyPath)
                
                  if (normalizedProxyPath !== proxyPath) {
                    log.warn(`proxyPath normalized to "${normalizedProxyPath}"`)
                Severity: Minor
                Found in lib/config.js and 1 other location - About 55 mins to fix
                lib/config.js on lines 85..93

                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

                Function run has a Cognitive Complexity of 9 (exceeds 5 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 55 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

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

                function createPatternObject (pattern) {
                  if (pattern && helper.isString(pattern)) {
                    return helper.isUrlAbsolute(pattern)
                      ? new UrlPattern(pattern)
                      : new Pattern(pattern)
                Severity: Minor
                Found in lib/config.js - About 55 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

                Function Karma has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function Karma (updater, socket, iframe, opener, navigator, location, document) {
                Severity: Major
                Found in static/karma.js - About 50 mins to fix

                  Function Karma has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  function Karma (updater, socket, iframe, opener, navigator, location, document) {
                  Severity: Major
                  Found in client/karma.js - About 50 mins to fix

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

                    function ProgressColorReporter (formatError, reportSlow, useColors, browserConsoleLogOptions) {
                      ProgressReporter.call(this, formatError, reportSlow, useColors, browserConsoleLogOptions)
                      BaseColorReporter.call(this)
                      this.EXCLUSIVELY_USE_COLORS = true
                    }
                    Severity: Minor
                    Found in lib/reporters/progress_color.js and 1 other location - About 50 mins to fix
                    lib/reporters/dots_color.js on lines 4..8

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

                    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

                    function DotsColorReporter (formatError, reportSlow, useColors, browserConsoleLogOptions) {
                      DotsReporter.call(this, formatError, reportSlow, useColors, browserConsoleLogOptions)
                      BaseColorReporter.call(this)
                      this.EXCLUSIVELY_USE_COLORS = true
                    }
                    Severity: Minor
                    Found in lib/reporters/dots_color.js and 1 other location - About 50 mins to fix
                    lib/reporters/progress_color.js on lines 4..8

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

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

                      reconnect (newSocket, clientSaysReconnect) {
                        if (!clientSaysReconnect || this.state === DISCONNECTED) {
                          this.log.info(`Disconnected browser returned on socket ${newSocket.id} with id ${this.id}.`)
                          this.setState(CONNECTED)
                    
                    
                    Severity: Minor
                    Found in lib/browser.js - About 45 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