Showing 30 of 123 total issues

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

module.exports = function responseStatus (opts) {
  opts = parseOptions(opts)

  const lower = +opts.lower
  const higher = +opts.higher
Severity: Minor
Found in lib/rules/response-status.js - About 1 hr to fix

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

    module.exports = function eachSeries (arr, iterator, cb) {
      cb = cb || function () {}
      if (!Array.isArray(arr) || !arr.length) return cb()
    
      const stack = arr.slice()
    Severity: Minor
    Found in lib/helpers/each-series.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 handler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    Directive.prototype.handler = function () {
      const self = this
    
      function handler (req, res, next) {
        if (self.enabled === false) return next()
    Severity: Minor
    Found in lib/directive.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

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

    module.exports = function (req, res, next) {
      if (req.method === 'GET' || req.method === 'DELETE') return next()
    
      if (isInvalidType(req)) {
        res.statusCode = 415
    Severity: Minor
    Found in lib/admin/middleware/body.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 next(null, !inRange(range, status))
    Severity: Major
    Found in lib/rules/response-status.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            return next(null, !~include.indexOf(status))
      Severity: Major
      Found in lib/rules/response-status.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return false
        Severity: Major
        Found in lib/helpers/match-headers.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return next(null, !(status > higher))
          Severity: Major
          Found in lib/rules/response-status.js - About 30 mins to fix

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

            module.exports = function rateLimit (opts) {
              opts = opts || {}
            
              const code = +opts.code || 429
              const limit = +opts.limit || 10
            Severity: Minor
            Found in lib/poisons/rate-limit.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 responseBody has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports = function responseBody (opts) {
              opts = opts || {}
            
              const match = opts.match
              const encoding = opts.encoding || 'utf8'
            Severity: Minor
            Found in lib/rules/response-body.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