Showing 19 of 19 total issues
Cyclomatic complexity for initialize is too high. [7/6] Open
def initialize(str)
@type =
case str
when /^c[s#](harp)?$/i
::Lamma::Runtime::C_SHARP
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Cyclomatic complexity for run is too high. [7/6] Open
def run
unless File.exist?(@conf_path)
abort("Config file #{@conf_path} is missing.")
end
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Method prebuild
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def prebuild
if @prebuild
Lamma.logger.info 'Running prebuild script...'
raise unless system(@prebuild)
elsif [Lamma::Runtime::PYTHON_27, Lamma::Runtime::PYTHON_36].include?(@function.runtime.type) \
- 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 run
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
if Dir.exist?(target)
Lamma.logger.fatal "Directory '#{target}' already exists."
exit(1)
end
Method run
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def run
unless File.exist?(@conf_path)
abort("Config file #{@conf_path} is missing.")
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 create_initial_role
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_initial_role(role_name)
begin
Lamma.logger.info("Creating role #{role_name}")
resp = iam.create_role({
assume_role_policy_document: DEFAULT_LAMBDA_ASSUME_ROLE_POLICY.to_json,
Method run
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def run
if Dir.exist?(target)
Lamma.logger.fatal "Directory '#{target}' already exists."
exit(1)
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 run
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
unless File.exist?(@conf_path)
abort("Config file #{@conf_path} is missing.")
end
Method zip_and_save
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def zip_and_save
io = Zip::OutputStream.write_buffer do |zio|
active_paths.each do |path|
next unless File.file?(path)
File.open(path) do |source_io|
- 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_or_create_alias
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def update_or_create_alias(f, new_version)
a = Lamma::Alias.new(f, options['alias'], new_version)
if a.remote_exist? && a.remote_version
last_version = a.remote_version
- 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_initial_role
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def create_initial_role(role_name)
begin
Lamma.logger.info("Creating role #{role_name}")
resp = iam.create_role({
assume_role_policy_document: DEFAULT_LAMBDA_ASSUME_ROLE_POLICY.to_json,
- 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
unexpected token tCOLON
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
'Effect': 'Allow',
- Exclude checks
unexpected token tCOLON
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
'Version': '2012-10-17',
- Exclude checks
Method Lamma::Alias#description
is defined at both lib/lamma/alias.rb:3 and lib/lamma/alias.rb:66. Open
def description
- Read upRead up
- Exclude checks
This cop checks for duplicated instance (or singleton) method definitions.
Example:
# bad
def duplicated
1
end
def duplicated
2
end
Example:
# bad
def duplicated
1
end
alias duplicated other_duplicated
Example:
# good
def duplicated
1
end
def other_duplicated
2
end
Unused method argument - function_name
. If it's necessary, use _
or _function_name
as an argument name to indicate that it won't be used. You can also write as show(*)
if you want the method to accept any arguments but don't care about them. Open
def show(function_name)
- Read upRead up
- Exclude checks
This cop checks for unused method arguments.
Example:
# bad
def some_method(used, unused, _unused_but_allowed)
puts used
end
Example:
# good
def some_method(used, _unused, _unused_but_allowed)
puts used
end
unexpected token error
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
raise Exception("Invalid source_path #{@source_path}") if @source_path&.empty?
- Exclude checks
XXX found Open
thor.say(f) # XXX:
- Exclude checks
XXX found Open
if true # XXX: option save_builds?
- Exclude checks
TODO found Open
# TODO: impl
- Exclude checks