Showing 134 of 134 total issues
File ec2.rb
has 781 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Awscli
module EC2
require 'pp'
class EC2
Method create_job_flow
has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. Open
def create_job_flow(options)
# => BOOTSTRAP ACTIONS
boot_strap_actions = []
if options[:bootstrap_actions]
options[:bootstrap_actions].each do |step|
- 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_instance
has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring. Open
def create_instance(options)
#validate required options
puts 'Validating Options ...'
abort "Invalid Key: #{options[:key_name]}" unless @conn.key_pairs.get(options[:key_name])
options[:groups].each do |sg|
- 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
File emr.rb
has 423 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Awscli
module Emr
class EMR
def initialize(connection)
@conn = connection
Method delete
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
def delete(options)
username = options[:user_name]
user = @conn.users.get(username)
if user
if options[:force]
- 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 update
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
def update(options)
opts = {}
key = {}
attribute_updates = {}
#Build and validate key
- 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
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
def create(options)
#validate block device mapping and parse it to a hash understandable by fog
opts = Marshal.load(Marshal.dump(options))
block_device_mapping = Array.new
if options[:block_device_mappings]
- 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 put
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
def put(options)
items = {}
opts = {}
options[:item].each do |item|
abort "invalid item format: #{item}" unless item =~ /(.*):(N|S|NS|SS|B|BS):(.*)/
- 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
File dynamo.rb
has 390 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Awscli
module DynamoDB
class Table
def initialize(connection)
@conn = connection
Method delete
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
def delete(options)
key = {}
opts = {}
#Build and validate key
abort 'Invalid --hash-key format' unless options[:hash_key] =~ /(N|S|NS|SS|B|BS):(.*)/
- 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
File iam.rb
has 371 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'json'
module Awscli
module Iam
Method delete_rec
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def delete_rec(dir_name)
#Forked from https://gist.github.com/bdunagan/1383301
data_queue = Queue.new
semaphore = Mutex.new
threads = Array.new
- 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_job_flow
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_job_flow(options)
# => BOOTSTRAP ACTIONS
boot_strap_actions = []
if options[:bootstrap_actions]
options[:bootstrap_actions].each do |step|
Similar blocks of code found in 2 locations. Consider refactoring. Open
if options[:block_device_mappings]
options[:block_device_mappings].each do |group|
mapping = Hash.new
#parse options
abort "Invalid block device mapping format, expecting 'devicename=blockdevice' format" unless group =~ /\S=\S/
- 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 115.
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
if options[:block_device_mapping]
options[:block_device_mapping].each do |group|
mapping = Hash.new
#parse options
abort "Invalid block device mapping format, expecting 'devicename=blockdevice' format" unless group =~ /\S=\S/
- 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 115.
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 query
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def query(options)
opts = {}
hash_key_type, hash_key_value = options[:hash_key_value].split(',')
hash_key = { hash_key_type => hash_key_value }
opts['AttributesToGet'] = options[:attrs_to_get] if options[:attrs_to_get]
- 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 query
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def query
unless options[:table_name] and options[:hash_key_value]
abort 'options --table-name and --hash-key-value are required'
end
abort 'invalid --hash-key-value format' unless options[:hash_key_value] =~ /^(.*?),(.*?)$/
- 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 scan
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def scan(options)
opts = {}
opts['AttributesToGet'] = options[:attrs_to_get] if options[:attrs_to_get]
opts['Limit'] = options[:limit] if options[:limit]
opts['ConsistentRead'] = options[:consistent_read] if options[:consistent_read]
- 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 EMR
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class EMR
def initialize(connection)
@conn = connection
end
Method create_instance
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_instance(options)
#validate required options
puts 'Validating Options ...'
abort "Invalid Key: #{options[:key_name]}" unless @conn.key_pairs.get(options[:key_name])
options[:groups].each do |sg|