metanorma/metanorma-bipm

View on GitHub
lib/isodoc/bipm/xref.rb

Summary

Maintainability
B
5 hrs
Test Coverage

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

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

      There are no issues that match your filters.

      Category
      Status