Showing 687 of 687 total issues
File base.rb
has 303 lines of code (exceeds 250 allowed). Consider refactoring. Open
module RuboCop
module Cop
# A scaffold for concrete cops.
#
# The Cop::Base class is meant to be extended.
Class IfUnlessModifier
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class IfUnlessModifier < Base
include StatementModifier
include LineLengthHelp
include AllowedPattern
include RangeHelp
Method on_block
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def on_block(node)
symbol_proc?(node) do |dispatch_node, arguments_node, method_name|
if active_support_extensions_enabled?
return if proc_node?(dispatch_node)
return if LAMBDA_OR_PROC.include?(dispatch_node.method_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
Class RedundantCondition
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class RedundantCondition < Base
include CommentsHelp
include RangeHelp
extend AutoCorrector
Class SafeNavigation
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class SafeNavigation < Base # rubocop:disable Metrics/ClassLength
include NilMethods
include RangeHelp
extend AutoCorrector
extend TargetRubyVersion
Class SpaceAroundOperators
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class SpaceAroundOperators < Base
include PrecedingFollowingAlignment
include RangeHelp
include RationalLiteral
extend AutoCorrector
Class Team
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class Team
# @return [Team]
def self.new(cop_or_classes, config, options = {})
# Support v0 api:
if cop_or_classes.first.is_a?(Class)
Class EmptyLineBetweenDefs
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class EmptyLineBetweenDefs < Base
include RangeHelp
extend AutoCorrector
MSG = 'Expected %<expected>s between %<type>s definitions; found %<actual>d.'
Class TargetFinder
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class TargetFinder
HIDDEN_PATH_SUBSTRING = "#{File::SEPARATOR}."
def initialize(config_store, options = {})
@config_store = config_store
File cops_documentation_generator.rb
has 290 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'fileutils'
require 'yard'
# Class for generating documentation of all cops departments
# @api private
Method find_previous_older_sibling
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def find_previous_older_sibling(node) # rubocop:disable Metrics
search_node(node).left_siblings.reverse.find do |sibling|
next unless sibling.is_a?(AST::Node)
sibling = sibling_node(sibling)
- 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 LineLength
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class LineLength < Base
include CheckLineBreakable
include AllowedPattern
include RangeHelp
include LineLengthHelp
Method on_new_investigation
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def on_new_investigation # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
processed_source.comments.each do |comment|
next unless /\A(?!#\+\+|#--)(#+[^#\s=])/.match?(comment.text)
next if comment.loc.line == 1 && allowed_on_first_line?(comment)
next if doxygen_comment_style?(comment)
- 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 InclusiveLanguage
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class InclusiveLanguage < Base
include RangeHelp
extend AutoCorrector
EMPTY_ARRAY = [].freeze
Class Changelog
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Changelog
ENTRIES_PATH = 'changelog/'
FIRST_HEADER = /#{Regexp.escape("## master (unreleased)\n")}/m.freeze
ENTRIES_PATH_TEMPLATE = "#{ENTRIES_PATH}%<type>s_%<name>s.md"
TYPE_REGEXP = /#{Regexp.escape(ENTRIES_PATH)}([a-z]+)_/.freeze
Class FileName
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class FileName < Base
include RangeHelp
MSG_SNAKE_CASE = 'The name of this source file (`%<basename>s`) should use snake_case.'
MSG_NO_DEFINITION = '`%<basename>s` should define a class or module called `%<namespace>s`.'
Class SoleNestedConditional
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class SoleNestedConditional < Base
include RangeHelp
extend AutoCorrector
MSG = 'Consider merging nested conditions into outer `%<conditional_type>s` conditions.'
Class SendNodeClassifier
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class SendNodeClassifier
extend NodePattern::Macros
# @!method forwarded_rest_arg?(node, rest_name)
def_node_matcher :forwarded_rest_arg?, '(splat (lvar %1))'
Class ConditionalAssignment
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class ConditionalAssignment < Base
include ConditionalAssignmentHelper
include ConfigurableEnforcedStyle
include IgnoredNode
extend AutoCorrector
Method each_already_disabled
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def each_already_disabled(cop, line_ranges)
line_ranges.each_cons(2) do |previous_range, range|
next if ignore_offense?(range)
# If a cop is disabled in a range that begins on the same line as
# the end of the previous range, it means that the cop was
- 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"