Showing 88 of 88 total issues
Class PlantumlRenderer
has 42 methods (exceeds 20 allowed). Consider refactoring. Open
class PlantumlRenderer
TEMPLATES_PATH = File.expand_path("../views/datamodel", __dir__).freeze
attr_reader :yml, :plantuml_path
File plantuml_renderer.rb
has 315 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "erb"
module Metanorma
module Datamodel
class PlantumlRenderer
Class TermLookupCleanup
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class TermLookupCleanup
AUTO_GEN_ID_REGEXP = /\A_/.freeze
attr_reader :xmldoc, :lookup, :log
Method terms_subclause_type_tally
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def terms_subclause_type_tally(node, m, parent)
sym = if (node.at(".//term") && !node.at(".//definitions")) ||
(node.name == "terms" && !node.at(".//term"))
unless m[:parent] == :term # don't count Term > Term twice
:term
- 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 cleanup
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
def cleanup(xmldoc)
@doctype = xmldoc.at("//bibdata/ext/doctype")&.text
element_name_cleanup(xmldoc)
passthrough_cleanup(xmldoc)
unnumbered_blocks_cleanup(xmldoc)
Method section
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def section(node)
a = section_attributes(node)
noko do |xml|
case sectiontype(node)
when "misc-container", "metanorma-extension"
- 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 span_preprocess1
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def span_preprocess1(span, ret)
case span[:key]
when "uri", "docid"
val = link_unwrap(Nokogiri::XML.fragment(span[:val])).to_xml
ret[span[:key].to_sym] << { type: span[:type], val: val }
Method init_iev_caches
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def init_iev_caches(node)
unless @no_isobib_cache || @no_isobib
node.attr("local-cache-only") or
@iev_globalname = global_ievcache_name
@iev_localname = local_ievcache_name(node.attr("local-cache") ||
- 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 section
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def section(node)
a = section_attributes(node)
noko do |xml|
case sectiontype(node)
when "misc-container", "metanorma-extension"
Method filter_sections
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def filter_sections(lines, headings)
skip = false
lines.each_with_index.with_object([]) do |(l, i), m|
if headings.include?(l.strip)
skip = true
- 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 doc_extract_attributes
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def doc_extract_attributes(node)
attrs = {
script: node.attr("script"),
bodyfont: node.attr("body-font"),
headerfont: node.attr("header-font"),
Method html_extract_attributes
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def html_extract_attributes(node)
{
script: node.attr("script"),
bodyfont: node.attr("body-font"),
headerfont: node.attr("header-font"),
Method inline_quoted
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def inline_quoted(node)
noko do |xml|
case node.type
when :emphasis then xml.em { |s| s << node.text }
when :strong then xml.strong { |s| s << node.text }
Consider simplifying this complex logical expression. Open
next if l.empty? || l.match(/ \+$/) || /^\[.*\]$/.match?(l) ||
ignore || i == lines.size - 1 ||
(i < lines.size - 1 && lines[i + 1].empty?)
Method pass_status
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def pass_status(status, text)
text == "++++" && !status[:delimln] and status[:pass] = !status[:pass]
status[:midline_docattr] && !/^:[^ :]+: /.match?(text) and
status[:midline_docattr] = false
if (status[:is_delim] && /^(-+|\*+|=+|_+)$/.match?(text)) ||
- 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 section_attributes
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def section_attributes(node)
ret =
{ id: Metanorma::Utils::anchor_or_uuid(node),
unnumbered: node.option?("unnumbered") ? "true" : nil,
annex: role_style(node, "appendix") && node.level == 1 ? true : nil,
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
class ToDoInlineAdmonitionBlock < Asciidoctor::Extensions::Treeprocessor
def process(document)
(document.find_by context: :paragraph).each do |para|
next unless /^TODO: /.match? para.lines[0]
- Read upRead up
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 41.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
class EditorInlineAdmonitionBlock < Asciidoctor::Extensions::Treeprocessor
def process(document)
(document.find_by context: :paragraph).each do |para|
next unless /^EDITOR: /.match? para.lines[0]
- Read upRead up
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 41.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method strip_header
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def strip_header(lines)
return { lines: lines, hdr: nil } unless !lines.empty? &&
lines.first.start_with?("= ")
skip = true
- 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 maxcols_validate1
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def maxcols_validate1(tcell, row, curr, cells2d, maxcols, mode)