heroku/heroku-pg

View on GitHub
lib/pgbackups.js

Summary

Maintainability
D
2 days
Test Coverage

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

module.exports = (context, heroku) => ({
  filesize: (size, opts = {}) => {
    Object.assign(opts, {
      decimalPlaces: 2,
      fixedDecimals: true
Severity: Minor
Found in lib/pgbackups.js - About 1 day 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 wait has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  wait: (action, transferID, interval, verbose, app) => {
    if (app === undefined) {
      app = context.app
    }
    const wait = require('co-wait')
Severity: Major
Found in lib/pgbackups.js - About 2 hrs to fix

    Function poll has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        let poll = co.wrap(function * () {
          let tty = process.env.TERM !== 'dumb' && process.stderr.isTTY
          let backup
          let failures = 0
    
    
    Severity: Minor
    Found in lib/pgbackups.js - About 1 hr to fix

      Function prefix has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      function prefix (transfer) {
        if (transfer.from_type === 'pg_dump') {
          if (transfer.to_type === 'pg_restore') {
            return 'c'
          } else {
      Severity: Minor
      Found in lib/pgbackups.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

      Avoid too many return statements within this function.
      Open

              return 'Pending'
      Severity: Major
      Found in lib/pgbackups.js - About 30 mins to fix

        There are no issues that match your filters.

        Category
        Status