engineyard/engineyard

View on GitHub

Showing 28 of 28 total issues

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

      def disable
        app_env = fetch_app_environment(options[:app], options[:environment], options[:account])
        ui.info "Putting up maintenance page for '#{app_env.app.name}' in '#{app_env.environment.name}'"
        serverside_runner(app_env, options[:verbose]).put_up_maintenance_page.call(ui.out, ui.err)
Severity: Minor
Found in lib/engineyard/cli/web.rb and 1 other location - About 40 mins to fix
lib/engineyard/cli/web.rb on lines 17..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 37.

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

      def enable
        app_env = fetch_app_environment(options[:app], options[:environment], options[:account])
        ui.info "Taking down maintenance page for '#{app_env.app.name}' in '#{app_env.environment.name}'"
        serverside_runner(app_env, options[:verbose]).take_down_maintenance_page.call(ui.out, ui.err)
Severity: Minor
Found in lib/engineyard/cli/web.rb and 1 other location - About 40 mins to fix
lib/engineyard/cli/web.rb on lines 47..50

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

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 load_adapter has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def load_adapter(bridge, app, environment, verbose, serverside_version)
Severity: Minor
Found in lib/engineyard/serverside_runner.rb - About 35 mins to fix

    Method ssh has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def ssh(cmd, hostname, username, out, err)
    Severity: Minor
    Found in lib/engineyard/serverside_runner.rb - About 35 mins to fix

      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

      Method with_reauthentication has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def with_reauthentication
              begin
                yield
              rescue EY::CloudClient::InvalidCredentials
                if @specified || !@ui.interactive?
      Severity: Minor
      Found in lib/engineyard/cli/api.rb - About 25 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 banner has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.banner(task, task_help = false, subcommand = false)
              subcommand_banner = to_s.split(/::/).map{|s| s.downcase}[2..-1]
              subcommand_banner = if subcommand_banner.size > 0
                                    subcommand_banner.join(' ')
                                  else
      Severity: Minor
      Found in lib/engineyard/thor.rb - About 25 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