karma-runner/karma

View on GitHub

Showing 258 of 258 total issues

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

      if (helper.isArray(data.removedFiles)) {
        await Promise.all(data.removedFiles.map(async function (filepath) {
          await fileList.removeFile(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 73..78

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

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

      if (helper.isArray(data.changedFiles)) {
        await Promise.all(data.changedFiles.map(async function (filepath) {
          await fileList.changeFile(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 73..78
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

Browser has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

class Browser {
  constructor (id, fullName, collection, emitter, socket, timer, disconnectDelay,
    noActivityTimeout, singleRun, clientConfig) {
    this.id = id
    this.fullName = fullName
Severity: Minor
Found in lib/browser.js - About 2 hrs to fix

    Function createErrorFormatter has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function createErrorFormatter (config, emitter, SourceMapConsumer) {
      const basePath = config.basePath
      const urlRoot = config.urlRoot === '/' ? '' : (config.urlRoot || '')
      let lastServedFiles = []
    
    
    Severity: Major
    Found in lib/reporter.js - About 2 hrs to fix

      Function serialize has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function serialize (node, context, fn, eventTarget) {
        if (!node) return '';
        if ('function' === typeof context) {
          fn = context;
          context = null;
      Severity: Major
      Found in static/karma.js - About 2 hrs to fix

        Function serialize has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function serialize (node, context, fn, eventTarget) {
          if (!node) return '';
          if ('function' === typeof context) {
            fn = context;
            context = null;
        Severity: Major
        Found in static/context.js - About 2 hrs to fix

          Function parseProxyConfig has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function parseProxyConfig (proxies, config) {
            proxies = proxies || []
            return _.sortBy(_.map(proxies, function (proxyConfiguration, proxyPath) {
              if (typeof proxyConfiguration === 'string') {
                proxyConfiguration = { target: proxyConfiguration }
          Severity: Major
          Found in lib/middleware/proxy.js - About 2 hrs to fix

            Function setupContext has 55 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              this.setupContext = function (contextWindow) {
                // If we clear the context after every run and we already had an error
                //   then stop now. Otherwise, carry on.
                if (self.config.clearContext && hasError) {
                  return
            Severity: Major
            Found in static/context.js - About 2 hrs to fix

              Function setupContext has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                this.setupContext = function (contextWindow) {
                  // If we clear the context after every run and we already had an error
                  //   then stop now. Otherwise, carry on.
                  if (self.config.clearContext && hasError) {
                    return
              Severity: Major
              Found in context/karma.js - About 2 hrs to fix

                Function stop has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                exports.stop = function (cliOptionsOrConfig, done) {
                  cliOptionsOrConfig = cliOptionsOrConfig || {}
                  const log = logger.create('stopper')
                  done = helper.isFunction(done) ? done : process.exit
                
                
                Severity: Major
                Found in lib/stopper.js - About 2 hrs to fix

                  Function decode has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      function decode(input) {
                          // Don't use UCS-2
                          var output = [],
                              inputLength = input.length,
                              out,
                  Severity: Major
                  Found in static/karma.js - About 2 hrs to fix

                    Function decode has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function decode(input) {
                            // Don't use UCS-2
                            var output = [],
                                inputLength = input.length,
                                out,
                    Severity: Major
                    Found in static/context.js - About 2 hrs to fix

                      Function BaseLauncher has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function BaseLauncher (id, emitter) {
                        if (this.start) {
                          return
                        }
                      
                      
                      Severity: Minor
                      Found in lib/launchers/base.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 exports has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      module.exports = function (wallaby) {
                        return {
                          files: [
                            {
                              pattern: 'package.json',
                      Severity: Major
                      Found in wallaby.js - About 2 hrs to fix

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

                        exports.restoreOriginalArgs = (config) => {
                          if (config && config.client && config.client.originalArgs) {
                            config.client.args = _.cloneDeep(config.client.originalArgs)
                          }
                        }
                        Severity: Major
                        Found in lib/helper.js and 1 other location - About 2 hrs to fix
                        lib/helper.js on lines 161..165

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

                        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

                        exports.saveOriginalArgs = (config) => {
                          if (config && config.client && config.client.args) {
                            config.client.originalArgs = _.cloneDeep(config.client.args)
                          }
                        }
                        Severity: Major
                        Found in lib/helper.js and 1 other location - About 2 hrs to fix
                        lib/helper.js on lines 167..171

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

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

                        function StatusUpdater (socket, titleElement, bannerElement, browsersElement) {
                          function updateBrowsersInfo (browsers) {
                            if (!browsersElement) {
                              return
                            }
                        Severity: Minor
                        Found in client/updater.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 launchSingle has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          launchSingle (protocol, hostname, port, urlRoot, upstreamProxy, processKillTimeout) {
                            if (upstreamProxy) {
                              protocol = upstreamProxy.protocol
                              hostname = upstreamProxy.hostname
                              port = upstreamProxy.port
                        Severity: Minor
                        Found in lib/launcher.js - About 1 hr to fix

                          Function _refresh has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            _refresh () {
                              const matchedFiles = new Set()
                          
                              let lastCompletedRefresh = this._refreshing
                              lastCompletedRefresh = Promise.all(
                          Severity: Minor
                          Found in lib/file-list.js - About 1 hr to fix

                            Function resolve has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function resolve (plugins, emitter) {
                              const modules = []
                            
                              function requirePlugin (name) {
                                log.debug(`Loading plugin ${name}.`)
                            Severity: Minor
                            Found in lib/plugin.js - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language