metanorma/metanorma-bipm

View on GitHub

Showing 15 of 15 total issues

Class PresentationXMLConvert has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

    class PresentationXMLConvert < IsoDoc::Generic::PresentationXMLConvert
      def convert1(docxml, filename, dir)
        @jcgm = docxml&.at(ns("//bibdata/ext/editorialgroup/committee/" \
                              "@acronym"))&.value == "JCGM"
        @xrefs.klass.jcgm = @jcgm
Severity: Minor
Found in lib/isodoc/bipm/presentation_xml_convert.rb - About 3 hrs to fix

    Class Xref has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Xref < IsoDoc::Xref
          attr_accessor :jcgm
    
          def initialize(lang, script, klass, i18n, options = {})
            @iso = IsoDoc::Iso::Xref.new(lang, script, klass, i18n, options)
    Severity: Minor
    Found in lib/isodoc/bipm/xref.rb - About 3 hrs to fix

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

            def list_cochairs(xml)
              ret = list_people(xml, "//bibdata/contributor[#{COCHAIR}]/person")
              ret.empty? and return ""
              role = xml&.at(ns("//bibdata/contributor[#{COCHAIR}]/role"))&.text
              label = ret.size > 1 && role ? "#{role}s" : role
      Severity: Minor
      Found in lib/isodoc/bipm/doccontrol.rb and 1 other location - About 55 mins to fix
      lib/isodoc/bipm/doccontrol.rb on lines 79..84

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

      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 list_chairs(xml)
              ret = list_people(xml, "//bibdata/contributor#{CHAIR}/person")
              ret.empty? and return ""
              role = xml&.at(ns("//bibdata/contributor#{CHAIR}/role"))&.text
              label = ret.size > 1 && role ? "#{role}s" : role
      Severity: Minor
      Found in lib/isodoc/bipm/doccontrol.rb and 1 other location - About 55 mins to fix
      lib/isodoc/bipm/doccontrol.rb on lines 71..76

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

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

            def norm_ref_entry_code(_ordinal, identifiers, _ids, _standard, datefn,
      _bib)
      Severity: Minor
      Found in lib/isodoc/bipm/presentation_xml_convert.rb - About 45 mins to fix

        Method biblio_ref_entry_code has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def biblio_ref_entry_code(ordinal, ids, _id, _standard, datefn, _bib)
        Severity: Minor
        Found in lib/isodoc/bipm/presentation_xml_convert.rb - About 45 mins to fix

          Method annex_anchor_names has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def annex_anchor_names(docxml)
                  n = @jcgm ? Counter.new("@", skip_i: true) : Counter.new(0)
                  clause_order_annex(docxml).each_with_index do |a, i|
                    docxml.xpath(ns(a[:path])).each do |c|
                      if i.zero?
          Severity: Minor
          Found in lib/isodoc/bipm/xref.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 xref_init has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                def xref_init(lang, script, _klass, labels, options)
          Severity: Minor
          Found in lib/isodoc/bipm/init.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/bipm/processor.rb - About 35 mins to fix

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

                    def initialize(lang, script, klass, i18n, options = {})
              Severity: Minor
              Found in lib/isodoc/bipm/xref.rb - About 35 mins to fix

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

                      def main_anchor_names(xml)
                        @jcgm and return super
                        t = clause_order_main(xml)
                        n = Counter.new
                        t.each_with_index do |a, i|
                Severity: Minor
                Found in lib/isodoc/bipm/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 prefix_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                      def prefix_name(node, delim, number, elem)
                        number.nil? || number.empty? and return
                        unless name = node.at(ns("./#{elem}[not(@type = 'quoted')]"))
                          node.at(ns("./#{elem}[@type = 'quoted']")) and return
                          (node.children.empty? and node.add_child("<#{elem}></#{elem}>")) or
                Severity: Minor
                Found in lib/isodoc/bipm/presentation_xml_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 extract_indexterms has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                      def extract_indexterms(terms)
                        terms.each_with_object({}) do |t, v|
                          term = to_xml(t.at(ns("./primary"))&.children)
                          term2 = to_xml(t.at(ns("./secondary"))&.children)
                          term3 = to_xml(t.at(ns("./tertiary"))&.children)
                Severity: Minor
                Found in lib/isodoc/bipm/index.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 metadata_committee has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                      def metadata_committee(node, xml)
                        return unless node.attr("committee-en") || node.attr("committee-fr")
                
                        xml.editorialgroup do |a|
                          metadata_committee1(node, a)
                Severity: Minor
                Found in lib/metanorma/bipm/front.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 sequential_formula_names has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                      def sequential_formula_names(clause, container: false)
                        c = Counter.new
                        clause.xpath(ns(".//formula")).noblank.each do |t|
                          @anchors[t["id"]] = anchor_struct(
                            c.increment(t).print, container ? t : nil,
                Severity: Minor
                Found in lib/isodoc/bipm/xref.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