Showing 58 of 58 total issues
Method execute_commands
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def execute_commands(commands, agent_socket, stdin)
result = nil
args = {:verify_host_key => false, :number_of_password_prompts => 0}
if agent_socket
args.merge!(:forward_agent => true,
- 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_exec!
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def ssh_exec!(ssh, command, stdin)
stdout_data = ''
stderr_data = ''
exit_status = nil
exit_signal = nil
Method ssh_exec!
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def ssh_exec!(ssh, command, stdin)
stdout_data = ''
stderr_data = ''
exit_status = nil
exit_signal = nil
- 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 parse_repo_list_output
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.parse_repo_list_output(content)
collect_content = false
index_start = "repo id"
index_end = "repolist:"
- 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 info
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.info(pkg)
params = { "-qi" => pkg}
in_description = false
out = Common.run!(rpm_cmd, :params => params).output
# older versions of rpm may have multiple fields per line,
- 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 save
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def save
old_contents = @interface_file.file? ? File.read(@interface_file) : ""
stop_success = stop
# Stop twice because when configure both ipv4 and ipv6 as dhcp, ipv6 dhcp client will
- 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 add_name
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def add_name(address, hostname, fqdn, comment, remove_existing = true)
# Delete entries for this hostname first
@parsed_file.each { |i| i[:hosts].to_a.delete(hostname) } if remove_existing
# Add entry
- 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 parse_content
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def parse_content(content)
# Break into content groupings by "\n\n" then process each grouping
content.split("\n\n").each_with_object([]) do |group, group_array|
group = group.split("\n").each_with_object({}) do |line, hash|
next if line.blank?
- 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 create_partition
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def create_partition(partition_type, *args)
create_partition_table unless has_partition_table?
start = finish = size = nil
case args.length
- 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 apply_static
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def apply_static(ip, mask, gw, dns, search = nil)
Method add_name
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_name(address, hostname, fqdn, comment, remove_existing = true)
Method apply_static6
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def apply_static6(ip, prefix, gw, dns, search = nil)
Method from_string
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.from_string(apt_cache_string)
in_description = false
apt_cache_string.split("\n").each.with_object({}) do |line,deb|
tag,value = self.from_line(line)
if tag == 'description-en'
- 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 lockdown
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def lockdown(*args)
raise "OpenSCAP not available" unless self.class.openscap_available?
raise "SCAP Security Guide not available" unless self.class.ssg_available?(platform)
values = args.last.kind_of?(Hash) ? args.pop : {}
- 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 register
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def register(options)
raise ArgumentError, "username and password are required" unless options[:username] && options[:password]
install_server_certificate(options[:server_url], SATELLITE6_SERVER_CERT_PATH) if options[:server_url]
- 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 download_packages
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.download_packages(path, packages, options = {})
raise ArgumentError, "path is required" unless path
raise ArgumentError, "packages are required" unless packages
options = {:mirror_type => :package}.merge(options)
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def self.scan
@pvs ||= begin
scan_volumes(Common.cmd(:pvdisplay)) do |fields, vg|
PhysicalVolume.new(:device_name => fields[0],
:volume_group => vg,
- 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 26.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def self.scan
@lvs ||= begin
scan_volumes(Common.cmd(:lvdisplay)) do |fields, vg|
LogicalVolume.new(:name => fields[0],
:volume_group => vg,
- 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 26.
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
Redundant use of Object#to_s
in interpolation. Open
puts "Registration Status: #{reg_status.to_s}"
- Read upRead up
- Exclude checks
Checks for string conversion in string interpolation, print
, puts
, and warn
arguments,
which is redundant.
Example:
# bad
"result is #{something.to_s}"
print something.to_s
puts something.to_s
warn something.to_s
Example:
# good
"result is #{something}"
print something
puts something
warn something
Use filter_map
instead. Open
result.output.split("\n").collect do |string|
path, size, type, *model = string.split
if type.casecmp?('disk') && size.to_i > 0
self.new(:path => path, :size => size.to_i, :model => model.join(' '))
end
- Exclude checks