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'
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 = []
- Read upRead up
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
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)
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
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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|
- Read upRead up
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
- Read upRead up
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 = []
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
- Read upRead up
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
- Read upRead up
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
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
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|
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)
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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)
- Read upRead up
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"