engineyard/engineyard

View on GitHub

Showing 28 of 28 total issues

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

    Class UI has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class UI < Thor::Base.shell
    
          class Tee
            def initialize(*ios)
              @ios = ios
    Severity: Minor
    Found in lib/engineyard/cli/ui.rb - About 2 hrs to fix

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

                def self.ask(question, password = false, default = nil)
                  if @mock
                    @questions ||= []
                    @questions << question
                    answer = @answers.shift
        Severity: Minor
        Found in lib/engineyard/cli/ui.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 agree has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

                def self.agree(question, default)
                  if @mock
                    @questions ||= []
                    @questions << question
                    answer = @answers.shift
        Severity: Minor
        Found in lib/engineyard/cli/ui.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

        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

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

              def print_envs(apps, default_env_name = nil)
                apps.sort_by {|app| "#{app.account.name}/#{app.name}" }.each do |app|
                  puts "#{app.account.name}/#{app.name}"
                  if app.environments.any?
                    app.environments.sort_by {|env| env.name }.each do |env|
        Severity: Minor
        Found in lib/engineyard/cli/ui.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 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 run has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def run(remote_command, out, err)
                cmd = Escape.shell_command(['bash', '-lc', remote_command])
          
                if cmd.respond_to?(:encoding) && cmd.respond_to?(:force_encoding)
                  out << "Encoding: #{cmd.encoding.name}" if @verbose
          Severity: Minor
          Found in lib/engineyard/serverside_runner.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 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 ssh has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def ssh(cmd, hostname, username, out, err)
                    exit_code = 1
                    Net::SSH.start(hostname, username, net_ssh_options) do |net_ssh|
                      net_ssh.open_channel do |channel|
                        channel.exec cmd do |_, success|
              Severity: Minor
              Found in lib/engineyard/serverside_runner.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 cookbooks_dir_archive_path has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                        def cookbooks_dir_archive_path
                          unless FileTest.exist?("cookbooks")
                            raise EY::Error, "Could not find chef recipes. Please run from the root of your recipes repo."
                          end
                
                
                Severity: Minor
                Found in lib/engineyard/cli/recipes.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 debug has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def debug(name, message = nil)
                        if ENV["DEBUG"]
                          name    = name.inspect    unless name.nil? or name.is_a?(String)
                          message = message.inspect unless message.nil? or message.is_a?(String)
                          say_with_status(name, message, :blue)
                Severity: Minor
                Found in lib/engineyard/cli/ui.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

                Severity
                Category
                Status
                Source
                Language