Showing 87 of 87 total issues
Method execute_script
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def execute_script(script, script_log_file)
script_command = InstanceAgent::Platform.util.prepare_script_command(script, script_absolute_path(script))
log_script("Script - " + script.location + "\n", script_log_file)
exit_status = 1
signal = nil
Method unpack_bundle
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def unpack_bundle(cmd, bundle_file, deployment_spec)
dst = File.join(deployment_root_dir(deployment_spec), 'deployment-archive')
if "tar".eql? deployment_spec.bundle_type
InstanceAgent::Platform.util.extract_tar(bundle_file, dst)
- 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 generate_instructions
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_instructions(application_specification)
InstanceAgent::Plugins::CodeDeployPlugin::InstallInstruction.generate_instructions() do |i|
application_specification.files.each do |fi|
absolute_source_path = File.join(deployment_archive_dir, fi.source)
file_exists_behavior = application_specification.respond_to?(:file_exists_behavior) && application_specification.file_exists_behavior ? application_specification.file_exists_behavior : @file_exists_behavior
Method initialize
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(mode)
mode = mode.to_s
while mode.length < 3 do
mode = "0" + mode;
end
Method run
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
start_time = Time.now
begin
perform
Method stop
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def stop
if (pid = self.class.find_pid)
puts "Checking first if a deployment is already in progress"
ProcessManager::Log.info("Checking first if any deployment lifecycle event is in progress #{description(pid)}")
begin
Method get_full_acl
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def get_full_acl()
perm = "%o" % File.stat(@object).mode
perm = perm[-3,3]
@acl.add_ace(":#{perm[0]}")
@acl.add_ace("g::#{perm[1]}")
- 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 configure
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.configure
file_path = InstanceAgent::Config.config[:on_premises_config_file]
file_config = nil
if File.exists?(file_path) && File.readable?(file_path)
begin
Method execute
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def execute
return if @app_spec.nil?
if (hooks = @app_spec.hooks[@lifecycle_event]) &&
!hooks.empty?
create_script_log_file_if_needed do |script_log_file|
Method process_command
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_command(command, spec)
log(:debug, "Calling #{@plugin.to_s}.execute_command")
begin
deployment_id = InstanceAgent::Plugins::CodeDeployPlugin::DeploymentSpecification.parse(spec).deployment_id
DeploymentCommandTracker.create_ongoing_deployment_tracking_file(deployment_id, command.host_command_identifier)
Method initialize
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(arguments = {})
#check arguments
raise "Lifecycle Event Required " if arguments[:lifecycle_event].nil?
raise "Deployment ID required " if arguments[:deployment_id].nil?
raise "Deployment Root Directory Required " if arguments[:deployment_root_dir].nil?
Method download_from_s3
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def download_from_s3(deployment_spec, bucket, key, version, etag)
log(:info, "Downloading artifact bundle from bucket '#{bucket}' and key '#{key}', version '#{version}', etag '#{etag}'")
options = s3_options()
s3 = Aws::S3::Client.new(options)
Method parse_permissions
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def parse_permissions(permissions_list)
permissions = []
#loop through list and create permissionsInfo representations
permissions_list.each do |permission|
if !permission.has_key?('object') || permission['object'].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 initialize
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def initialize(arguments = {})
#check arguments
raise "Lifecycle Event Required " if arguments[:lifecycle_event].nil?
raise "Deployment ID required " if arguments[:deployment_id].nil?
raise "Deployment Root Directory Required " if arguments[:deployment_root_dir].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 get_range
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_range
range = "s" + @low_sensitivity.to_s
if (@low_sensitivity != @high_sensitivity)
range = range + "-s" + @high_sensitivity.to_s
end
Similar blocks of code found in 2 locations. Consider refactoring. Open
def self.delete_folder (dir)
if dir != nil && dir != "/"
output = `rm -rf #{dir} 2>&1`
exit_status = $?.exitstatus
log(:debug, "Command status: #{$?}")
- 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 49.
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.delete_folder (dir)
if dir != nil && dir != "/"
output = `rd /s /q "#{dir}" 2>&1`
exit_status = $?.exitstatus
log(:debug, "Command status: #{$?}")
- 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 49.
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 initialize
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize
super
@config.update({
:program_name => 'codedeploy-agent',
:wait_between_spawning_children => 1,
Method build_spec
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def build_spec(location, bundle_type, deployment_group_id, file_exists_behavior, all_possible_lifecycle_events, deployment_group_name, application_name, appspec_filename)
Method find_matches
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def find_matches(permission)
log(:debug, "Finding matches for #{permission.object}")
matches = []
if permission.type.include?("file")
@copy_targets.keys.each do |object|
- 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"