metanorma/metanorma-itu

View on GitHub

Showing 32 of 32 total issues

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

    class Converter < Standoc::Converter
      def metadata_status(node, xml)
        stage = node.attr("status") || node.attr("docstage") || "published"
        stage = "draft" if node.attributes.has_key?("draft")
        xml.status do |s|
Severity: Minor
Found in lib/metanorma/itu/front.rb - About 3 hrs to fix

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

        class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
          def initialize(options)
            @hierarchical_assets = options[:hierarchicalassets]
            super
          end
    Severity: Minor
    Found in lib/isodoc/itu/presentation_xml_convert.rb - About 3 hrs to fix

      Method ddMMMMYYYY has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

            def ddMMMMYYYY(date1, date2)
              m1 = /(?<yr>\d\d\d\d)-(?<mo>\d\d)-(?<dd>\d\d)/.match date1
              m2 = /(?<yr>\d\d\d\d)-(?<mo>\d\d)-(?<dd>\d\d)/.match date2
              if m1 && m1[:yr] && m1[:mo] && m1[:dd]
                dd1 = m1[:dd].sub(/^0/, "")
      Severity: Minor
      Found in lib/isodoc/itu/metadata.rb - About 2 hrs 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

      Class Converter has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class Converter < Standoc::Converter
            XML_ROOT_TAG = "itu-standard".freeze
            XML_NAMESPACE = "https://www.metanorma.org/ns/itu".freeze
      
            register_for "itu"
      Severity: Minor
      Found in lib/metanorma/itu/converter.rb - About 2 hrs to fix

        Method biblio_list has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def biblio_list(clause, div, biblio)
                div.table class: "biblio", border: "0" do |t|
                  i = 0
                  t.tbody do |tbody|
                    clause.elements.each do |b|
        Severity: Minor
        Found in lib/isodoc/itu/ref.rb - About 1 hr 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 ddMMMyyyy has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def ddMMMyyyy(date)
                d = date.split("-").map { |x| x.sub(/^0/, "") }
                case @lang
                when "zh"
                  d[0] += "年" if d[0]
        Severity: Minor
        Found in lib/isodoc/itu/presentation_bibdata.rb - About 1 hr 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 author has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def author(xml, _out)
                sector = xml.at(ns("//bibdata/ext/editorialgroup/sector"))
                set(:sector, sector.text) if sector
                bureau(xml)
                tc = xml.at(ns("//bibdata/ext/editorialgroup/committee"))
        Severity: Minor
        Found in lib/isodoc/itu/metadata.rb - About 55 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 biblio_ref_entry_code has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def biblio_ref_entry_code(_ordinal, idents, _id, _standard, datefn, _bib)
        Severity: Minor
        Found in lib/isodoc/itu/presentation_ref.rb - About 45 mins to fix

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

                def annex(node, out)
                  @meta.get[:doctype_original] == "recommendation-annex" or
                    page_break(out)
                  out.div **attr_code(id: node["id"], class: "Section3") do |s|
                    annex_name(node, nil, s) unless node.at(ns("./title"))
          Severity: Minor
          Found in lib/isodoc/itu/base_convert.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

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

                def norm_ref_entry_code(_ordinal, idents, _ids, _standard, datefn, _bib)
                  ret = (idents[:metanorma] || idents[:ordinal] || idents[:sdo]).to_s
                  /^\[.+\]$/.match?(ret) or ret = "[#{ret}]"
                  ret += datefn
                  ret.empty? and return ret
          Severity: Minor
          Found in lib/isodoc/itu/presentation_ref.rb and 1 other location - About 45 mins to fix
          lib/isodoc/itu/presentation_ref.rb on lines 88..93

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

          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 biblio_ref_entry_code(_ordinal, idents, _id, _standard, datefn, _bib)
                  ret = (idents[:metanorma] || idents[:ordinal] || idents[:sdo]).to_s
                  /^\[.+\]$/.match?(ret) or ret = "[#{ret}]"
                  ret += datefn
                  ret.empty? and return ret
          Severity: Minor
          Found in lib/isodoc/itu/presentation_ref.rb and 1 other location - About 45 mins to fix
          lib/isodoc/itu/presentation_ref.rb on lines 80..85

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

          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, idents, _ids, _standard, datefn, _bib)
          Severity: Minor
          Found in lib/isodoc/itu/presentation_ref.rb - About 45 mins to fix

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

                  def authority_cleanup(docxml)
                    dest = docxml.at("//div[@class = 'draft-warning']")
                    auth = docxml.at("//div[@id = 'draft-warning']")
                    dest and auth and dest.replace(auth.remove)
                    %w(copyright license legal).each do |t|
            Severity: Minor
            Found in lib/isodoc/itu/word_cleanup.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 meeting has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def meeting(isoxml)
                    resolution =
                      isoxml.at(ns("//bibdata/ext/doctype"))&.text == "resolution"
                    if o = isoxml.at(ns("//bibdata/ext/meeting-date/on"))&.text
                      set(:meeting_date, resolution ? ddMMMMYYYY(o, nil) : ddMMMYYYY(o))
            Severity: Minor
            Found in lib/isodoc/itu/metadata.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 output has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def output(isodoc_node, inname, outname, format, options={})
            Severity: Minor
            Found in lib/metanorma/itu/processor.rb - About 35 mins to fix

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

                    def hierarchical_figure_body(num, subfignum, counter, block, klass)
              Severity: Minor
              Found in lib/isodoc/itu/xref.rb - About 35 mins to fix

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

                      def initialize(lang, script, klass, labels, options)
                Severity: Minor
                Found in lib/isodoc/itu/xref.rb - About 35 mins to fix

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

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

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

                          def make_tr_attr(tcell, row, totalrows, header, bordered)
                    Severity: Minor
                    Found in lib/isodoc/itu/word_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(node, text, regex, regex_prev, warning)
                      Severity: Minor
                      Found in lib/metanorma/itu/validate.rb - About 35 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language