troessner/reek

View on GitHub
samples/smelly_source/redcloth.rb

Summary

Maintainability
F
1 wk
Test Coverage

File redcloth.rb has 720 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class RedCloth < String

    VERSION = '3.0.4'
    DEFAULT_RULES = [:textile, :markdown]

Severity: Major
Found in samples/smelly_source/redcloth.rb - About 1 day to fix

    Method rip_offtags has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

        def rip_offtags( text )
            if text =~ /<.*>/
                ## strip and encode <pre> content
                codepre, used_offtags = 0, {}
                text.gsub!( OFFTAG_MATCH ) do |line|
    Severity: Minor
    Found in samples/smelly_source/redcloth.rb - About 6 hrs 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_textile_lists has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

        def block_textile_lists( text ) 
            text.gsub!( LISTS_RE ) do |match|
                lines = match.split( /\n/ )
                last_line = -1
                depth = []
    Severity: Minor
    Found in samples/smelly_source/redcloth.rb - About 6 hrs 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

    Class RedCloth has 44 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class RedCloth < String
    
        VERSION = '3.0.4'
        DEFAULT_RULES = [:textile, :markdown]
    
    
    Severity: Minor
    Found in samples/smelly_source/redcloth.rb - About 6 hrs to fix

      Method blocks has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          def blocks( text, deep_code = false )
              text.replace( text.split( BLOCKS_GROUP_RE ).collect do |blk|
                  plain = blk !~ /\A[#*> ]/
      
                  # skip blocks that are complex HTML
      Severity: Minor
      Found in samples/smelly_source/redcloth.rb - About 4 hrs 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 clean_html has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

          def clean_html( text, tags = BASIC_TAGS )
              text.gsub!( /<!\[CDATA\[/, '' )
              text.gsub!( /<(\/*)(\w+)([^>]*)>/ ) do
                  raw = $~
                  tag = raw[2].downcase
      Severity: Minor
      Found in samples/smelly_source/redcloth.rb - About 4 hrs 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_textile_table has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          def block_textile_table( text ) 
              text.gsub!( TABLE_RE ) do |matches|
      
                  tatts, fullrow = $~[1..2]
                  tatts = pba( tatts, 'table' )
      Severity: Minor
      Found in samples/smelly_source/redcloth.rb - About 3 hrs 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 pba has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          def pba( text_in, element = "" )
              
              return '' unless text_in
      
              style = []
      Severity: Minor
      Found in samples/smelly_source/redcloth.rb - About 3 hrs 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 glyphs_textile has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def glyphs_textile( text, level = 0 )
              if text !~ HASTAG_MATCH
                  pgl text
                  footnote_ref text
              else
      Severity: Minor
      Found in samples/smelly_source/redcloth.rb - About 2 hrs 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 inline_textile_image has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def inline_textile_image( text ) 
              text.gsub!( IMAGE_RE )  do |m|
                  stln,algn,atts,url,title,href,href_a1,href_a2 = $~[1..8]
                  atts = pba( atts )
                  atts = " src=\"#{ url }\"#{ atts }"
      Severity: Minor
      Found in samples/smelly_source/redcloth.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_textile_lists has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def block_textile_lists( text ) 
              text.gsub!( LISTS_RE ) do |match|
                  lines = match.split( /\n/ )
                  last_line = -1
                  depth = []
      Severity: Minor
      Found in samples/smelly_source/redcloth.rb - About 1 hr to fix

        Method to_html has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def to_html( *rules )
                rules = DEFAULT_RULES if rules.empty?
                # make our working copy
                text = self.dup
                
        Severity: Minor
        Found in samples/smelly_source/redcloth.rb - About 1 hr to fix

          Method blocks has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def blocks( text, deep_code = false )
                  text.replace( text.split( BLOCKS_GROUP_RE ).collect do |blk|
                      plain = blk !~ /\A[#*> ]/
          
                      # skip blocks that are complex HTML
          Severity: Minor
          Found in samples/smelly_source/redcloth.rb - About 1 hr to fix

            Method rip_offtags has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def rip_offtags( text )
                    if text =~ /<.*>/
                        ## strip and encode <pre> content
                        codepre, used_offtags = 0, {}
                        text.gsub!( OFFTAG_MATCH ) do |line|
            Severity: Minor
            Found in samples/smelly_source/redcloth.rb - About 1 hr to fix

              Method pba has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def pba( text_in, element = "" )
                      
                      return '' unless text_in
              
                      style = []
              Severity: Minor
              Found in samples/smelly_source/redcloth.rb - About 1 hr to fix

                Method block_textile_table has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def block_textile_table( text ) 
                        text.gsub!( TABLE_RE ) do |matches|
                
                            tatts, fullrow = $~[1..2]
                            tatts = pba( tatts, 'table' )
                Severity: Minor
                Found in samples/smelly_source/redcloth.rb - About 1 hr to fix

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

                      def flush_left( text )
                          indt = 0
                          if text =~ /^ /
                              while text !~ /^ {#{indt}}\S/
                                  indt += 1
                  Severity: Minor
                  Found in samples/smelly_source/redcloth.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 inline_textile_span has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def inline_textile_span( text ) 
                          QTAGS.each do |qtag_rc, ht, qtag_re, rtype|
                              text.gsub!( qtag_re ) do |m|
                               
                                  case rtype
                  Severity: Minor
                  Found in samples/smelly_source/redcloth.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

                  Avoid deeply nested control flow statements.
                  Open

                                          htmlesc( line, :NoQuotes ) unless used_offtags['notextile']
                  Severity: Major
                  Found in samples/smelly_source/redcloth.rb - About 45 mins to fix

                    Method textile_fn_ has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def textile_fn_( tag, num, atts, cite, content )
                    Severity: Minor
                    Found in samples/smelly_source/redcloth.rb - About 35 mins to fix

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

                          def to_html( *rules )
                              rules = DEFAULT_RULES if rules.empty?
                              # make our working copy
                              text = self.dup
                              
                      Severity: Minor
                      Found in samples/smelly_source/redcloth.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