engineyard/engineyard

View on GitHub
lib/engineyard/cli.rb

Summary

Maintainability
F
3 days
Test Coverage

File cli.rb has 707 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'engineyard'
require 'engineyard/error'
require 'engineyard/thor'
require 'engineyard/deploy_config'
require 'engineyard/serverside_runner'
Severity: Major
Found in lib/engineyard/cli.rb - About 1 day to fix

    Method ssh has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def ssh(cmd=nil)
          environment = fetch_environment(options[:environment], options[:account])
          instances = filter_servers(environment, options, default: {app_master: true})
          user = environment.username
          ssh_opts = []
    Severity: Minor
    Found in lib/engineyard/cli.rb - 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

    Method deploy has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def deploy
          app_env = fetch_app_environment(options[:app], options[:environment], options[:account])
    
          env_config    = config.environment_config(app_env.environment_name)
          deploy_config = EY::DeployConfig.new(options, env_config, repo, ui)
    Severity: Major
    Found in lib/engineyard/cli.rb - About 2 hrs to fix

      Method filter_servers has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def filter_servers(environment, cli_opts, filter_opts)
              if (cli_opts.keys.map(&:to_sym) & OPT_TO_ROLES.keys).any?
                options = cli_opts.dup
              else
                options = filter_opts[:default].dup
      Severity: Minor
      Found in lib/engineyard/cli.rb - 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

      Method ssh has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def ssh(cmd=nil)
            environment = fetch_environment(options[:environment], options[:account])
            instances = filter_servers(environment, options, default: {app_master: true})
            user = environment.username
            ssh_opts = []
      Severity: Minor
      Found in lib/engineyard/cli.rb - About 1 hr to fix

        Method environments has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def environments
              if options[:all] && options[:simple]
                ui.print_simple_envs api.environments
              elsif options[:all]
                ui.print_envs api.apps
        Severity: Minor
        Found in lib/engineyard/cli.rb - 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

        Method help has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def help(*cmds)
              if cmds.empty?
                base = self.class.send(:banner_base)
                list = self.class.printable_tasks
        
        
        Severity: Minor
        Found in lib/engineyard/cli.rb - About 1 hr to fix

          Method environments has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def environments
                if options[:all] && options[:simple]
                  ui.print_simple_envs api.environments
                elsif options[:all]
                  ui.print_envs api.apps
          Severity: Minor
          Found in lib/engineyard/cli.rb - About 1 hr to fix

            Method deploy has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def deploy
                  app_env = fetch_app_environment(options[:app], options[:environment], options[:account])
            
                  env_config    = config.environment_config(app_env.environment_name)
                  deploy_config = EY::DeployConfig.new(options, env_config, repo, ui)
            Severity: Minor
            Found in lib/engineyard/cli.rb - 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

            Method scp has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def scp(from_path, to_path)
                  environment = fetch_environment(options[:environment], options[:account])
                  instances   = filter_servers(environment, options, default: {app_master: true})
                  user        = environment.username
            
            
            Severity: Minor
            Found in lib/engineyard/cli.rb - About 45 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

            Method servers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def servers
                  if options[:environment] == '' && options[:account] == ''
                    repo.fail_on_no_remotes!
                  end
            
            
            Severity: Minor
            Found in lib/engineyard/cli.rb - 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

            Method console has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def console
                  app_env = fetch_app_environment(options[:app], options[:environment], options[:account])
                  instances = filter_servers(app_env.environment, options, default: {app_master: true})
                  user = app_env.environment.username
                  cmd = "cd /data/#{app_env.app.name}/current && bundle exec rails console"
            Severity: Minor
            Found in lib/engineyard/cli.rb - 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

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

                  instances.each do |instance|
                    host = instance.public_hostname
                    name = instance.name ? "#{instance.role} (#{instance.name})" : instance.role
                    ui.info "\nConnecting to #{name} #{host}..."
                    unless cmd
            Severity: Major
            Found in lib/engineyard/cli.rb and 1 other location - About 1 hr to fix
            lib/engineyard/cli.rb on lines 508..519

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

            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

                  instances.each do |instance|
                    host = instance.public_hostname
                    name = instance.name ? "#{instance.role} (#{instance.name})" : instance.role
                    ui.info "\nConnecting to #{name} #{host}..."
                    unless cmd
            Severity: Major
            Found in lib/engineyard/cli.rb and 1 other location - About 1 hr to fix
            lib/engineyard/cli.rb on lines 552..563

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

            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

            There are no issues that match your filters.

            Category
            Status