Class has too many lines. [185/100] Open
class MiGA::Cli::Action::Browse < MiGA::Cli::Action
def parse_cli
cli.parse do |opt|
cli.defaults = { open: true }
cli.opt_object(opt, [:project])
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [21/10] Open
def generate_summary_page(path, p)
b = File.basename(path, '.tsv')
table = '<table class="table table-hover table-responsive">'
File.open(path, 'r') do |fh|
fh.each do |ln|
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [21/10] Open
def format_results(obj)
o = ''
obj.each_result do |key, res|
links = format_result_links(res)
stats = format_result_stats(res)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for generate_summary_page is too high. [21.05/15] Open
def generate_summary_page(path, p)
b = File.basename(path, '.tsv')
table = '<table class="table table-hover table-responsive">'
File.open(path, 'r') do |fh|
fh.each do |ln|
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [14/10] Open
def format_metadata(obj)
'<table class="table table-sm table-responsive">' +
obj.metadata.data.map do |k, v|
case k
when /^run_/, :plugins, :user
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [13/10] Open
def generate_project_page(p)
# Redirect page
write_file(p, '../index.html') { build_from_template('redirect.html') }
# Summaries
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [11/10] Open
def generate_datasets_index(p)
cli.say 'Creating index pages'
data = format_dataset_index(p)
data.each do |k, v|
write_file(p, "#{k}_datasets.html") do
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for perform is too high. [15.03/15] Open
def perform
p = cli.load_project
create_empty_page(p)
generate_project_page(p)
cli.say 'Creating dataset pages'
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method format_result_stats
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def format_result_stats(res)
res.stats.map do |k, v|
v = [v, ''] unless v.is_a? Array
v[0] = ('%.3g' % v[0]) if v[0].is_a? Float
"<b>#{format_name(k)}:</b> #{v[0]}#{v[1]}<br/>"
- Read upRead up
- Create a ticketCreate a ticket
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
Align the operands of an expression in an assignment spanning multiple lines. Open
r.map { |i| "<th scope=col>#{format_name(i)}</th>" }.join(' ') +
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks the indentation of the right hand side operand in binary operations that span more than one line.
Example:
# bad
if a +
b
something
end
# good
if a +
b
something
end
Favor a normal unless-statement over a modifier clause in a multiline statement. Open
res.stats.map do |k, v|
v = [v, ''] unless v.is_a? Array
v[0] = ('%.3g' % v[0]) if v[0].is_a? Float
"<b>#{format_name(k)}:</b> #{v[0]}#{v[1]}<br/>"
end.join('') + '<br/>' unless res.stats.empty?
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for uses of if/unless modifiers with multiple-lines bodies.
Example:
# bad
{
result: 'this should not happen'
} unless cond
# good
{ result: 'ok' } if cond
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
r.map { |i| "<td>#{i}</td>" }.join(' ') + "</tr>"
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Prefer $INPUT_LINE_NUMBER
or $NR
from the stdlib 'English' module (don't forget to require it) over $.
. Open
if $. == 1
- Create a ticketCreate a ticket
- Exclude checks
Align the operands of an expression in an assignment spanning multiple lines. Open
'</tr></thead><tbody>'
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks the indentation of the right hand side operand in binary operations that span more than one line.
Example:
# bad
if a +
b
something
end
# good
if a +
b
something
end
Align the operands of an expression in an assignment spanning multiple lines. Open
r.map { |i| "<td>#{i}</td>" }.join(' ') + "</tr>"
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks the indentation of the right hand side operand in binary operations that span more than one line.
Example:
# bad
if a +
b
something
end
# good
if a +
b
something
end