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: 'credentials',
description: 'show information on credentials in the database',
needsApp: true,
Severity: Major
Found in commands/credentials.js and 1 other location - About 3 hrs to fix
commands/ps.js on lines 52..61

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

    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

    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

    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

    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

      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

      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

      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

      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

      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

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

        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

        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

        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

        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