metanorma/metanorma-standoc

View on GitHub

Showing 88 of 88 total issues

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 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 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 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 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 isorefrender1 has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def isorefrender1(bib, match, code, year, allp = "")
    Severity: Minor
    Found in lib/metanorma/standoc/ref.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

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

              def progress_conv(idx, step, total, threshold, msg)
        Severity: Minor
        Found in lib/metanorma/standoc/cleanup_maths.rb - About 35 mins to fix

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

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

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

                  def norm_id_memorize(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 organization has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                      def organization(org, orgname, node = nil, default_org = nil, attrs = {})
                Severity: Minor
                Found in lib/metanorma/standoc/front_organisation.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 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 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_boilerplate.rb - About 35 mins to fix

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

                              def ref_dl_cleanup(xmldoc)
                                xmldoc.xpath("//clause[@bibitem = 'true']").each do |c|
                                  bib = dl_bib_extract(c) or next
                                  validate_ref_dl(bib, c)
                                  bibitemxml = RelatonBib::BibliographicItem.from_hash(bib).to_xml or next
                        Severity: Minor
                        Found in lib/metanorma/standoc/cleanup_asciibib.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 modify_ref_node has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def modify_ref_node(node, target)
                                node.name = "xref"
                                s = @lookup[:symbol][target]
                                t1 = @lookup[:sec2prim][target] and target = norm_ref_id1(t1)
                                t = @lookup[:term][target]
                        Severity: Minor
                        Found in lib/metanorma/standoc/term_lookup_cleanup.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 note_cleanup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def note_cleanup(xmldoc)
                                xmldoc.xpath("//note").each do |n|
                                  n["keep-separate"] == "true" || !n.ancestors("table").empty? and next
                                  prev = n.previous_element || next
                                  n.parent = prev if ELEMS_ALLOW_NOTES.include? prev.name
                        Severity: Minor
                        Found in lib/metanorma/standoc/cleanup_block.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 png_validate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def png_validate(doc)
                                doc.xpath("//image[@mimetype = 'image/png']").each do |i|
                                  Vectory::Utils::url?(i["src"]) and next
                                  decoded = if Vectory::Utils::datauri?(i["src"])
                                              Vectory::Utils::decode_datauri(i["src"])[:data]
                        Severity: Minor
                        Found in lib/metanorma/standoc/validate.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

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

                              def figure_dl_cleanup2(xmldoc)
                                q = "//figure/following-sibling::*[self::p]"
                                xmldoc.xpath(q).each do |s|
                                  if s.text =~ /^\s*key[^a-z]*$/i && s&.next_element&.name == "dl"
                                    s.next_element["key"] = "true"
                        Severity: Minor
                        Found in lib/metanorma/standoc/cleanup_block.rb and 2 other locations - About 35 mins to fix
                        lib/metanorma/standoc/cleanup_block.rb on lines 37..44
                        lib/metanorma/standoc/cleanup_table.rb on lines 12..19

                        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 35.

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language