lib/caravan.rb
Assignment Branch Condition size for start is too high. [26.42/15] Open
Open
def start(merged_conf)
src_path = merged_conf["src"]
target_path = merged_conf["dst"]
deploy_mode = merged_conf["deploy_mode"]
ignores = merged_conf["exclude"]
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [31/30] Open
Open
def start(merged_conf)
src_path = merged_conf["src"]
target_path = merged_conf["dst"]
deploy_mode = merged_conf["deploy_mode"]
ignores = merged_conf["exclude"]
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method start
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def start(merged_conf)
src_path = merged_conf["src"]
target_path = merged_conf["dst"]
deploy_mode = merged_conf["deploy_mode"]
ignores = merged_conf["exclude"]
Method create_listener
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def create_listener(deployer, src_path)
Listen.to(src_path) do |modified, added, removed|
# rubocop:disable Lint/NonLocalExitFromIterator
return unless deployer.handle_change(modified, added, removed)
return unless deployer.before_deploy
- 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
Favor a normal if-statement over a modifier clause in a multiline statement. Open
Open
Caravan::Message.warn(
"Caravan now support multiple specs in `caravan.yml`. " \
"The default spec is `master`. " \
"And we detect that you may need to migrate."
) if Caravan::ConfigMigration.need_migrate?(conf)
- Read upRead up
- Exclude checks
Checks for uses of if/unless modifiers with multiple-lines bodies.
Example:
# bad
{
result: 'this should not happen'
} unless cond
# good
{ result: 'ok' } if cond