metanorma/metanorma-standoc

View on GitHub

Showing 88 of 88 total issues

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

      def sectiontype(node, level = true)
        ret = sectiontype1(node)
        ret1 = preface_main_filter(sectiontype_streamline(ret), node)
        ret1 == "symbols and abbreviated terms" and return ret1
        !level || node.level == 1 || node.attr("heading") or return nil
Severity: Minor
Found in lib/metanorma/standoc/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 variant_space_cleanup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def variant_space_cleanup(xmldoc)
        xmldoc.xpath("//*[variant]").each do |c|
          next if c.next.nil? || c.next.next.nil?

          if c.next.text? && c.next.next.name == "variant"
Severity: Minor
Found in lib/metanorma/standoc/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 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

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

      def xref_cleanup1(xmldoc)
        xmldoc.xpath("//xref").each do |x|
          %r{:(?!//)}.match?(x["target"]) and xref_to_internal_eref(x)
          x.name == "xref" or next
          if refid? x["target"]
Severity: Minor
Found in lib/metanorma/standoc/cleanup_xref.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 mi_italicise? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def mi_italicise?(char)
        return false if char.length > 1

        case char
        when /\p{Greek}/
Severity: Minor
Found in lib/metanorma/standoc/cleanup_maths.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 analyse_ref_code_csv_map has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def analyse_ref_code_csv_map(source)
        source.each_with_object({}) do |(k, v), ret|
          case k
          when :dropid, :hidden, :nofetch
            ret[k] = v == "true"
Severity: Minor
Found in lib/metanorma/standoc/ref_utility.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 dl2_table_cleanup(xmldoc)
        q = "//table/following-sibling::*[1][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_table.rb and 2 other locations - About 35 mins to fix
lib/metanorma/standoc/cleanup_block.rb on lines 37..44
lib/metanorma/standoc/cleanup_block.rb on lines 57..64

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

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

      def formula_cleanup_where2(formula)
        q = "//formula/following-sibling::*[1][self::p]"
        formula.xpath(q).each do |s|
          if s.text =~ /^\s*where[^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 57..64
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

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

            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

      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

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

            class SymbolRefInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
              use_dsl
              named :symbol
              name_positional_attributes "name", "termxref"
              using_format :short
        Severity: Minor
        Found in lib/metanorma/standoc/macros_terms.rb and 1 other location - About 30 mins to fix
        lib/metanorma/standoc/macros_terms.rb on lines 69..78

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

        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

            class TermRefInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
              use_dsl
              named :term
              name_positional_attributes "name", "termxref"
              using_format :short
        Severity: Minor
        Found in lib/metanorma/standoc/macros_terms.rb and 1 other location - About 30 mins to fix
        lib/metanorma/standoc/macros_terms.rb on lines 82..91

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

        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 figure_example(node)
                noko do |xml|
                  xml.figure **figure_attrs(node) do |ex|
                    node.title.nil? or ex.name { |name| name << node.title }
                    wrap_in_para(node, ex)
        Severity: Minor
        Found in lib/metanorma/standoc/blocks_image.rb and 1 other location - About 25 mins to fix
        lib/metanorma/standoc/blocks.rb on lines 138..144

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

        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 example_proper(node)
                noko do |xml|
                  xml.example **example_attrs(node) do |ex|
                    node.title.nil? or ex.name { |name| name << node.title }
                    wrap_in_para(node, ex)
        Severity: Minor
        Found in lib/metanorma/standoc/blocks.rb and 1 other location - About 25 mins to fix
        lib/metanorma/standoc/blocks_image.rb on lines 23..29

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

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

        Severity
        Category
        Status
        Source
        Language