Method has too many lines. [44/10] Open
def post(options = {})
tags = [options[:tags] || []].flatten
title = options[:title].to_s
permlink = options[:permlink] || title.downcase.gsub(/[^a-z0-9\-]+/, '-')
parent_permlink = options[:parent_permlink] || tags[0]
- 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.
Assignment Branch Condition size for post is too high. [44.96/15] Open
def post(options = {})
tags = [options[:tags] || []].flatten
title = options[:title].to_s
permlink = options[:permlink] || title.downcase.gsub(/[^a-z0-9\-]+/, '-')
parent_permlink = options[:parent_permlink] || tags[0]
- 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
Cyclomatic complexity for post is too high. [16/6] Open
def post(options = {})
tags = [options[:tags] || []].flatten
title = options[:title].to_s
permlink = options[:permlink] || title.downcase.gsub(/[^a-z0-9\-]+/, '-')
parent_permlink = options[:parent_permlink] || tags[0]
- 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.
Perceived complexity for post is too high. [16/7] Open
def post(options = {})
tags = [options[:tags] || []].flatten
title = options[:title].to_s
permlink = options[:permlink] || title.downcase.gsub(/[^a-z0-9\-]+/, '-')
parent_permlink = options[:parent_permlink] || tags[0]
- 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
Method post
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def post(options = {})
tags = [options[:tags] || []].flatten
title = options[:title].to_s
permlink = options[:permlink] || title.downcase.gsub(/[^a-z0-9\-]+/, '-')
parent_permlink = options[:parent_permlink] || tags[0]
Method post
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def post(options = {})
tags = [options[:tags] || []].flatten
title = options[:title].to_s
permlink = options[:permlink] || title.downcase.gsub(/[^a-z0-9\-]+/, '-')
parent_permlink = options[:parent_permlink] || tags[0]
- 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
Align )
with (
. Open
) || !!percent_hbd || !allow_votes || !allow_curation_rewards
- Read upRead up
- Exclude checks
This cops checks the indentation of hanging closing parentheses in
method calls, method definitions, and grouped expressions. A hanging
closing parenthesis means )
preceded by a line break.
Example:
# good: when x is on its own line, indent this way
func(
x,
y
)
# good: when x follows opening parenthesis, align parentheses
a = b * (x +
y
)
# bad
def func(
x,
y
)
end
Trailing whitespace detected. Open
- Exclude checks
Trailing whitespace detected. Open
- Exclude checks
Line is too long. [106/80] Open
# steem = Radiator::Chain.new(chain: :steem, account_name: 'your account name', wif: 'your wif')
- Exclude checks
Missing top-level module documentation comment. Open
module ActsAsPoster
- Read upRead up
- Exclude checks
This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.
The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.
Example:
# bad
class Person
# ...
end
# good
# Description/Explanation of Person class
class Person
# ...
end
Line is too long. [105/80] Open
# @option options [String] :permlink (automatic) Permlink of the post, defaults to formatted title.
- Exclude checks
Line is too long. [113/80] Open
# @option options [String] :parent_permlink (automatic) Parent permlink of the post, defaults to first tag.
- Exclude checks
Line is too long. [105/80] Open
# @option options [Integer] :percent_hbd (5000) Percent HBD is used to set 50/50 or 100% HIVE Power
- Exclude checks
Trailing whitespace detected. Open
- Exclude checks
Avoid single-line method definitions. Open
def post!(options = {}); post(options).broadcast!(true); end
- Read upRead up
- Exclude checks
This cop checks for single-line method definitions that contain a body. It will accept single-line methods with no body.
Example:
# bad
def some_method; body end
def link_to(url); {:name => url}; end
def @table.columns; super; end
# good
def no_op; end
def self.resource_class=(klass); end
def @table.columns; end
Avoid single-line method definitions. Open
def delete_comment!(permlink); delete_comment(permlink).broadcast!(true); end
- Read upRead up
- Exclude checks
This cop checks for single-line method definitions that contain a body. It will accept single-line methods with no body.
Example:
# bad
def some_method; body end
def link_to(url); {:name => url}; end
def @table.columns; super; end
# good
def no_op; end
def self.resource_class=(klass); end
def @table.columns; end
Trailing whitespace detected. Open
- Exclude checks
Line is too long. [106/80] Open
# steem = Radiator::Chain.new(chain: :steem, account_name: 'your account name', wif: 'your wif')
- Exclude checks
Trailing whitespace detected. Open
- Exclude checks
Trailing whitespace detected. Open
- Exclude checks
Trailing whitespace detected. Open
- Exclude checks
Avoid the use of double negation (!!
). Open
) || !!percent_hbd || !allow_votes || !allow_curation_rewards
- Read upRead up
- Exclude checks
This cop checks for uses of double negation (!!) to convert something to a boolean value. As this is both cryptic and usually redundant, it should be avoided.
Example:
# bad
!!something
# good
!something.nil?
Please, note that when something is a boolean value !!something and !something.nil? are not the same thing. As you're unlikely to write code that can accept values of any type this is rarely a problem in practice.
Trailing whitespace detected. Open
- Exclude checks
Trailing whitespace detected. Open
- Exclude checks
Trailing whitespace detected. Open
- Exclude checks
Line is too long. [116/80] Open
raise ChainError, 'At least one tag is required or set the parent_permlink directy.' if parent_permlink.nil?
- Exclude checks
Line is too long. [106/80] Open
# steem = Radiator::Chain.new(chain: :steem, account_name: 'your account name', wif: 'your wif')
- Exclude checks
Trailing whitespace detected. Open
- Exclude checks
Line is too long. [83/80] Open
def delete_comment!(permlink); delete_comment(permlink).broadcast!(true); end
- Exclude checks
Line is too long. [89/80] Open
max_accepted_payout = options[:max_accepted_payout] || default_max_acepted_payout
- Exclude checks
Line is too long. [81/80] Open
permlink = options[:permlink] || title.downcase.gsub(/[^a-z0-9\-]+/, '-')
- Exclude checks
Line is too long. [106/80] Open
# @option options [String] :parent_author (optional) Parent author of the post (only used if reply).
- Exclude checks
Trailing whitespace detected. Open
- Exclude checks
Avoid the use of double negation (!!
). Open
if (!!max_accepted_payout &&
- Read upRead up
- Exclude checks
This cop checks for uses of double negation (!!) to convert something to a boolean value. As this is both cryptic and usually redundant, it should be avoided.
Example:
# bad
!!something
# good
!something.nil?
Please, note that when something is a boolean value !!something and !something.nil? are not the same thing. As you're unlikely to write code that can accept values of any type this is rarely a problem in practice.
Avoid the use of double negation (!!
). Open
vote(self_vote, account_name, permlink) if !!self_vote
- Read upRead up
- Exclude checks
This cop checks for uses of double negation (!!) to convert something to a boolean value. As this is both cryptic and usually redundant, it should be avoided.
Example:
# bad
!!something
# good
!something.nil?
Please, note that when something is a boolean value !!something and !something.nil? are not the same thing. As you're unlikely to write code that can accept values of any type this is rarely a problem in practice.
Line is too long. [106/80] Open
# steem = Radiator::Chain.new(chain: :steem, account_name: 'your account name', wif: 'your wif')
- Exclude checks
Line is too long. [132/80] Open
# @option options [String] :max_accepted_payout (1000000.000 SBD) Maximum accepted payout, set to '0.000 SBD' to deline payout
- Exclude checks
Line is too long. [102/80] Open
# @option options [Integer] :allow_curation_rewards (true) Allow curation rewards for this post.
- Exclude checks