tom-lord/regexp-examples

View on GitHub

Showing 5 of 5 total issues

Method parse_multi_group has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def parse_multi_group
      # TODO: Clean up this ugly mess of a method!
      @current_position += 1
      @num_groups += 1
      remember_old_regexp_options do
Severity: Major
Found in lib/regexp-examples/parser_helpers/parse_multi_group_helper.rb - About 2 hrs to fix

    Method parse_multi_group has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_multi_group
          # TODO: Clean up this ugly mess of a method!
          @current_position += 1
          @num_groups += 1
          remember_old_regexp_options do
    Severity: Minor
    Found in lib/regexp-examples/parser_helpers/parse_multi_group_helper.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 parse_after_backslash_group has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_after_backslash_group
          @current_position += 1
          if rest_of_string =~ /\A(\d{1,3})/
            parse_regular_backreference_group(Regexp.last_match(1))
          elsif rest_of_string =~ /\Ak['<]([\w-]+)['>]/

    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 parse_after_backslash_group has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def parse_after_backslash_group
          @current_position += 1
          if rest_of_string =~ /\A(\d{1,3})/
            parse_regular_backreference_group(Regexp.last_match(1))
          elsif rest_of_string =~ /\Ak['<]([\w-]+)['>]/

      Method calculate_ranges has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def calculate_ranges(matching_codes)
        return [] if matching_codes.empty?
        first = matching_codes.shift
        matching_codes.inject([first..first]) do |r, x|
          if r.last.last.succ != x
      Severity: Minor
      Found in scripts/unicode_lister.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

      Severity
      Category
      Status
      Source
      Language