lib/rdoc/method_attr.rb

Summary

Maintainability
C
1 day
Test Coverage

Class MethodAttr has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

class RDoc::MethodAttr < RDoc::CodeObject

  include Comparable

  ##
Severity: Minor
Found in lib/rdoc/method_attr.rb - About 3 hrs to fix

    Method find_method_or_attribute has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def find_method_or_attribute name # :nodoc:
        return nil unless parent.respond_to? :ancestors
    
        searched = parent.ancestors
        kernel = @store.modules_hash['Kernel']
    Severity: Minor
    Found in lib/rdoc/method_attr.rb - About 1 hr 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 block_params= has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def block_params=(value)
        # 'yield.to_s' or 'assert yield, msg'
        return @block_params = '' if value =~ /^[\.,]/
    
        # remove trailing 'if/unless ...'
    Severity: Minor
    Found in lib/rdoc/method_attr.rb - About 1 hr 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 block_params= has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def block_params=(value)
        # 'yield.to_s' or 'assert yield, msg'
        return @block_params = '' if value =~ /^[\.,]/
    
        # remove trailing 'if/unless ...'
    Severity: Minor
    Found in lib/rdoc/method_attr.rb - About 1 hr to fix

      Method pretty_print has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def pretty_print q # :nodoc:
          alias_for =
            if @is_alias_for.respond_to? :name then
              "alias for #{@is_alias_for.name}"
            elsif Array === @is_alias_for then
      Severity: Minor
      Found in lib/rdoc/method_attr.rb - About 55 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 <=> has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def <=>(other)
          return unless other.respond_to?(:singleton) &&
                        other.respond_to?(:name)
      
          [     @singleton ? 0 : 1,       name] <=>
      Severity: Minor
      Found in lib/rdoc/method_attr.rb - About 35 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

      Avoid too many return statements within this method.
      Open

          return @block_params = 'str' if value =~ /^\$[&0-9]$/
      Severity: Major
      Found in lib/rdoc/method_attr.rb - About 30 mins to fix

        There are no issues that match your filters.

        Category
        Status