Block has too many lines. [83/25] Open
namespace :cequel do
namespace :keyspace do
desc 'Initialize Cassandra keyspace'
task :create => :environment do
create!
- Read upRead up
- 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 migrate
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def migrate
watch_stack = ActiveSupport::Dependencies::WatchStack.new
migration_table_names = Set[]
project_root = defined?(Rails) ? Rails.root : Dir.pwd
- 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
Assignment Branch Condition size for migrate is too high. [38.01/34] Open
def migrate
watch_stack = ActiveSupport::Dependencies::WatchStack.new
migration_table_names = Set[]
project_root = defined?(Rails) ? Rails.root : Dir.pwd
- Read upRead up
- 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
Cyclomatic complexity for migrate is too high. [8/6] Open
def migrate
watch_stack = ActiveSupport::Dependencies::WatchStack.new
migration_table_names = Set[]
project_root = defined?(Rails) ? Rails.root : Dir.pwd
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Method has too many lines. [32/31] Open
def migrate
watch_stack = ActiveSupport::Dependencies::WatchStack.new
migration_table_names = Set[]
project_root = defined?(Rails) ? Rails.root : Dir.pwd
- Read upRead up
- 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 migrate
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def migrate
watch_stack = ActiveSupport::Dependencies::WatchStack.new
migration_table_names = Set[]
project_root = defined?(Rails) ? Rails.root : Dir.pwd
Extra blank line detected. Open
def drop!
- Read upRead up
- Exclude checks
This cops checks for two or more consecutive blank lines.
Example:
# bad - It has two empty lines.
some_method
# one empty line
# two empty lines
some_method
# good
some_method
# one empty line
some_method
Use empty lines between method definitions. Open
def drop!
- Read upRead up
- Exclude checks
This cop checks whether method definitions are separated by one empty line.
NumberOfEmptyLines
can be and integer (e.g. 1 by default) or
an array (e.g. [1, 2]) to specificy a minimum and a maximum of
empty lines.
AllowAdjacentOneLineDefs
can be used to configure is adjacent
one line methods definitions are an offense
Example:
# bad
def a
end
def b
end
Example:
# good
def a
end
def b
end
Add an empty line after magic comments. Open
task :environment do
- Read upRead up
- Exclude checks
Checks for a newline after the final magic comment.
Example:
# good
# frozen_string_literal: true
# Some documentation for Person
class Person
# Some code
end
# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
# Some code
end
Line is too long. [87/80] Open
puts "Keyspace #{Cequel::Record.connection.name} doesn't exist. Nothing to do."
- Exclude checks
%w
-literals should be delimited by [
and ]
. Open
task :init => %w(keyspace:create migrate)
- Read upRead up
- 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)
Line is too long. [88/80] Open
puts "Keyspace #{Cequel::Record.connection.name} already exists. Nothing to do."
- Exclude checks
Unnecessary utf-8 encoding comment. Open
# -*- encoding : utf-8 -*-
- Exclude checks
Extra blank line detected. Open
desc 'Drop keyspace if exists, then create and migrate'
- Read upRead up
- Exclude checks
This cops checks for two or more consecutive blank lines.
Example:
# bad - It has two empty lines.
some_method
# one empty line
# two empty lines
some_method
# good
some_method
# one empty line
some_method