metanorma/metanorma

View on GitHub

Showing 24 of 28 total issues

Class FileLookup has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

  class FileLookup
    attr_accessor :files_to_delete, :parent

    # hash for each document in collection of document identifier to:
    # document reference (fileref or id), type of document reference,
Severity: Minor
Found in lib/metanorma/files_lookup.rb - About 2 hrs to fix

    Class CollectionRenderer has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class CollectionRenderer
        def update_bibitem(bib, identifier)
          docid = get_bibitem_docid(bib, identifier) or return
          newbib = dup_bibitem(docid, bib)
          _file, url = @files
    Severity: Minor
    Found in lib/metanorma/collection_fileparse.rb - About 2 hrs to fix

      Class Compile has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Compile
          # @return [Array<String>]
          attr_reader :errors, :processor
      
          def initialize
      Severity: Minor
      Found in lib/metanorma/compile.rb - About 2 hrs to fix

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

          class Sectionsplit
            def xref_preprocess(xml, _fileslookup, _identifier)
              key = (0...8).map { rand(65..90).chr }.join # random string
              xml.root["type"] = key # to force recognition of internal refs
              # bookmarks etc as new id elements introduced in Presentation XML:
        Severity: Minor
        Found in lib/metanorma/sectionsplit_links.rb - About 2 hrs to fix

          Method options_extract has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def options_extract(filename, options)
                content = read_file(filename)
                o = Metanorma::Input::Asciidoc.new.extract_metanorma_options(content)
                  .merge(xml_options_extract(content))
                options[:type] ||= o[:type]&.to_sym
          Severity: Minor
          Found in lib/metanorma/compile_options.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 docrefs has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def docrefs(elm, builder)
                elm.xpath(ns("./docref[@index = 'true']")).each do |d|
                  if m = d.at(ns("./manifest"))
                    builder << indexfile(m, ul: false)
                  else
          Severity: Minor
          Found in lib/metanorma/collection_renderer.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 extract_metanorma_options has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def extract_metanorma_options(file)
                  headerextract = file.sub(/\n\n.*$/m, "\n")
                  /\n:mn-document-class:\s+(?<type>[^\n]+)\n/ =~ headerextract
                  /\n:mn-output-extensions:\s+(?<extensions>[^\n]+)\n/ =~ headerextract
                  /\n:mn-relaton-output-file:\s+(?<relaton>[^\n]+)\n/ =~ headerextract
          Severity: Minor
          Found in lib/metanorma/input/asciidoc.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 initialize has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def initialize(collection, folder, options = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
                check_options options
                @xml = Nokogiri::XML collection.to_xml # @xml is the collection manifest
                @lang = @xml.at("//xmlns:bibdata/xmlns:language")&.text || "en"
                @script = @xml.at("//xmlns:bibdata/xmlns:script")&.text || "Latn"
          Severity: Minor
          Found in lib/metanorma/collection_renderer.rb - About 1 hr to fix

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

                def process_ext_simple(ext, isodoc, fnames, options, isodoc_options)
                  if ext == :rxl
                    relaton_export(isodoc, options.merge(relaton: fnames[:out]))
                  elsif options[:passthrough_presentation_xml] && ext == :presentation
                    f = File.exist?(fnames[:f]) ? fnames[:f] : fnames[:orig_filename]
            Severity: Minor
            Found in lib/metanorma/compile.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 sectionfile has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def sectionfile(fulldoc, xml, file, chunks, parentnode)
            Severity: Minor
            Found in lib/metanorma/sectionsplit.rb - About 35 mins to fix

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

                  def update_indirect_refs_to_docs1(_docxml, key, file, bibitems, erefs)
              Severity: Minor
              Found in lib/metanorma/collection_fileparse.rb - About 35 mins to fix

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

                    def process_exts(filename, extensions, file, isodoc, options)
                Severity: Minor
                Found in lib/metanorma/compile.rb - About 35 mins to fix

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

                      def create_sectionfile(xml, out, file, chunks, parentnode)
                  Severity: Minor
                  Found in lib/metanorma/sectionsplit.rb - About 35 mins to fix

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

                        def process_ext(ext, file, isodoc, fnames, options)
                    Severity: Minor
                    Found in lib/metanorma/compile.rb - About 35 mins to fix

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

                          def process_ext_simple(ext, isodoc, fnames, options, isodoc_options)
                      Severity: Minor
                      Found in lib/metanorma/compile.rb - About 35 mins to fix

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

                            def self.add_suffix_to_attributes(doc, suffix, tag_name, attr_name, isodoc)
                        Severity: Minor
                        Found in lib/metanorma/util.rb - About 35 mins to fix

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

                              def collection_manifest(filename, files, origxml, _presxml, dir)
                          Severity: Minor
                          Found in lib/metanorma/sectionsplit.rb - About 35 mins to fix

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

                                def process_exts1(ext, fnames, isodoc, options, isodoc_options)
                            Severity: Minor
                            Found in lib/metanorma/compile.rb - About 35 mins to fix

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

                                  def process_exts_run(fnames, file, isodoc, extensions, options)
                              Severity: Minor
                              Found in lib/metanorma/compile.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/processor.rb - About 35 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language