rubinius/rubinius

View on GitHub
core/regexp.rb

Summary

Maintainability
D
2 days
Test Coverage

File regexp.rb has 446 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Regexp
  def self.allocate
    Rubinius.primitive :regexp_allocate
    raise PrimitiveFailure, "Regexp.allocate primitive failed"
  end
Severity: Minor
Found in core/regexp.rb - About 6 hrs to fix

    Class Regexp has 36 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Regexp
      def self.allocate
        Rubinius.primitive :regexp_allocate
        raise PrimitiveFailure, "Regexp.allocate primitive failed"
      end
    Severity: Minor
    Found in core/regexp.rb - About 4 hrs to fix

      Method initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def initialize(pattern, opts=nil, lang=nil)
          if pattern.kind_of?(Regexp)
            opts = pattern.options
            pattern = pattern.source
          elsif pattern.kind_of?(Fixnum) or pattern.kind_of?(Float)
      Severity: Minor
      Found in core/regexp.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 union has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.union(*patterns)
          case patterns.size
          when 0
            return %r/(?!)/
          when 1
      Severity: Minor
      Found in core/regexp.rb - About 1 hr to fix

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

            def create_parts
              while @index < @source.size
                if @source[@index].chr == '('
                  escaped = @index > 0 && @source[@index - 1].chr == '\\'
        
        
        Severity: Minor
        Found in core/regexp.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 union has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.union(*patterns)
            case patterns.size
            when 0
              return %r/(?!)/
            when 1
        Severity: Minor
        Found in core/regexp.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 match has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def match(str, pos=0)
            unless str
              Regexp.last_match = nil
              return nil
            end
        Severity: Minor
        Found in core/regexp.rb - About 45 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 match? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def match?(str, pos=0)
            return false unless str
        
            str = str.to_s if str.is_a?(Symbol)
            str = StringValue(str)
        Severity: Minor
        Found in core/regexp.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

        Method === has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def ===(other)
            if other.kind_of? Symbol
              other = other.to_s
            elsif !other.kind_of? String
              other = Rubinius::Type.check_convert_type other, String, :to_str
        Severity: Minor
        Found in core/regexp.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

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

            def in_group_with_options?
              return false if @source[@index, 1] != '?'
        
              @source[@index + 1..-1].each_byte do |b|
                c = b.chr
        Severity: Minor
        Found in core/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

        There are no issues that match your filters.

        Category
        Status