metanorma/metanorma-standoc

View on GitHub

Showing 47 of 70 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_/
      
            attr_reader :xmldoc, :lookup, :log
      
      
      Severity: Minor
      Found in lib/metanorma/standoc/term_lookup_cleanup.rb - About 3 hrs to fix

        Method cleanup has 63 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 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 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 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 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

              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 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 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 dl_bib_extract has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def dl_bib_extract(clause, nested = false)
                          dl = clause.at("./dl") or return
                          key = ""
                          bib = dl.xpath("./dt | ./dd").each_with_object({}) do |dtd, m|
                            (dtd.name == "dt" and key = dtd.text.sub(/:+$/, "")) and next
                  Severity: Minor
                  Found in lib/metanorma/standoc/cleanup_asciibib.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 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

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

                        def pop_floating_title(xmldoc)
                          loop do
                            found = false
                            xmldoc.xpath("//floating-title").each do |t|
                              t.next_element.nil? or next
                  Severity: Minor
                  Found in lib/metanorma/standoc/cleanup_section.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 term_defs_boilerplate has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                          def term_defs_boilerplate(div, source, term, _preface, isodoc)
                    Severity: Minor
                    Found in lib/metanorma/standoc/cleanup_terms_boilerplate.rb - About 35 mins to fix

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

                            def norm_id_memorize_init(node, res_table, selector, prefix, use_domain)
                      Severity: Minor
                      Found in lib/metanorma/standoc/term_lookup_cleanup.rb - About 35 mins to fix

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

                                def merge_by_type(old, new, field, attributes, opt = {})
                        Severity: Minor
                        Found in lib/metanorma/standoc/merge_bibitems.rb - About 35 mins to fix

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

                                def table_tracker_update(cells2d, row, curr, rowspan, colspan)
                          Severity: Minor
                          Found in lib/metanorma/standoc/validate_table.rb - About 35 mins to fix

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

                                  def output(isodoc_node, inname, outname, format, options = {})
                            Severity: Minor
                            Found in lib/metanorma/standoc/processor.rb - About 35 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language