heroku/heroku-cli-addons

View on GitHub

Showing 19 of 27 total issues

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

function * run (ctx, api) {
  const util = require('../../lib/util')
  const table = util.table
  const style = util.style
  const formatPrice = util.formatPrice
Severity: Major
Found in commands/addons/index.js - About 1 day to fix

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

    function * run (ctx, api) {
      const util = require('../../lib/util')
      const table = util.table
      const style = util.style
      const formatPrice = util.formatPrice
    Severity: Minor
    Found in commands/addons/index.js - About 7 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

    Function displayForApp has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function displayForApp (app, addons) {
        if (addons.length === 0) {
          cli.log(`No add-ons for app ${app}.`)
          return
        }
    Severity: Major
    Found in commands/addons/index.js - About 2 hrs to fix

      Function addonGetter has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function * addonGetter (api, app) {
          let attachments, addons
      
          if (app) { // don't disploy attachments globally
            addons = api.get(`/apps/${app}/addons`, {headers: {
      Severity: Major
      Found in commands/addons/index.js - About 2 hrs to fix

        Function displayAll has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function displayAll (addons) {
            addons = sortBy(addons, 'app.name', 'plan.name', 'addon.name')
        
            if (addons.length === 0) {
              cli.log('No add-ons.')
        Severity: Minor
        Found in commands/addons/index.js - About 1 hr to fix

          Function parseConfig has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          function parseConfig (args) {
            let config = {}
            while (args.length > 0) {
              let key = args.shift()
              if (!key.startsWith('--')) throw new Error(`Unexpected argument ${key}`)
          Severity: Minor
          Found in commands/addons/create.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 attachment has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.attachment = function (heroku, app, id, options = {}) {
            const headers = attachmentHeaders()
          
            function getAttachment (id) {
              return heroku.post('/actions/addon-attachments/resolve', {
          Severity: Minor
          Found in lib/resolve.js - About 1 hr to fix

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

            function * run (context, heroku) {
              const util = require('../../lib/util')
            
              let app = context.app
              let addon = yield heroku.get(`/addons/${encodeURIComponent(context.args.addon_name)}`)
            Severity: Minor
            Found in commands/addons/attach.js - About 1 hr to fix

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

              module.exports = function * (heroku, app, plan, confirm, wait, options) {
                const util = require('./util')
                const waitForAddonProvisioning = require('./addons_wait')
              
                function createAddonRequest (confirm) {
              Severity: Minor
              Found in lib/create_addon.js - About 1 hr to fix

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

                function * run (context, heroku) {
                  const util = require('../../lib/util')
                
                  let app = context.app
                  let addon = yield heroku.get(`/addons/${encodeURIComponent(context.args.addon_name)}`)
                Severity: Minor
                Found in commands/addons/attach.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 run has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                function * run (ctx, api) {
                  const resolve = require('../../lib/resolve')
                
                  let addons
                  if (ctx.args.addon) {
                Severity: Minor
                Found in commands/addons/wait.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 run has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function * run (c, h) {
                  const resolver = require('../../lib/resolve')
                  const util = require('../../lib/util')
                
                  context = c
                Severity: Minor
                Found in commands/addons/upgrade.js - About 1 hr to fix

                  Function writeSudoTemplate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function writeSudoTemplate (ctx, sso, path) {
                    return new Promise(function (resolve, reject) {
                      let html = `<!DOCTYPE HTML>
                  <html>
                    <head>
                  Severity: Minor
                  Found in commands/addons/open.js - About 1 hr to fix

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

                    function * run (context, heroku) {
                      const resolve = require('../../lib/resolve')
                      const {groupBy, toPairs} = require('lodash')
                    
                      let force = context.flags.force || process.env.HEROKU_FORCE === '1'
                    Severity: Minor
                    Found in commands/addons/destroy.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

                    Function exports has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    module.exports = function * (heroku, app, plan, confirm, wait, options) {
                    Severity: Minor
                    Found in lib/create_addon.js - About 45 mins to fix

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

                      module.exports = function * (heroku, app, plan, confirm, wait, options) {
                        const util = require('./util')
                        const waitForAddonProvisioning = require('./addons_wait')
                      
                        function createAddonRequest (confirm) {
                      Severity: Minor
                      Found in lib/create_addon.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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function * run (ctx, api) {
                        const resolve = require('../../lib/resolve')
                      
                        if (process.env.HEROKU_SUDO) return sudo(ctx, api)
                      
                      
                      Severity: Minor
                      Found in commands/addons/open.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 handleAPIError has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function handleAPIError (err) {
                        if (err.statusCode === 422 && err.body.id === 'multiple_matches') {
                          let example = err.body.message.split(', ')[2] || 'redis-triangular-1234'
                          throw new Error(`${err.body.message}
                      
                      
                      Severity: Minor
                      Found in commands/addons/upgrade.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 filter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const filter = function (app, addonService) {
                        return attachments => {
                          return attachments.filter(attachment => {
                            if (attachment.app.name !== app) {
                              return false
                      Severity: Minor
                      Found in lib/resolve.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