File base.rb
has 425 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "date"
require "nokogiri"
require "htmlentities"
require "json"
require "pathname"
Method insert_biblio
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def insert_biblio(node, xmldoc)
# we want no references in this document, so we can ignore any anchors of references
xmldoc.xpath("//referencegroup | //reference").each(&:remove)
refs = Set.new
xmldoc.xpath("//xref | //relref").each { |r| refs << r["target"] }
- 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 insert_biblio
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def insert_biblio(node, xmldoc)
# we want no references in this document, so we can ignore any anchors of references
xmldoc.xpath("//referencegroup | //reference").each(&:remove)
refs = Set.new
xmldoc.xpath("//xref | //relref").each { |r| refs << r["target"] }
Method common_rfc_pis
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def common_rfc_pis(node)
# Below are generally applicable Processing Instructions (PIs)
# that most I-Ds might want to use, common to v2 and v3.
# These are set only if explicitly specified, with the exception
# of compact and subcompact
Method cache_biblio
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def cache_biblio(node)
bibliocache_name = "#{Dir.home}/.asciidoc-rfc-biblio-cache.json"
# If we are required to, clear the biblio cache
if node.attr("flush-caches") == "true"
FileUtils.rm_f bibliocache_name
Method flatten_rawtext
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def flatten_rawtext(node)
result = []
if node.respond_to?(:blocks) && node.blocks?
node.blocks.each { |b| result << flatten_rawtext(b) }
elsif node.respond_to?(:lines)
- 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 cache_workgroup
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def cache_workgroup(node)
wgcache_name = "#{Dir.home}/.asciidoc-rfc-workgroup-cache.json"
# If we are required to, clear the wg cache
if node.attr("flush-caches") == "true"
FileUtils.rm_f wgcache_name
Method extract_entities
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def extract_entities(node, xmldoc)
refs = xmldoc.xpath("//reference")
ret = []
biblio = cache_biblio(node)
refs.each do |ref|
- 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 current_location
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def current_location(node)
return "Line #{node.lineno}" if node.respond_to?(:lineno) && !node.lineno.nil? && !node.lineno.empty?
return "ID #{node.id}" if node.respond_to?(:id) && !node.id.nil?
while !node.nil? && (!node.respond_to?(:level) || node.level > 0) && node.context != :section
node = node.parent
- 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 workgroup
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def workgroup(node, xml)
workgroups = cache_workgroup(node)
node.attr("workgroup")&.split(/, ?/)&.each do |wg|
if wg =~ / (Working Group)$/i
warn %(asciidoctor: WARNING (#{current_location(node)}): suffix "Working Group" will be stripped in published RFC from #{wg})
- 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 inline_indexterm
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def inline_indexterm(node)
# supports only primary and secondary terms
# primary attribute (highlighted major entry) not supported
if node.type == :visible
iref_attributes = {
- 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"