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,
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
Class Compile
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class Compile
# @return [Array<String>]
attr_reader :errors, :processor
def initialize
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:
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
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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"
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]
- Read upRead up
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)
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)
Method process_exts
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def process_exts(filename, extensions, file, isodoc, options)
Method create_sectionfile
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_sectionfile(xml, out, file, chunks, parentnode)
Method process_ext
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def process_ext(ext, file, isodoc, fnames, options)
Method process_ext_simple
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def process_ext_simple(ext, isodoc, fnames, options, isodoc_options)
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)
Method collection_manifest
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def collection_manifest(filename, files, origxml, _presxml, dir)
Method process_exts1
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def process_exts1(ext, fnames, isodoc, options, isodoc_options)
Method process_exts_run
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def process_exts_run(fnames, file, isodoc, extensions, options)
Method output
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def output(isodoc_node, _inname, outname, _format, _options = {})