metanorma/metanorma-standoc

View on GitHub

Showing 61 of 88 total issues

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

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

      def admonition_core_attrs(node)
        { notag: node.attr("notag") == "true" ? "true" : nil,
          coverpage: node.attr("coverpage") == "true" ? "true" : nil,
          beforeclauses: node.attr("beforeclauses") == "true" ? "true" : nil,
          unnumbered: node.attr("unnumbered") ||
Severity: Minor
Found in lib/metanorma/standoc/blocks_notes.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 hanging_para_style has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def hanging_para_style(root)
        root.xpath("//clause | //annex | //foreword | //introduction | " \
                   "//acknowledgements").each do |c|
          next unless c.at("./clause")
          next if c.elements.reject do |n|
Severity: Minor
Found in lib/metanorma/standoc/validate_section.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 move_attrs_to_amend has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def move_attrs_to_amend(clause, amend)
        %w(change path path_end title).each do |e|
          next unless clause[e]

          amend[e] = clause[e]
Severity: Minor
Found in lib/metanorma/standoc/cleanup_amend.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 symbols_parse(attrs, xml, node)
Severity: Major
Found in lib/metanorma/standoc/terms.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

              return clause_parse(attrs, xml, node)
    Severity: Major
    Found in lib/metanorma/standoc/terms.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              svg = File.read(path, encoding: "utf-8") or return false
      Severity: Major
      Found in lib/metanorma/standoc/cleanup_image.rb - About 30 mins to fix

        Method figure_footnote_cleanup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def figure_footnote_cleanup(xmldoc)
                nomatches = false
                until nomatches
                  nomatches = true
                  xmldoc.xpath(FIGURE_FN_XPATH).each do |s|
        Severity: Minor
        Found in lib/metanorma/standoc/cleanup_footnotes.rb - About 25 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 math_validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def math_validate(doc)
                doc.xpath("//m:math", "m" => MATHML_NS).each do |m|
                  if m.parent["validate"] == "false"
                    m.parent.delete("validate")
                  else
        Severity: Minor
        Found in lib/metanorma/standoc/validate.rb - About 25 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 alternate_termdefinitions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def alternate_termdefinitions(xmldoc)
                xmldoc.xpath("//term").each do |t|
                  t.xpath("./definition").each do |d|
                    d1 = d.next_element or next
                    if (v = d.at("./verbal-definition")) &&
        Severity: Minor
        Found in lib/metanorma/standoc/cleanup_terms.rb - About 25 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 redundant_bookmark_cleanup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def redundant_bookmark_cleanup(xmldoc)
                xmldoc.xpath("//bookmark").each do |b|
                  p = b
                  while !p.xml? && p = p.parent
                    p["id"] == b["id"] or next
        Severity: Minor
        Found in lib/metanorma/standoc/cleanup_inline.rb - About 25 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 supply_br has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def supply_br(lines)
                ignore = false
                lines.each_with_index do |l, i|
                  /^(--+|====+|\|===|\.\.\.\.+|\*\*\*\*+|\+\+\+\++|````+|____\+)$/
                    .match(l) and (ignore = !ignore)
        Severity: Minor
        Found in lib/metanorma/standoc/macros.rb - About 25 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 refitem1code has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def refitem1code(_item, match)
                code = analyse_ref_code(match[:code])
                ((code[:id] && code[:numeric]) || code[:nofetch]) and
                  return { code: nil, match: match, analyse_code: code,
                           hidden: code[:hidden] }
        Severity: Minor
        Found in lib/metanorma/standoc/ref.rb - About 25 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 mi_italicise? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def mi_italicise?(char)
                char.length > 1 and return false
                case char
                when /\p{Greek}/
                  (/\p{Lower}/.match(char) && !mathml_mi_italics[:lowergreek]) ||
        Severity: Minor
        Found in lib/metanorma/standoc/cleanup_maths.rb - About 25 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 span_preprocess1 has a Cognitive Complexity of 6 (exceeds 5 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 25 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 references2xml has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def references2xml(ret)
                out = ret.map do |b|
                  b.nil? ? nil : noko { |xml| reference1out(b, xml) }.join
                end
                out.map { |x| x.nil? ? nil : Nokogiri::XML(x).root }
        Severity: Minor
        Found in lib/metanorma/standoc/ref_queue.rb - About 25 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 which has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.which(cmd)
                exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]
                ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
                  exts.each do |ext|
                    exe = File.join(path, "#{cmd}#{ext}")
        Severity: Minor
        Found in lib/metanorma/standoc/macros_plantuml.rb - About 25 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 empty_element_cleanup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def empty_element_cleanup(xmldoc)
                xmldoc.xpath("//#{TEXT_ELEMS.join(' | //')}").each do |x|
                  next if x.name == "name" && x.parent.name == "expression"
        
                  x.remove if x.children.empty?
        Severity: Minor
        Found in lib/metanorma/standoc/cleanup.rb - About 25 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 variant_cleanup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def variant_cleanup(xmldoc)
                variant_space_cleanup(xmldoc)
                xmldoc.xpath("//*[variant]").each do |c|
                  next unless c.children.any? do |n|
                    n.name != "variant" && (!n.text? || !n.text.gsub(/\s/, "").empty?)
        Severity: Minor
        Found in lib/metanorma/standoc/cleanup.rb - About 25 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 analyse_ref_repo_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def analyse_ref_repo_path(ret)
                m = /^(?<type>repo|path|attachment):\((?<key>[^,]+),?(?<id>[^)]*)\)$/
                  .match(ret[:id]) or return ret
                id = if m[:id].empty?
                       if m[:type] == "attachment"
        Severity: Minor
        Found in lib/metanorma/standoc/ref_utility.rb - About 25 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