metanorma/metanorma-itu

View on GitHub

Showing 30 of 32 total issues

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

      def title_otherlangs(node, xml)
        node.attributes.each do |k, v|
          /^(?:annex)?title-(?<lang>.+)$/ =~ k or next
          lang == @lang and next
          type = /^annex/.match?(k) ? "annex" : "main"
Severity: Minor
Found in lib/metanorma/itu/front.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 pub_class has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def pub_class(bib)
        return 1 if bib.at("#{PUBLISHER}[abbreviation = 'ITU']")
        return 1 if bib.at("#{PUBLISHER}[name = 'International " \
                           "Telecommunication Union']")
        return 2 if bib.at("#{PUBLISHER}[abbreviation = 'ISO']")
Severity: Minor
Found in lib/metanorma/itu/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 editor_table_entries has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def editor_table_entries(eds, ed_lbl, mail_lbl)
        eds.each_with_index.with_object([]) do |(n, i), m|
          mail = ""
          n[:email] and
            mail = "#{mail_lbl}<link target='mailto:#{n[:email]}'>" \
Severity: Minor
Found in lib/isodoc/itu/presentation_preface.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 3 if bib.at("#{PUBLISHER}[abbreviation = 'IEC']")
Severity: Major
Found in lib/metanorma/itu/cleanup.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return 3 if bib.at("#{PUBLISHER}[name = 'International " \
    Severity: Major
    Found in lib/metanorma/itu/cleanup.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return 4 if bib.at("./docidentifier[@type][not(#{skip_docid} or " \
      Severity: Major
      Found in lib/metanorma/itu/cleanup.rb - About 30 mins to fix

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

              def word_preface(docxml)
                super
                abstractbox = docxml.at("//div[@id='abstractbox']")
                historybox = docxml.at("//div[@id='historybox']")
                sourcebox = docxml.at("//div[@id='sourcebox']")
        Severity: Minor
        Found in lib/isodoc/itu/word_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 word_title_cleanup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def word_title_cleanup(docxml)
                docxml.xpath("//p[@class = 'annex_obligation']").each do |h|
                  h.next_element&.name == "p" or next
                  h.next_element["class"] ||= "Normalaftertitle"
                end
        Severity: Minor
        Found in lib/isodoc/itu/word_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 capitalise_unless_text_transform has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def capitalise_unless_text_transform(elem)
                css = nil
                elem.traverse_topdown do |n|
                  n.name == "span" && /text-transform:/.match?(n["style"]) and
                    css = n
        Severity: Minor
        Found in lib/isodoc/itu/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 style_two_regex_not_prev has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def style_two_regex_not_prev(node, text, regex, regex_prev, warning)
                text.nil? and return
                arr = text.split(/\W+/)
                arr.each_index do |i|
                  m = regex.match arr[i]
        Severity: Minor
        Found in lib/metanorma/itu/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

        Severity
        Category
        Status
        Source
        Language