bbatsov/rubocop

View on GitHub

Showing 672 of 672 total issues

Method find_ancestor_method_dispatch_node has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def find_ancestor_method_dispatch_node(node)
        return unless (ancestor = node.parent.parent)
        return unless ancestor.call_type? || ancestor.super_type? || ancestor.yield_type?
        return if brackets?(ancestor)

Severity: Minor
Found in lib/rubocop/cop/mixin/hash_shorthand_syntax.rb - About 25 mins to fix

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 autocorrect_enabled? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def autocorrect_enabled?
        # allow turning off autocorrect on a cop by cop basis
        return true unless cop_config

        # `false` is the same as `disabled` for backward compatibility.
Severity: Minor
Found in lib/rubocop/cop/autocorrect_logic.rb - About 25 mins to fix

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 on_send has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_send(node)
          insecure_protocol_source?(node) do |source_node|
            source = source_node.value
            use_http_protocol = source == 'http://rubygems.org'

Severity: Minor
Found in lib/rubocop/cop/bundler/insecure_protocol_source.rb - About 25 mins to fix

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 on_defined? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_defined?(node)
          arg = node.first_argument
          return false unless arg.ivar_type?

          method_node, method_name = find_definition(node)
Severity: Minor
Found in lib/rubocop/cop/naming/memoized_instance_variable_name.rb - About 25 mins to fix

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 part_of_ignored_node? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def part_of_ignored_node?(node)
        ignored_nodes.map(&:loc).any? do |ignored_loc|
          next false if ignored_loc.expression.begin_pos > node.source_range.begin_pos

          ignored_end_pos = if ignored_loc.respond_to?(:heredoc_body)
Severity: Minor
Found in lib/rubocop/cop/ignored_node.rb - About 25 mins to fix

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 traverse_files_upwards has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def traverse_files_upwards(filename, start_dir, stop_dir)
      Pathname.new(start_dir).expand_path.ascend do |dir|
        file = dir + filename
        yield(file.to_s) if file.exist?

Severity: Minor
Found in lib/rubocop/file_finder.rb - About 25 mins to fix

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 on_interpolation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_interpolation(begin_node)
          final_node = begin_node.children.last
          return unless offending?(final_node)

          # %W and %I split the content into words before expansion
Severity: Minor
Found in lib/rubocop/cop/lint/literal_in_interpolation.rb - About 25 mins to fix

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 on_send has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_send(node)
          return unless redundant_require_statement?(node)

          add_offense(node) do |corrector|
            if node.parent.respond_to?(:modifier_form?) && node.parent.modifier_form?
Severity: Minor
Found in lib/rubocop/cop/lint/redundant_require_statement.rb - About 25 mins to fix

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 on_block has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_block(node)
          return unless node.body
          return unless reduce_with_block?(node)
          return unless node.argument_list.length >= 2

Severity: Minor
Found in lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb - About 25 mins to fix

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 group_expressions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def group_expressions(node, expressions)
          # Create a mutable list to simplify state tracking while we iterate.
          expressions = expressions.to_a

          until expressions.empty?
Severity: Minor
Found in lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb - About 25 mins to fix

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 autocorrect_sclass has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def autocorrect_sclass(node, corrector)
          rewritten_defs = []

          def_nodes(node).each do |def_node|
            next unless node_visibility(def_node) == :public
Severity: Minor
Found in lib/rubocop/cop/style/class_methods_definitions.rb - About 25 mins to fix

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 sample_size_for_one_arg has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def sample_size_for_one_arg(arg)
          if arg.range_type?
            range_size(arg)
          elsif arg.int_type?
            [0, -1].include?(arg.to_a.first) ? nil : :unknown
Severity: Minor
Found in lib/rubocop/cop/style/sample.rb - About 25 mins to fix

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 on_new_investigation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_new_investigation
          processed_source.comments.each do |comment|
            next if comment.text.ascii_only?
            next if only_allowed_non_ascii_chars?(comment.text)

Severity: Minor
Found in lib/rubocop/cop/style/ascii_comments.rb - About 25 mins to fix

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 check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def check(node)
          return unless node.else_branch

          if node.else? && node.loc.else.is?('else')
            check_else(node)
Severity: Minor
Found in lib/rubocop/cop/lint/else_layout.rb - About 25 mins to fix

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 top_conditional_ancestor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def top_conditional_ancestor(node)
          parent = node.parent
          unless parent &&
                 (parent.operator_keyword? ||
                  (parent.begin_type? && parent.parent && parent.parent.operator_keyword?))
Severity: Minor
Found in lib/rubocop/cop/lint/safe_navigation_consistency.rb - About 25 mins to fix

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 register_offense has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def register_offense(comment, cop_names)
          directive = DirectiveComment.new(comment)

          cop_names.each do |name|
            name = name.split('/').first if department?(directive, name)
Severity: Minor
Found in lib/rubocop/cop/lint/redundant_cop_enable_directive.rb - About 25 mins to fix

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 on_return has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_return(return_node)
          return unless return_node.descendants.any?

          context_node = non_void_context(return_node)

Severity: Minor
Found in lib/rubocop/cop/lint/return_in_void_context.rb - About 25 mins to fix

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 on_send has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_send(node)
          return unless node.receiver
          return unless URI_CONSTANTS.include?(node.receiver.source)

          argument = node.first_argument ? "(#{node.first_argument.source})" : ''
Severity: Minor
Found in lib/rubocop/cop/lint/uri_regexp.rb - About 25 mins to fix

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 on_sclass has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_sclass(node)
          return unless def_self_style?
          return unless node.identifier.self_type?
          return unless all_methods_public?(node)

Severity: Minor
Found in lib/rubocop/cop/style/class_methods_definitions.rb - About 25 mins to fix

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 any_assignment? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def any_assignment?(node)
          node.each_ancestor(*AST::Node::ASSIGNMENTS).any? do |asgn_node|
            # `obj.method = value` parses as (send ... :method= ...), and will
            # not be returned as an `asgn_node` here, however,
            # `obj.method ||= value` parses as (or-asgn (send ...) ...)
Severity: Minor
Found in lib/rubocop/cop/style/method_call_without_args_parentheses.rb - About 25 mins to fix

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

Severity
Category
Status
Source
Language