compleatang/legal-markdown

View on GitHub

Showing 28 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      def guard_strings strings
        strings.scan(/\:(\S.*)$/){ |m| strings = strings.gsub( m[0], " " + m[0] ) }
        strings.scan(/^((level-\d+:)(.+)\"*)$/) do |m|
          line = m[0]; level = m[1]; field = m[2].strip.delete "\""
          if field =~ /[^\.\)]\z/
    Severity: Major
    Found in lib/legal_markdown/make_yaml_frontmatter.rb and 1 other location - About 1 hr to fix
    lib/legal_markdown/legal_to_markdown/load_source.rb on lines 90..100

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 66.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        def string_guard strings
          strings.scan(/\:(\S.*)$/){ |m| strings = strings.gsub( m[0], " " + m[0] ) }
          strings.scan(/^((level-\d+:)(.+)\"*)$/) do |m|
            line = m[0]; level = m[1]; field = m[2].strip.delete "\""
            if field =~ /[^\.\)]\z/
    Severity: Major
    Found in lib/legal_markdown/legal_to_markdown/load_source.rb and 1 other location - About 1 hr to fix
    lib/legal_markdown/make_yaml_frontmatter.rb on lines 143..153

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 66.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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
              Severity
              Category
              Status
              Source
              Language