metanorma/metanorma-standoc

View on GitHub

Showing 61 of 88 total issues

Class PlantumlRenderer has 42 methods (exceeds 20 allowed). Consider refactoring.
Open

    class PlantumlRenderer
      TEMPLATES_PATH = File.expand_path("../views/datamodel", __dir__).freeze

      attr_reader :yml, :plantuml_path

Severity: Minor
Found in lib/metanorma/standoc/datamodel/plantuml_renderer.rb - About 5 hrs to fix

    File plantuml_renderer.rb has 315 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "erb"
    
    module Metanorma
      module Datamodel
        class PlantumlRenderer
    Severity: Minor
    Found in lib/metanorma/standoc/datamodel/plantuml_renderer.rb - About 3 hrs to fix

      Class TermLookupCleanup has 28 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class TermLookupCleanup
            AUTO_GEN_ID_REGEXP = /\A_/.freeze
      
            attr_reader :xmldoc, :lookup, :log
      
      
      Severity: Minor
      Found in lib/metanorma/standoc/term_lookup_cleanup.rb - About 3 hrs to fix

        Method terms_subclause_type_tally has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

              def terms_subclause_type_tally(node, m, parent)
                sym = if (node.at(".//term") && !node.at(".//definitions")) ||
                    (node.name == "terms" && !node.at(".//term"))
                        unless m[:parent] == :term # don't count Term > Term twice
                          :term
        Severity: Minor
        Found in lib/metanorma/standoc/cleanup_section_names.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 cleanup has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def cleanup(xmldoc)
                @doctype = xmldoc.at("//bibdata/ext/doctype")&.text
                element_name_cleanup(xmldoc)
                passthrough_cleanup(xmldoc)
                unnumbered_blocks_cleanup(xmldoc)
        Severity: Major
        Found in lib/metanorma/standoc/cleanup.rb - About 2 hrs to fix

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

                def section(node)
                  a = section_attributes(node)
                  noko do |xml|
                    case sectiontype(node)
                    when "misc-container", "metanorma-extension"
          Severity: Minor
          Found in lib/metanorma/standoc/section.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 span_preprocess1 has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def span_preprocess1(span, ret)
                    case span[:key]
                    when "uri", "docid"
                      val = link_unwrap(Nokogiri::XML.fragment(span[:val])).to_xml
                      ret[span[:key].to_sym] << { type: span[:type], val: val }
          Severity: Minor
          Found in lib/metanorma/standoc/spans_to_bibitem_preprocessing.rb - About 1 hr to fix

            Method init_iev_caches has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                  def init_iev_caches(node)
                    unless @no_isobib_cache || @no_isobib
                      node.attr("local-cache-only") or
                        @iev_globalname = global_ievcache_name
                      @iev_localname = local_ievcache_name(node.attr("local-cache") ||
            Severity: Minor
            Found in lib/metanorma/standoc/ref_queue.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 section has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def section(node)
                    a = section_attributes(node)
                    noko do |xml|
                      case sectiontype(node)
                      when "misc-container", "metanorma-extension"
            Severity: Minor
            Found in lib/metanorma/standoc/section.rb - About 1 hr to fix

              Method filter_sections has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                    def filter_sections(lines, headings)
                      skip = false
                      lines.each_with_index.with_object([]) do |(l, i), m|
                        if headings.include?(l.strip)
                          skip = true
              Severity: Minor
              Found in lib/metanorma/standoc/macros_embed.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 doc_extract_attributes has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def doc_extract_attributes(node)
                      attrs = {
                        script: node.attr("script"),
                        bodyfont: node.attr("body-font"),
                        headerfont: node.attr("header-font"),
              Severity: Minor
              Found in lib/metanorma/standoc/render.rb - About 1 hr to fix

                Method html_extract_attributes has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def html_extract_attributes(node)
                        {
                          script: node.attr("script"),
                          bodyfont: node.attr("body-font"),
                          headerfont: node.attr("header-font"),
                Severity: Minor
                Found in lib/metanorma/standoc/render.rb - About 1 hr to fix

                  Method inline_quoted has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def inline_quoted(node)
                          noko do |xml|
                            case node.type
                            when :emphasis then xml.em { |s| s << node.text }
                            when :strong then xml.strong { |s| s << node.text }
                  Severity: Minor
                  Found in lib/metanorma/standoc/inline.rb - About 1 hr to fix

                    Consider simplifying this complex logical expression.
                    Open

                              next if l.empty? || l.match(/ \+$/) || /^\[.*\]$/.match?(l) ||
                                ignore || i == lines.size - 1 ||
                                (i < lines.size - 1 && lines[i + 1].empty?)
                    Severity: Major
                    Found in lib/metanorma/standoc/macros.rb - About 1 hr to fix

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

                            def pass_status(status, text)
                              text == "++++" && !status[:delimln] and status[:pass] = !status[:pass]
                              status[:midline_docattr] && !/^:[^ :]+: /.match?(text) and
                                status[:midline_docattr] = false
                              if (status[:is_delim] && /^(-+|\*+|=+|_+)$/.match?(text)) ||
                      Severity: Minor
                      Found in lib/metanorma/standoc/macros.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 section_attributes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def section_attributes(node)
                              ret =
                                { id: Metanorma::Utils::anchor_or_uuid(node),
                                  unnumbered: node.option?("unnumbered") ? "true" : nil,
                                  annex: role_style(node, "appendix") && node.level == 1 ? true : nil,
                      Severity: Minor
                      Found in lib/metanorma/standoc/section.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 strip_header has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def strip_header(lines)
                              return { lines: lines, hdr: nil } unless !lines.empty? &&
                                lines.first.start_with?("= ")
                      
                              skip = true
                      Severity: Minor
                      Found in lib/metanorma/standoc/macros_embed.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 maxcols_validate1 has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                            def maxcols_validate1(tcell, row, curr, cells2d, maxcols, mode)
                      Severity: Minor
                      Found in lib/metanorma/standoc/validate_table.rb - About 45 mins to fix

                        Method isorefmatches3_1 has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                              def isorefmatches3_1(xml, match, code, year, _hasyr, _ref)
                        Severity: Minor
                        Found in lib/metanorma/standoc/ref.rb - About 45 mins to fix

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

                                def uninterrupt_quotes_around_xml(xmldoc)
                                  xmldoc.traverse do |n|
                                    next unless n.text? && n&.previous&.element?
                                    next if uninterrupt_quotes_around_xml_skip(n)
                          
                          
                          Severity: Minor
                          Found in lib/metanorma/standoc/cleanup_text.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