mjackson/expect

View on GitHub

Showing 12 of 79 total issues

File Expectation.js has 432 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import has from 'has'
import tmatch from 'tmatch'
import assert from './assert'
import { isSpy } from './SpyUtils'
import {
Severity: Minor
Found in modules/Expectation.js - About 6 hrs to fix

    Function exports has 91 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = (config) => {
      const customLaunchers = {
        BS_Chrome: {
          base: 'BrowserStack',
          os: 'Windows',
    Severity: Major
    Found in karma.conf.js - About 3 hrs to fix

      Expectation has 26 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Expectation {
        constructor(actual) {
          this.actual = actual
      
          if (isFunction(actual)) {
      Severity: Minor
      Found in modules/Expectation.js - About 3 hrs to fix

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

        export const functionThrows = (fn, context, args, value) => {
          try {
            fn.apply(context, args)
          } catch (error) {
            if (value == null)
        Severity: Minor
        Found in modules/TestUtils.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 createSpy has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const createSpy = (fn, restore = noop) => {
          if (fn == null)
            fn = noop
        
          assert(
        Severity: Major
        Found in modules/SpyUtils.js - About 2 hrs to fix

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

            toInclude(value, compareValues, message) {
              if (typeof compareValues === 'string') {
                message = compareValues
                compareValues = null
              }
          Severity: Minor
          Found in modules/Expectation.js - About 1 hr to fix

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

              toExclude(value, compareValues, message) {
                if (typeof compareValues === 'string') {
                  message = compareValues
                  compareValues = null
                }
            Severity: Minor
            Found in modules/Expectation.js - About 1 hr to fix

              Function createSpy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              export const createSpy = (fn, restore = noop) => {
                if (fn == null)
                  fn = noop
              
                assert(
              Severity: Minor
              Found in modules/SpyUtils.js - About 35 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 too many return statements within this function.
              Open

                return false
              Severity: Major
              Found in modules/TestUtils.js - About 30 mins to fix

                Function extend has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function extend(extension) {
                  if (Extensions.indexOf(extension) === -1) {
                    Extensions.push(extension)
                
                    for (const p in extension)
                Severity: Minor
                Found in modules/extend.js - About 25 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 toExclude has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  toExclude(value, compareValues, message) {
                    if (typeof compareValues === 'string') {
                      message = compareValues
                      compareValues = null
                    }
                Severity: Minor
                Found in modules/Expectation.js - About 25 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 toInclude has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  toInclude(value, compareValues, message) {
                    if (typeof compareValues === 'string') {
                      message = compareValues
                      compareValues = null
                    }
                Severity: Minor
                Found in modules/Expectation.js - About 25 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