heroku/heroku-pg

View on GitHub

Showing 99 of 99 total issues

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

  Object.assign({
    command: 'pull',
    description: 'pull Heroku database into local or remote database',
    help: `Pull from SOURCE into TARGET.

Severity: Major
Found in commands/pull.js and 1 other location - About 1 hr to fix
commands/pull.js on lines 187..206

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

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

function * run (context, heroku) {
  const host = require('../../lib/host')
  const fetcher = require('../../lib/fetcher')(heroku)

  const {app, args, flags} = context
Severity: Minor
Found in commands/backups/schedule.js - About 1 hr to fix

    Function download has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function download (url, path, opts) {
      const progress = require('smooth-progress')
      const bytes = require('bytes')
      const https = require('https')
      const fs = require('fs')
    Severity: Minor
    Found in lib/download.js - About 1 hr to fix

      Function run has a Cognitive Complexity of 10 (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')
      
      
      Severity: Minor
      Found in commands/backups/capture.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

      Function configVarNamesFromValue has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.configVarNamesFromValue = (config, value) => {
        let keys = []
        for (let key of Object.keys(config)) {
          let configVal = config[key]
          if (configVal === value) {
      Severity: Minor
      Found in lib/util.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

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

        let displayReport = report => {
          cli.log(`Report ${report.id} for ${report.app}::${report.database}
      available for one month after creation on ${report.created_at}
      `)
          let display = checks => {
      Severity: Minor
      Found in commands/diagnose.js - About 1 hr to fix

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

        function * run (context, heroku) {
          const host = require('../../lib/host')
          const fetcher = require('../../lib/fetcher')(heroku)
          let {app, args} = context
        
        
        Severity: Minor
        Found in commands/links/index.js - About 1 hr to fix

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

          exports.getConnectionDetails = function (attachment, config) {
            const url = require('url')
            const configVars = attachment.config_vars.filter((cv) => {
              return config[cv] && config[cv].startsWith('postgres://')
            })
          Severity: Minor
          Found in lib/util.js - About 1 hr to fix

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

            function displayDB (db, app) {
              if (db.addon.attachment_names) {
                cli.styledHeader(db.addon.attachment_names.map(c => cli.color.configVar(c + '_URL')).join(', '))
              } else {
                cli.styledHeader(db.configVars.map(c => cli.color.configVar(c)).join(', '))
            Severity: Minor
            Found in commands/info.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

            Avoid deeply nested control flow statements.
            Open

                      if (detach && detach.status === 'succeeded') {
                        msg += 'without an attached DATABASE_URL.'
                      } else {
                        msg += `with ${current.addon.name} attached as DATABASE_URL.`
                      }
            Severity: Major
            Found in commands/promote.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                      } else if (Date.now() > endTime) {
                        return cli.action.done('timeout. Check your Attach DATABASE release for failures.')
                      }
              Severity: Major
              Found in commands/promote.js - About 45 mins to fix

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

                  yield cli.confirmApp(app, flags.confirm, `WARNING: Destructive action
                ${cli.color.addon(db.name)} will become writeable and no longer follow ${origin}. This cannot be undone.
                `)
                Severity: Minor
                Found in commands/unfollow.js and 1 other location - About 40 mins to fix
                commands/upgrade.js on lines 28..31

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

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

                    cli.warn(`${cli.color.cmd('pg:credentials')} has recently changed. Please use ${cli.color.cmd('pg:credentials:url')} for the previous output.`)
                Severity: Major
                Found in commands/credentials.js and 3 other locations - About 40 mins to fix
                commands/backups/capture.js on lines 39..43
                commands/backups/restore.js on lines 62..66
                commands/credentials.js on lines 45..45

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

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

                    cli.log(`
                Use Ctrl-C at any time to stop monitoring progress; the backup will continue running.
                Use ${cli.color.cmd('heroku pg:backups:info')} to check progress.
                Stop a running backup with ${cli.color.cmd('heroku pg:backups:cancel')}.
                `)
                Severity: Major
                Found in commands/backups/capture.js and 3 other locations - About 40 mins to fix
                commands/backups/restore.js on lines 62..66
                commands/credentials.js on lines 35..35
                commands/credentials.js on lines 45..45

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

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

                  yield cli.confirmApp(app, flags.confirm, `WARNING: Destructive action
                ${cli.color.addon(db.name)} will be upgraded to a newer PostgreSQL version, stop following ${origin}, and become writable.
                
                This cannot be undone.`)
                Severity: Minor
                Found in commands/upgrade.js and 1 other location - About 40 mins to fix
                commands/unfollow.js on lines 18..20

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

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

                  cli.log(`
                Use Ctrl-C at any time to stop monitoring progress; the backup will continue restoring.
                Use ${cli.color.cmd('heroku pg:backups')} to check progress.
                Stop a running restore with ${cli.color.cmd('heroku pg:backups:cancel')}.
                `)
                Severity: Major
                Found in commands/backups/restore.js and 3 other locations - About 40 mins to fix
                commands/backups/capture.js on lines 39..43
                commands/credentials.js on lines 35..35
                commands/credentials.js on lines 45..45

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

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

                    cli.error(`${cli.color.cmd('pg:credentials --reset')} is deprecated. Please use ${cli.color.cmd('pg:credentials:rotate')} instead.`)
                Severity: Major
                Found in commands/credentials.js and 3 other locations - About 40 mins to fix
                commands/backups/capture.js on lines 39..43
                commands/backups/restore.js on lines 62..66
                commands/credentials.js on lines 35..35

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

                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 a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

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

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

                function presentCredentialAttachments (app, credAttachments, credentials, cred) {
                  let isForeignApp = (attOrAddon) => attOrAddon.app.name !== app
                  let atts = sortBy(credAttachments,
                    isForeignApp,
                    'name',
                Severity: Minor
                Found in lib/util.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

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

                exports.generate = (name, convert, explain) => {
                  return co.wrap(function * run (context, heroku) {
                    const host = require('./host')
                    const util = require('./util')
                    const fetcher = require('./fetcher')(heroku)
                Severity: Minor
                Found in lib/setter.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

                Severity
                Category
                Status
                Source
                Language