Class has too many lines. [232/100] Open
class MiGA::Cli::Action::Init < MiGA::Cli::Action
require 'miga/cli/action/init/daemon_helper'
require 'miga/cli/action/init/files_helper'
include MiGA::Cli::Action::Init::DaemonHelper
include MiGA::Cli::Action::Init::FilesHelper
- 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. [54/10] Open
def parse_cli
cli.interactive = true
cli.defaults = {
mytaxa: nil,
rdp: nil,
- 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 check_software_requirements is too high. [40.8/15] Open
def check_software_requirements(rc_fh)
cli.puts 'Looking for requirements:'
opt_groups = {
mytaxa: 'MyTaxa',
rdp: 'RDP classifier',
- 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. [29/10] Open
def check_software_requirements(rc_fh)
cli.puts 'Looking for requirements:'
opt_groups = {
mytaxa: 'MyTaxa',
rdp: 'RDP classifier',
- 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 parse_cli is too high. [29.73/15] Open
def parse_cli
cli.interactive = true
cli.defaults = {
mytaxa: nil,
rdp: nil,
- 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. [18/10] Open
def find_software(exec)
path = nil
loop do
d_path = File.dirname(run_cmd(cli, ['which', exec], raise: false))
if cli[:ask] || d_path == '.'
- 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. [16/10] Open
def install_library(cli, paths, language, pkg)
case language
when :r
r_cmd = "install.packages('#{pkg}', repos='http://cran.rstudio.com/')"
run_r_cmd(cli, paths, r_cmd)
- 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. [15/10] Open
def test_library(cli, paths, language, pkg)
opts = { raise: false, return: :status, stderr: '/dev/null' }
status =
case language
when :r
- 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. [15/10] Open
def perform
cli.puts <<~BANNER
===[ Welcome to MiGA, the Microbial Genome Atlas ]===
I'm the initialization script, and I'll sniff around your computer to
- 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 parse_cli
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_cli
cli.interactive = true
cli.defaults = {
mytaxa: nil,
rdp: nil,
- Create a ticketCreate a ticket
Assignment Branch Condition size for ask_for_optional is too high. [19.34/15] Open
def ask_for_optional(symbol, name)
cli[symbol] = cli[:optional] if !cli[:optional].nil? && cli[symbol].nil?
return cli[symbol] unless cli[symbol].nil?
cli[symbol] =
- 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
Assignment Branch Condition size for find_software is too high. [18.87/15] Open
def find_software(exec)
path = nil
loop do
d_path = File.dirname(run_cmd(cli, ['which', exec], raise: false))
if cli[:ask] || d_path == '.'
- 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. [12/10] Open
def check_libraries(paths)
req_libraries = {
r: %w[ape cluster vegan],
ruby: %w[sqlite3 daemons json],
python: %w[numpy sqlite3 pyhmmer pyrodigal]
- 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 check_and_install_library is too high. [17.15/15] Open
def check_and_install_library(paths, language, library)
cli.print "Testing #{library}... "
if test_library(cli, paths, language, library)
cli.puts 'yes'
else
- 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. [11/10] Open
def check_and_install_library(paths, language, library)
cli.print "Testing #{library}... "
if test_library(cli, paths, language, library)
cli.puts 'yes'
else
- 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 list_requirements
if cli.ask_user(
'Would you like to see all the requirements before starting?',
'no', %w(yes no)
) == 'yes'
- 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.
Block has too many lines. [41/25] Open
cli.parse do |opt|
opt.on(
'-c', '--config PATH',
'Path to the Bash configuration file',
"By default: #{cli[:config]}"
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.
Method check_software_requirements
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def check_software_requirements(rc_fh)
cli.puts 'Looking for requirements:'
opt_groups = {
mytaxa: 'MyTaxa',
rdp: 'RDP classifier',
- 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
Method check_software_requirements
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_software_requirements(rc_fh)
cli.puts 'Looking for requirements:'
opt_groups = {
mytaxa: 'MyTaxa',
rdp: 'RDP classifier',
- Create a ticketCreate a ticket
Method find_software
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def find_software(exec)
path = nil
loop do
d_path = File.dirname(run_cmd(cli, ['which', exec], raise: false))
if cli[:ask] || d_path == '.'
- 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
%w
-literals should be delimited by [
and ]
. Open
'no', %w(yes no)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop enforces the consistent usage of %
-literal delimiters.
Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.
Example:
# Style/PercentLiteralDelimiters:
# PreferredDelimiters:
# default: '[]'
# '%i': '()'
# good
%w[alpha beta] + %i(gamma delta)
# bad
%W(alpha #{beta})
# bad
%I(alpha beta)
Non-local exit from iterator, without return value. next
, break
, Array#find
, Array#any?
, etc. is preferred. Open
%i[mytaxa rdp reads].each { |i| return if r[0] =~ /\(#{i}\)$/ && !cli[i] }
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for non-local exits from iterators without a return value. It registers an offense under these conditions:
- No value is returned,
- the block is preceded by a method chain,
- the block has arguments,
- the method which receives the block is not
define_method
ordefine_singleton_method
, - the return is not contained in an inner scope, e.g. a lambda or a method definition.
Example:
class ItemApi
rescue_from ValidationError do |e| # non-iteration block with arg
return { message: 'validation error' } unless e.errors # allowed
error_array = e.errors.map do |error| # block with method chain
return if error.suppress? # warned
return "#{error.param}: invalid" unless error.message # allowed
"#{error.param}: #{error.message}"
end
{ message: 'validation error', errors: error_array }
end
def update_items
transaction do # block without arguments
return unless update_necessary? # allowed
find_each do |item| # block without method chain
return if item.stock == 0 # false-negative...
item.update!(foobar: true)
end
end
end
end
%w
-literals should be delimited by [
and ]
. Open
'yes', %w(yes no)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop enforces the consistent usage of %
-literal delimiters.
Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.
Example:
# Style/PercentLiteralDelimiters:
# PreferredDelimiters:
# default: '[]'
# '%i': '()'
# good
%w[alpha beta] + %i(gamma delta)
# bad
%W(alpha #{beta})
# bad
%I(alpha beta)
Missing top-level class documentation comment. Open
class MiGA::Cli::Action::Init < MiGA::Cli::Action
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.
The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.
Example:
# bad
class Person
# ...
end
# good
# Description/Explanation of Person class
class Person
# ...
end
Put empty method definitions on a single line. Open
def empty_action
end
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for the formatting of empty method definitions.
By default it enforces empty method definitions to go on a single
line (compact style), but it can be configured to enforce the end
to go on its own line (expanded style).
Note: A method definition is not considered empty if it contains comments.
Example: EnforcedStyle: compact (default)
# bad
def foo(bar)
end
def self.foo(bar)
end
# good
def foo(bar); end
def foo(bar)
# baz
end
def self.foo(bar); end
Example: EnforcedStyle: expanded
# bad
def foo(bar); end
def self.foo(bar); end
# good
def foo(bar)
end
def self.foo(bar)
end