Showing 32 of 32 total issues
Assignment Branch Condition size for start is too high. [26.42/15] 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
Assignment Branch Condition size for merge is too high. [21.77/15] Open
def merge(options, conf, spec = Caravan::Config.default_spec_name)
merged_conf = if conf.nil?
Caravan::Message.warn("Fail to load conf. Use default instead.")
default_spec_name = Caravan::Config.default_spec_name
Caravan::Config.default_conf[default_spec_name]
- 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
Perceived complexity for merge is too high. [9/7] Open
def merge(options, conf, spec = Caravan::Config.default_spec_name)
merged_conf = if conf.nil?
Caravan::Message.warn("Fail to load conf. Use default instead.")
default_spec_name = Caravan::Config.default_spec_name
Caravan::Config.default_conf[default_spec_name]
- Read upRead up
- Exclude checks
This cop tries to produce a complexity score that's a measure of the
complexity the reader experiences when looking at a method. For that
reason it considers when
nodes as something that doesn't add as much
complexity as an if
or a &&
. Except if it's one of those special
case
/when
constructs where there's no expression after case
. Then
the cop treats it as an if
/elsif
/elsif
... and lets all the when
nodes count. In contrast to the CyclomaticComplexity cop, this cop
considers else
nodes as adding complexity.
Example:
def my_method # 1
if cond # 1
case var # 2 (0.8 + 4 * 0.2, rounded)
when 1 then func_one
when 2 then func_two
when 3 then func_three
when 4..10 then func_other
end
else # 1
do_something until a && b # 2
end # ===
end # 7 complexity points
Cyclomatic complexity for merge is too high. [8/6] Open
def merge(options, conf, spec = Caravan::Config.default_spec_name)
merged_conf = if conf.nil?
Caravan::Message.warn("Fail to load conf. Use default instead.")
default_spec_name = Caravan::Config.default_spec_name
Caravan::Config.default_conf[default_spec_name]
- 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 has too many lines. [31/30] 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
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 merge
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def merge(options, conf, spec = Caravan::Config.default_spec_name)
merged_conf = if conf.nil?
Caravan::Message.warn("Fail to load conf. Use default instead.")
default_spec_name = Caravan::Config.default_spec_name
Caravan::Config.default_conf[default_spec_name]
- 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_listener
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. 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
%q
-literals should be delimited by (
and )
. Open
spec.summary = %q{Simple project files watcher and deployer}
- Read upRead up
- Exclude checks
This cop enforces the consistent usage of %
-literal delimiters.
Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.
Example:
# Style/PercentLiteralDelimiters:
# PreferredDelimiters:
# default: '[]'
# '%i': '()'
# good
%w[alpha beta] + %i(gamma delta)
# bad
%W(alpha #{beta})
# bad
%I(alpha beta)
%q
-literals should be delimited by (
and )
. Open
spec.description = %q{Caravan is a simple file watcher and deployer of project files for local development.}
- Read upRead up
- Exclude checks
This cop enforces the consistent usage of %
-literal delimiters.
Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.
Example:
# Style/PercentLiteralDelimiters:
# PreferredDelimiters:
# default: '[]'
# '%i': '()'
# good
%w[alpha beta] + %i(gamma delta)
# bad
%W(alpha #{beta})
# bad
%I(alpha beta)
Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency codeclimate-test-reporter
should appear before shoulda-context
. Open
spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0"
- Read upRead up
- Exclude checks
Dependencies in the gemspec should be alphabetically sorted.
Example:
# bad
spec.add_dependency 'rubocop'
spec.add_dependency 'rspec'
# good
spec.add_dependency 'rspec'
spec.add_dependency 'rubocop'
# good
spec.add_dependency 'rubocop'
spec.add_dependency 'rspec'
# bad
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rspec'
# good
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rubocop'
# good
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rspec'
# bad
spec.add_runtime_dependency 'rubocop'
spec.add_runtime_dependency 'rspec'
# good
spec.add_runtime_dependency 'rspec'
spec.add_runtime_dependency 'rubocop'
# good
spec.add_runtime_dependency 'rubocop'
spec.add_runtime_dependency 'rspec'
# good only if TreatCommentsAsGroupSeparators is true
# For code quality
spec.add_dependency 'rubocop'
# For tests
spec.add_dependency 'rspec'
Use %q
only for strings that contain both single quotes and double quotes. Open
spec.summary = %q{Simple project files watcher and deployer}
- Exclude checks
Use %q
only for strings that contain both single quotes and double quotes. Open
spec.description = %q{Caravan is a simple file watcher and deployer of project files for local development.}
- Exclude checks
Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem black-white-blue
should appear before jekyll-feed
. Open
gem "black-white-blue"
- Read upRead up
- Exclude checks
Gems should be alphabetically sorted within groups.
Example:
# bad
gem 'rubocop'
gem 'rspec'
# good
gem 'rspec'
gem 'rubocop'
# good
gem 'rubocop'
gem 'rspec'
# good only if TreatCommentsAsGroupSeparators is true
# For code quality
gem 'rubocop'
# For tests
gem 'rspec'
Line is too long. [88/80] Open
Caravan::Message.warn("Fail to load conf. Use default instead.")
- Exclude checks
Use the new Ruby 1.9 hash syntax. Open
task :default => :test
- Read upRead up
- Exclude checks
This cop checks hash literal syntax.
It can enforce either the use of the class hash rocket syntax or the use of the newer Ruby 1.9 syntax (when applicable).
A separate offense is registered for each problematic pair.
The supported styles are:
- ruby19 - forces use of the 1.9 syntax (e.g.
{a: 1}
) when hashes have all symbols for keys - hash_rockets - forces use of hash rockets for all hashes
- nomixedkeys - simply checks for hashes with mixed syntaxes
- ruby19nomixed_keys - forces use of ruby 1.9 syntax and forbids mixed syntax hashes
Example: EnforcedStyle: ruby19 (default)
# bad
{:a => 2}
{b: 1, :c => 2}
# good
{a: 2, b: 1}
{:c => 2, 'd' => 2} # acceptable since 'd' isn't a symbol
{d: 1, 'e' => 2} # technically not forbidden
Example: EnforcedStyle: hash_rockets
# bad
{a: 1, b: 2}
{c: 1, 'd' => 5}
# good
{:a => 1, :b => 2}
Example: EnforcedStyle: nomixedkeys
# bad
{:a => 1, b: 2}
{c: 1, 'd' => 2}
# good
{:a => 1, :b => 2}
{c: 1, d: 2}
Example: EnforcedStyle: ruby19nomixed_keys
# bad
{:a => 1, :b => 2}
{c: 2, 'd' => 3} # should just use hash rockets
# good
{a: 1, b: 2}
{:c => 3, 'd' => 4}
Unnecessary utf-8 encoding comment. Open
# coding: utf-8
- Exclude checks
%w
-literals should be delimited by [
and ]
. Open
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), *%w(.. lib)))
- Read upRead up
- Exclude checks
This cop enforces the consistent usage of %
-literal delimiters.
Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.
Example:
# Style/PercentLiteralDelimiters:
# PreferredDelimiters:
# default: '[]'
# '%i': '()'
# good
%w[alpha beta] + %i(gamma delta)
# bad
%W(alpha #{beta})
# bad
%I(alpha beta)
Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency minitest
should appear before rake
. Open
spec.add_development_dependency "minitest", "~> 5.0"
- Read upRead up
- Exclude checks
Dependencies in the gemspec should be alphabetically sorted.
Example:
# bad
spec.add_dependency 'rubocop'
spec.add_dependency 'rspec'
# good
spec.add_dependency 'rspec'
spec.add_dependency 'rubocop'
# good
spec.add_dependency 'rubocop'
spec.add_dependency 'rspec'
# bad
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rspec'
# good
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rubocop'
# good
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rspec'
# bad
spec.add_runtime_dependency 'rubocop'
spec.add_runtime_dependency 'rspec'
# good
spec.add_runtime_dependency 'rspec'
spec.add_runtime_dependency 'rubocop'
# good
spec.add_runtime_dependency 'rubocop'
spec.add_runtime_dependency 'rspec'
# good only if TreatCommentsAsGroupSeparators is true
# For code quality
spec.add_dependency 'rubocop'
# For tests
spec.add_dependency 'rspec'
Line is too long. [91/80] Open
# This is the default theme for new Jekyll sites. You may change this to anything you like.
- Exclude checks