karma-runner/karma

View on GitHub

Showing 193 of 258 total issues

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

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

          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

            Avoid deeply nested control flow statements.
            Open

                                if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
                                    if (copyIsArray) {
                                        copyIsArray = false;
                                        clone = src && isArray(src) ? src : [];
                                    } else {
            Severity: Major
            Found in static/context.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if (q < t) {
                                          break;
                                      }
              Severity: Major
              Found in static/context.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            if (ele.tagName && ele.tagName.toLowerCase() === 'script') {
                              var tmp = ele
                              ele = document.createElement('script')
                              ele.src = policy.createScriptURL(tmp.src)
                              ele.crossOrigin = tmp.crossOrigin
                Severity: Major
                Found in client/karma.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                          for (var key in obj) {
                            if (Object.prototype.hasOwnProperty.call(obj, key)) {
                              if (first) {
                                first = false
                              } else {
                  Severity: Major
                  Found in common/stringify.js - About 45 mins to fix

                    Function createProxyHandler has a Cognitive Complexity of 8 (exceeds 5 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 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

                    Avoid deeply nested control flow statements.
                    Open

                                        if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
                                            if (copyIsArray) {
                                                copyIsArray = false;
                                                clone = src && isArray(src) ? src : [];
                                            } else {
                    Severity: Major
                    Found in static/karma.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                              if (obj.constructor && typeof obj.constructor === 'function') {
                                constructor = obj.constructor.name
                              }
                      Severity: Major
                      Found in common/stringify.js - About 45 mins to fix

                        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

                        Avoid deeply nested control flow statements.
                        Open

                                    if (ele.tagName && ele.tagName.toLowerCase() === 'script') {
                                      var tmp = ele
                                      ele = document.createElement('script')
                                      ele.src = policy.createScriptURL(tmp.src)
                                      ele.crossOrigin = tmp.crossOrigin
                        Severity: Major
                        Found in static/karma.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                  if (obj.constructor && typeof obj.constructor === 'function') {
                                    constructor = obj.constructor.name
                                  }
                          Severity: Major
                          Found in static/karma.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                    for (var key in obj) {
                                      if (Object.prototype.hasOwnProperty.call(obj, key)) {
                                        if (first) {
                                          first = false
                                        } else {
                            Severity: Major
                            Found in static/karma.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                      for (var key in obj) {
                                        if (Object.prototype.hasOwnProperty.call(obj, key)) {
                                          if (first) {
                                            first = false
                                          } else {
                              Severity: Major
                              Found in static/context.js - About 45 mins to fix

                                Function constructor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  constructor (cliOptionsOrConfig, done) {
                                    super()
                                    cliOptionsOrConfig = cliOptionsOrConfig || {}
                                    this.log = logger.create('karma-server')
                                    done = helper.isFunction(done) ? done : process.exit
                                Severity: Minor
                                Found in lib/server.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