compleatang/legal-markdown

View on GitHub

Showing 26 of 28 total issues

Method increment_the_branch has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def increment_the_branch( array_to_sub, selector, next_selector )
      if selector > next_selector                                         #going up the tree and reset
        selectors_to_reset = @substitutions.inject([]){ |m,(k,v)| m << k if k > next_selector; m }
        selectors_to_reset.each do | this_selector |
          substitutor = @substitutions[this_selector]
Severity: Minor
Found in lib/legal_markdown/legal_to_markdown/leaders.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

File leaders.rb has 297 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module LegalToMarkdown
  extend self

  module Leaders

Severity: Minor
Found in lib/legal_markdown/legal_to_markdown/leaders.rb - About 3 hrs to fix

    Method get_the_levels has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_the_levels
          begin
            @headers.each do | header, value |
              if @deep_leaders
                search = "l" + header[-1] + "." if header =~ /level-\d/
    Severity: Minor
    Found in lib/legal_markdown/legal_to_markdown/leaders.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 build_jason has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def build_jason
          if @content.is_a?(Array)
            @content[0] = build_header_and_text_hashs @content[0] unless @content[0].empty?
            @content[2] = build_header_and_text_hashs @content[2] unless @content[2].empty?
            content_hash = {}
    Severity: Minor
    Found in lib/legal_markdown/legal_to_markdown/json_builder.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 build_the_block_for_jason has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def build_the_block_for_jason( arrayed_block )
          require 'securerandom'
          annotations_hash = {}
          provisions_hash = arrayed_block.inject({}) do |block, arrayed_line|
            (sub_it, reference, selector, arrayed_line) = block_builder arrayed_line
    Severity: Minor
    Found in lib/legal_markdown/legal_to_markdown/leaders.rb - About 1 hr to fix

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

        def write_it( final_content, writer )
          final_content = final_content.gsub(/ +\n/, "\n") if writer == :markdown
          require 'json' if writer == :jason
          if @output_file && @output_file != "-"
            File.open(@output_file, "w") {|f| f.write( final_content ); f.close } if writer == :markdown
      Severity: Minor
      Found in lib/legal_markdown/legal_to_markdown/writer.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 verbose_after_process has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def verbose_after_process source, action
          if @verbose
            puts
            puts Paint["Here's what I found after running the #{action}.", :blue, :bold]
            puts Paint['=============================================', :blue]
      Severity: Minor
      Found in lib/legal_markdown/legal_to_markdown.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 clauses_churn_add has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def clauses_churn_add
            @clauses_added.each do | mixin |
              pattern = /(\[\{\{#{mixin}\}\}\s*?)(.*?\n*?)(\])/m
              sub_pattern = /\[\{\{(\S+?)\}\}\s*?/
              @content[pattern]
      Severity: Minor
      Found in lib/legal_markdown/legal_to_markdown/mixins.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 clauses_churn_delete has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def clauses_churn_delete
            @clauses_deleted.each do | mixin |
              pattern = /(\[\{\{#{mixin}\}\}\s*?)(.*?\n*?)(\])/m
              sub_pattern = /\[\{\{(\S+?)\}\}\s*?/
              @content[pattern]
      Severity: Minor
      Found in lib/legal_markdown/legal_to_markdown/mixins.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 chew_on_the_block has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def chew_on_the_block
            # @substitutions hash example
            # {"ll."OR "l2."=>[:type8, "Article ", "(", "1", ")", :no_reset || nil, :no_indent || nil, :preval || :pre || nil],}
            @cross_references = {}
            arrayed_block = []
      Severity: Minor
      Found in lib/legal_markdown/legal_to_markdown/leaders.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 build_the_block_for_jason has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def build_the_block_for_jason( arrayed_block )
            require 'securerandom'
            annotations_hash = {}
            provisions_hash = arrayed_block.inject({}) do |block, arrayed_line|
              (sub_it, reference, selector, arrayed_line) = block_builder arrayed_line
      Severity: Minor
      Found in lib/legal_markdown/legal_to_markdown/leaders.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 log_the_key has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def log_the_key( block, sub_it, reference, selector, arrayed_line, arrayed_block )
      Severity: Minor
      Found in lib/legal_markdown/legal_to_markdown/leaders.rb - About 45 mins to fix

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

            def build_an_annotation( start, stop, cite, parent, substitution )
        Severity: Minor
        Found in lib/legal_markdown/legal_to_markdown/leaders.rb - About 35 mins to fix

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

            def filter_yaml pattern
              # @headers will be a hash, stuff is an array, returns a filtered hash
              stuff = pattern.is_a?(Regexp) ? scan_doc(pattern) : pattern
              if stuff
                stuff_in_yaml = stuff.inject({}) do |hash, elem|
          Severity: Minor
          Found in lib/legal_markdown/make_yaml_frontmatter.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 build_new_yaml_frontmatter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def build_new_yaml_frontmatter
              @content = "\n---\n\n" + @content
              replacers = {0=>"Mixins", 1=>"Optional Clauses", 2=>"Structured Headers", 3=>"Properties", 4=>"Document Meta-Data"}
              stringy = @yaml_data_as_array.inject("") do |string, section|
                unless section.empty?
          Severity: Minor
          Found in lib/legal_markdown/make_yaml_frontmatter.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 text_mixins has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def text_mixins
                @headers.each do | mixin, replacer |
                  unless mixin =~ /level-\d/ or mixin =~ /no-reset/ or mixin =~ /no-indent/ or mixin =~ /level-style/
                    replacer = replacer.to_s
                    mixin_pattern = /(\{\{#{mixin}\}\})/
          Severity: Minor
          Found in lib/legal_markdown/legal_to_markdown/mixins.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[:type6, value.delete("(" + $1 + ")"), "(", $1, ")"]
          Severity: Major
          Found in lib/legal_markdown/legal_to_markdown/leaders.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return[:type9, value.delete("(" + $1 + ")"), "(", $1, ")"]
            Severity: Major
            Found in lib/legal_markdown/legal_to_markdown/leaders.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return[:type0, value.delete($1 + "."), "", $1, "."]
              Severity: Major
              Found in lib/legal_markdown/legal_to_markdown/leaders.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return[:type7, value.delete($1 + "."), "", $1, "."]
                Severity: Major
                Found in lib/legal_markdown/legal_to_markdown/leaders.rb - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language