heroku/heroku-pg

View on GitHub

Showing 99 of 99 total issues

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

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

if (!backups.length) {
cli.log(`No backups. Capture one with ${cli.color.cmd('heroku pg:backups:capture')}`)
} else {
cli.table(backups, {
columns: [
Severity: Major
Found in commands/backups/index.js and 1 other location - About 1 day to fix
commands/backups/index.js on lines 63..75

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

if (!restores.length) {
cli.log(`No restores found. Use ${cli.color.cmd('heroku pg:backups:restore')} to restore a backup`)
} else {
cli.table(restores, {
columns: [
Severity: Major
Found in commands/backups/index.js and 1 other location - About 1 day to fix
commands/backups/index.js on lines 44..56

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

if (args.backup_id) {
num = yield pgbackups.transfer.num(args.backup_id)
if (!num) throw new Error(`Invalid Backup: ${args.backup_id}`)
} else {
let transfers = yield heroku.get(`/client/v11/apps/${app}/transfers`, {host})
Severity: Major
Found in commands/backups/download.js and 1 other location - About 1 day to fix
commands/backups/url.js on lines 15..23

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

if (args.backup_id) {
num = yield pgbackups.transfer.num(args.backup_id)
if (!num) throw new Error(`Invalid Backup: ${args.backup_id}`)
} else {
let transfers = yield heroku.get(`/client/v11/apps/${app}/transfers`, {host})
Severity: Major
Found in commands/backups/url.js and 1 other location - About 1 day to fix
commands/backups/download.js on lines 28..36

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

function execPsqlWithFile (file, dbEnv) {
const {spawn} = require('child_process')
return new Promise((resolve, reject) => {
let result = ''
debug('Running sql file: %s', file.trim())
Severity: Major
Found in lib/psql.js and 1 other location - About 5 hrs to fix
lib/psql.js on lines 17..31

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

function execPsql (query, dbEnv) {
const {spawn} = require('child_process')
return new Promise((resolve, reject) => {
let result = ''
debug('Running query: %s', query.trim())
Severity: Major
Found in lib/psql.js and 1 other location - About 5 hrs to fix
lib/psql.js on lines 33..47

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

let dbInfo = yield heroku.request({
host: host(db),
method: 'get',
path: `/client/v11/databases/${db.id}`
}).catch(err => {
Severity: Major
Found in commands/backups/schedule.js and 1 other location - About 4 hrs to fix
commands/backups/capture.js on lines 20..27

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

let dbInfo = yield heroku.request({
host: host(db),
method: 'get',
path: `/client/v11/databases/${db.id}`
}).catch(err => {
Severity: Major
Found in commands/backups/capture.js and 1 other location - About 4 hrs to fix
commands/backups/schedule.js on lines 43..50

Function run has a Cognitive Complexity of 29 (exceeds 5 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: Minor
Found in commands/diagnose.js - About 4 hrs to fix

Function run has a Cognitive Complexity of 29 (exceeds 5 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: Minor
Found in commands/wait.js - About 4 hrs to fix

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

module.exports = heroku => {
function * attachment (app, passedDb, namespace = null) {
let db = passedDb || 'DATABASE_URL'
 
function matchesHelper (app, db) {
Severity: Major
Found in lib/fetcher.js - About 4 hrs to fix

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

    module.exports = {
    topic: 'pg',
    command: 'settings:log-lock-waits',
    description: `Controls whether a log message is produced when a session waits longer than the deadlock_timeout to acquire a lock. deadlock_timeout is set to 1 second`,
    help: `Delays due to lock contention occur when multiple transactions are trying to access the same resource at the same time.
    Severity: Major
    Found in commands/settings/log_lock_waits.js and 2 other locations - About 4 hrs to fix
    commands/settings/log_min_duration_statement.js on lines 16..26
    commands/settings/log_statement.js on lines 10..23

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

    module.exports = {
    topic: 'pg',
    command: 'settings:log-min-duration-statement',
    description: `The duration of each completed statement will be logged if the statement completes after the time specified by VALUE.
    VALUE needs to specified as a whole number, in milliseconds.`,
    Severity: Major
    Found in commands/settings/log_min_duration_statement.js and 2 other locations - About 4 hrs to fix
    commands/settings/log_lock_waits.js on lines 13..23
    commands/settings/log_statement.js on lines 10..23

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

    module.exports = {
    topic: 'pg',
    command: 'settings:log-statement',
    description: `log_statement controls which SQL statements are logged.`,
    help: `Valid values for VALUE:
    Severity: Major
    Found in commands/settings/log_statement.js and 2 other locations - About 4 hrs to fix
    commands/settings/log_lock_waits.js on lines 13..23
    commands/settings/log_min_duration_statement.js on lines 16..26

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

    module.exports = heroku => {
    function * attachment (app, passedDb, namespace = null) {
    let db = passedDb || 'DATABASE_URL'
     
    function matchesHelper (app, db) {
    Severity: Minor
    Found in lib/fetcher.js - About 3 hrs to fix

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

    function * run (context, heroku) {
    const fetcher = require('../lib/fetcher')(heroku)
    const {app, args} = context
    const attachment = yield fetcher.attachment(app, args.database)
    let current
    Severity: Major
    Found in commands/promote.js - About 3 hrs to fix

      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

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

      module.exports = {
      topic: 'pg',
      command: 'ps',
      description: 'view active queries with execution time',
      needsApp: true,
      Severity: Major
      Found in commands/ps.js and 1 other location - About 3 hrs to fix
      commands/credentials.js on lines 51..60

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

      module.exports = {
      topic: 'pg',
      command: 'unfollow',
      description: 'stop a replica from following and make it a writeable database',
      needsApp: true,
      Severity: Major
      Found in commands/unfollow.js and 1 other location - About 3 hrs to fix
      commands/backups/delete.js on lines 22..31
      Severity
      Category
      Status
      Source
      Language