heroku/heroku-pg

View on GitHub

Showing 99 of 99 total issues

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

module.exports = {
  topic: 'pg',
  command: 'backups:delete',
  description: 'delete a backup',
  needsApp: true,
Severity: Major
Found in commands/backups/delete.js and 1 other location - About 3 hrs to fix
commands/unfollow.js on lines 27..36

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

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 list has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function * list (context, heroku) {
  const pgbackups = require('../../lib/pgbackups')(context, heroku)
  const {sortBy} = require('lodash')
  const host = require('../../lib/host')()
  const app = context.app
Severity: Major
Found in commands/backups/index.js - About 2 hrs to fix

    Function run has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    function * run (context, heroku) {
      const pgbackups = require('../../lib/pgbackups')(context, heroku)
      const fetcher = require('../../lib/fetcher')(heroku)
      const host = require('../../lib/host')
      const {sortBy} = require('lodash')
    Severity: Minor
    Found in commands/backups/restore.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

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

        yield cli.action(`Taking snapshot of ${cli.color.addon(db.name)}`, co(function * () {
          yield heroku.post(`/postgres/v0/databases/${db.id}/snapshots`, {host: host(db)})
        }))
    Severity: Major
    Found in commands/backups/capture.js and 2 other locations - About 2 hrs to fix
    commands/reset.js on lines 16..18
    commands/unfollow.js on lines 22..24

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

    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

      yield cli.action(`${cli.color.addon(db.name)} unfollowing`, co(function * () {
        yield heroku.put(`/client/v11/databases/${db.id}/unfollow`, {host: host(db)})
      }))
    Severity: Major
    Found in commands/unfollow.js and 2 other locations - About 2 hrs to fix
    commands/backups/capture.js on lines 16..18
    commands/reset.js on lines 16..18

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

    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

      yield cli.action(`Resetting ${cli.color.addon(db.name)}`, co(function * () {
        yield heroku.put(`/client/v11/databases/${db.id}/reset`, {host: host(db)})
      }))
    Severity: Major
    Found in commands/reset.js and 2 other locations - About 2 hrs to fix
    commands/backups/capture.js on lines 16..18
    commands/unfollow.js on lines 22..24

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

    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 run has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    async function run (context, heroku) {
      const debug = require('debug')('heroku-pg')
      const fetcher = require('../lib/fetcher')(heroku)
      const host = require('../lib/host')
      const app = context.app
    Severity: Major
    Found in commands/wait.js - About 2 hrs to fix

      Function run has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      function * run (context, heroku) {
        const url = require('url')
        const host = require('../lib/host')
        const pgbackups = require('../lib/pgbackups')(context, heroku)
        const fetcher = require('../lib/fetcher')(heroku)
      Severity: Minor
      Found in commands/copy.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

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

      module.exports = {
        topic: 'pg',
        command: 'backups:info',
        description: 'get information about a specific backup',
        needsApp: true,
      Severity: Major
      Found in commands/backups/info.js and 6 other locations - About 2 hrs to fix
      commands/backups/cancel.js on lines 28..36
      commands/backups/unschedule.js on lines 34..44
      commands/killall.js on lines 16..24
      commands/links/index.js on lines 39..47
      commands/maintenance/index.js on lines 18..26
      commands/settings/index.js on lines 26..34

      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 7 locations. Consider refactoring.
      Open

      module.exports = {
        topic: 'pg',
        command: 'settings',
        description: 'show your current database settings',
        needsApp: true,
      Severity: Major
      Found in commands/settings/index.js and 6 other locations - About 2 hrs to fix
      commands/backups/cancel.js on lines 28..36
      commands/backups/info.js on lines 73..81
      commands/backups/unschedule.js on lines 34..44
      commands/killall.js on lines 16..24
      commands/links/index.js on lines 39..47
      commands/maintenance/index.js on lines 18..26

      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 7 locations. Consider refactoring.
      Open

      module.exports = {
        topic: 'pg',
        command: 'maintenance',
        description: 'show current maintenance information',
        needsApp: true,
      Severity: Major
      Found in commands/maintenance/index.js and 6 other locations - About 2 hrs to fix
      commands/backups/cancel.js on lines 28..36
      commands/backups/info.js on lines 73..81
      commands/backups/unschedule.js on lines 34..44
      commands/killall.js on lines 16..24
      commands/links/index.js on lines 39..47
      commands/settings/index.js on lines 26..34

      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 7 locations. Consider refactoring.
      Open

      module.exports = {
        topic: 'pg',
        command: 'backups:cancel',
        description: 'cancel an in-progress backup or restore (default newest)',
        needsApp: true,
      Severity: Major
      Found in commands/backups/cancel.js and 6 other locations - About 2 hrs to fix
      commands/backups/info.js on lines 73..81
      commands/backups/unschedule.js on lines 34..44
      commands/killall.js on lines 16..24
      commands/links/index.js on lines 39..47
      commands/maintenance/index.js on lines 18..26
      commands/settings/index.js on lines 26..34

      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

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

          if (dbInfo) {
            let dbProtected = /On/.test(dbInfo.info.find(attribute => attribute.name === 'Continuous Protection').values[0])
            if (dbProtected) {
              cli.warn('Continuous protection is already enabled for this database. Logical backups of large databases are likely to fail.')
              cli.warn('See https://devcenter.heroku.com/articles/heroku-postgres-data-safety-and-continuous-protection#physical-backups-on-heroku-postgres.')
      Severity: Major
      Found in commands/backups/capture.js and 1 other location - About 2 hrs to fix
      commands/backups/schedule.js on lines 52..58

      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

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

        if (dbInfo) {
          let dbProtected = /On/.test(dbInfo.info.find(attribute => attribute.name === 'Continuous Protection').values[0])
          if (dbProtected) {
            cli.warn('Continuous protection is already enabled for this database. Logical backups of large databases are likely to fail.')
            cli.warn('See https://devcenter.heroku.com/articles/heroku-postgres-data-safety-and-continuous-protection#physical-backups-on-heroku-postgres.')
      Severity: Major
      Found in commands/backups/schedule.js and 1 other location - About 2 hrs to fix
      commands/backups/capture.js on lines 28..34

      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 7 locations. Consider refactoring.
      Open

      module.exports = {
        topic: 'pg',
        command: 'killall',
        description: 'terminates all connections for all credentials',
        needsApp: true,
      Severity: Major
      Found in commands/killall.js and 6 other locations - About 2 hrs to fix
      commands/backups/cancel.js on lines 28..36
      commands/backups/info.js on lines 73..81
      commands/backups/unschedule.js on lines 34..44
      commands/links/index.js on lines 39..47
      commands/maintenance/index.js on lines 18..26
      commands/settings/index.js on lines 26..34

      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

      Function run has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function * run (context, heroku) {
        const url = require('url')
        const host = require('../lib/host')
        const pgbackups = require('../lib/pgbackups')(context, heroku)
        const fetcher = require('../lib/fetcher')(heroku)
      Severity: Major
      Found in commands/copy.js - About 2 hrs to fix

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

        module.exports = {
          topic: 'pg',
          command: 'links',
          description: 'lists all databases and information on link',
          needsApp: true,
        Severity: Major
        Found in commands/links/index.js and 6 other locations - About 2 hrs to fix
        commands/backups/cancel.js on lines 28..36
        commands/backups/info.js on lines 73..81
        commands/backups/unschedule.js on lines 34..44
        commands/killall.js on lines 16..24
        commands/maintenance/index.js on lines 18..26
        commands/settings/index.js on lines 26..34

        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 7 locations. Consider refactoring.
        Open

        module.exports = {
          topic: 'pg',
          command: 'backups:unschedule',
          description: 'stop daily backups',
          needsApp: true,
        Severity: Major
        Found in commands/backups/unschedule.js and 6 other locations - About 2 hrs to fix
        commands/backups/cancel.js on lines 28..36
        commands/backups/info.js on lines 73..81
        commands/killall.js on lines 16..24
        commands/links/index.js on lines 39..47
        commands/maintenance/index.js on lines 18..26
        commands/settings/index.js on lines 26..34

        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

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

        function * run (context, heroku) {
          const fetcher = require('../lib/fetcher')(heroku)
          const host = require('../lib/host')
          const util = require('../lib/util')
          const {app, args} = context
        Severity: Major
        Found in commands/diagnose.js - About 2 hrs to fix

          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
            Severity
            Category
            Status
            Source
            Language