metanorma/metanorma-iso

View on GitHub

Showing 43 of 43 total issues

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

      def xref_init(lang, script, _klass, i18n, options)
Severity: Minor
Found in lib/isodoc/iso/init.rb - About 35 mins to fix

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

          def termdef_warn(text, regex, elem, term, msg)
    Severity: Minor
    Found in lib/metanorma/iso/validate.rb - About 35 mins to fix

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

            def make_tr_attr(cell, row, totalrows, header, bordered)
      Severity: Minor
      Found in lib/isodoc/iso/word_dis_convert.rb - About 35 mins to fix

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

              def style_two_regex_not_prev(n, text, regex, re_prev, warning)
        Severity: Minor
        Found in lib/metanorma/iso/validate_style.rb - About 35 mins to fix

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

                def title_intro_validate(root)
                  title_intro_en = title_lang_part(root, "intro", "en")
                  title_intro_fr = title_lang_part(root, "intro", "fr")
                  if title_intro_en.nil? && !title_intro_fr.nil?
                    @log.add("Style", title_intro_fr, "No English Title Intro!")
          Severity: Minor
          Found in lib/metanorma/iso/validate_title.rb and 1 other location - About 35 mins to fix
          lib/metanorma/iso/validate_title.rb on lines 21..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 36.

          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 title_main_validate(root)
                  title_main_en = title_lang_part(root, "main", "en")
                  title_main_fr = title_lang_part(root, "main", "fr")
                  if title_main_en.nil? && !title_main_fr.nil?
                    @log.add("Style", title_main_fr, "No English Title!")
          Severity: Minor
          Found in lib/metanorma/iso/validate_title.rb and 1 other location - About 35 mins to fix
          lib/metanorma/iso/validate_title.rb on lines 10..18

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

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

                def clause_etc1(clause, out, num)
                  out.div **attr_code(
                    id: clause["id"],
                    class: clause.name == "definitions" ? "Symbols" : nil,
                  ) do |div|
          Severity: Minor
          Found in lib/isodoc/iso/base_convert.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 style_two_regex_not_prev has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def style_two_regex_not_prev(n, text, regex, re_prev, warning)
                  return if text.nil?
          
                  arr = Tokenizer::WhitespaceTokenizer.new.tokenize(text)
                  arr.each_index do |i|
          Severity: Minor
          Found in lib/metanorma/iso/validate_style.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 2 locations. Consider refactoring.
          Open

                def note_continued_style(docxml)
                  docxml.xpath("//div[@class = 'Note']").each do |d|
                    d.xpath("./p").each_with_index do |p, i|
                      p["class"] && p["class"] != "Note" and next
                      p["class"] = (i.zero? ? "Note" : "Notecontinued")
          Severity: Minor
          Found in lib/isodoc/iso/word_dis_styles.rb and 1 other location - About 35 mins to fix
          lib/isodoc/iso/word_dis_styles.rb on lines 114..118

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

          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_continued_style(docxml)
                  docxml.xpath("//div[@class = 'Example']").each do |d|
                    d.xpath("./p").each_with_index do |p, i|
                      p["class"] && p["class"] != "Example" and next
                      p["class"] = (i.zero? ? "Example" : "Examplecontinued")
          Severity: Minor
          Found in lib/isodoc/iso/word_dis_styles.rb and 1 other location - About 35 mins to fix
          lib/isodoc/iso/word_dis_styles.rb on lines 123..127

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

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

                def ol_depth(node)
                  depth = node.ancestors(@iso_class ? "ol" : "ul, ol").size + 1
                  type = :alphabet
                  type = :arabic if [2, 7].include? depth
                  type = :roman if [3, 8].include? depth
          Severity: Minor
          Found in lib/isodoc/iso/presentation_xml_convert.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 vocab_terms_titles_validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def vocab_terms_titles_validate(root)
                  terms = root.xpath("//sections/terms | //sections/clause[.//terms]")
                  if terms.size == 1
                    ((t = terms.first.at("./title")) && (t&.text == @i18n.termsdef)) or
                      @log.add("Style", terms.first,
          Severity: Minor
          Found in lib/metanorma/iso/validate_section.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 image_name_validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def image_name_validate(xmldoc)
                  prefix = image_name_prefix(xmldoc) or return
                  xmldoc.xpath("//image").each do |i|
                    next if i["src"].start_with?("data:")
          
          
          Severity: Minor
          Found in lib/metanorma/iso/validate_image.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_parse1 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def figure_parse1(node, out)
                  measurement_units(node, out)
                  out.div **figure_attrs(node) do |div|
                    node.children.each do |n|
                      n.name == "note" && n["type"] == "units" and next
          Severity: Minor
          Found in lib/isodoc/iso/base_convert.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 isosubgroup_validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def isosubgroup_validate(root)
                  root.xpath("//technical-committee/@type").each do |t|
                    unless %w{TC PC JTC JPC}.include? t.text
                      @log.add("Document Attributes", nil,
                               "invalid technical committee type #{t}")
          Severity: Minor
          Found in lib/metanorma/iso/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 style_list_iso has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def style_list_iso(elem, level, listtype, idx)
                return idx if elem.at(".//ol | .//ul") && !elem.at("./p")
          
                idx += 1
                ol = elem.xpath("./ancestor::ol")&.last
          Severity: Minor
          Found in lib/html2doc/lists.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 note_continued_style has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def note_continued_style(docxml)
                  docxml.xpath("//div[@class = 'Note']").each do |d|
                    d.xpath("./p").each_with_index do |p, i|
                      p["class"] && p["class"] != "Note" and next
                      p["class"] = (i.zero? ? "Note" : "Notecontinued")
          Severity: Minor
          Found in lib/isodoc/iso/word_dis_styles.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 xrefs_mandate_validate1 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def xrefs_mandate_validate1(xmldoc, xpath, name)
                  exc = %w(table note example figure).map { |x| "//#{x}#{xpath}" }
                    .join(" | ")
                  (xmldoc.xpath(xpath) - xmldoc.xpath(exc)).each do |x|
                    x["unnumbered"] == "true" and next
          Severity: Minor
          Found in lib/metanorma/iso/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 example_continued_style has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def example_continued_style(docxml)
                  docxml.xpath("//div[@class = 'Example']").each do |d|
                    d.xpath("./p").each_with_index do |p, i|
                      p["class"] && p["class"] != "Example" and next
                      p["class"] = (i.zero? ? "Example" : "Examplecontinued")
          Severity: Minor
          Found in lib/isodoc/iso/word_dis_styles.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

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

                def title_amd(node, xml, lang, at)
                  t = node.attr("title-amendment-#{lang}") or return
                  xml.title(**attr_code(at.merge(type: "title-amd"))) do |t1|
                    t1 << Metanorma::Utils::asciidoc_sub(t)
          Severity: Minor
          Found in lib/metanorma/iso/front.rb and 3 other locations - About 20 mins to fix
          lib/metanorma/iso/front.rb on lines 78..81
          lib/metanorma/iso/front.rb on lines 91..94
          lib/metanorma/iso/front.rb on lines 105..108

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

          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