Showing 83 of 83 total issues
LolDba::HasAndBelongsToMany has no descriptive comment Open
class HasAndBelongsToMany < RelationInspector
- Read upRead up
- Exclude checks
Classes and modules are the units of reuse and release. It is therefore considered good practice to annotate every class and module with a brief comment outlining its responsibilities.
Example
Given
class Dummy
# Do things...
end
Reek would emit the following warning:
test.rb -- 1 warning:
[1]:Dummy has no descriptive comment (IrresponsibleModule)
Fixing this is simple - just an explaining comment:
# The Dummy class is responsible for ...
class Dummy
# Do things...
end
LolDba::RailsCompatibility has no descriptive comment Open
class RailsCompatibility
- Read upRead up
- Exclude checks
Classes and modules are the units of reuse and release. It is therefore considered good practice to annotate every class and module with a brief comment outlining its responsibilities.
Example
Given
class Dummy
# Do things...
end
Reek would emit the following warning:
test.rb -- 1 warning:
[1]:Dummy has no descriptive comment (IrresponsibleModule)
Fixing this is simple - just an explaining comment:
# The Dummy class is responsible for ...
class Dummy
# Do things...
end
LolDba::Writer has no descriptive comment Open
class Writer
- Read upRead up
- Exclude checks
Classes and modules are the units of reuse and release. It is therefore considered good practice to annotate every class and module with a brief comment outlining its responsibilities.
Example
Given
class Dummy
# Do things...
end
Reek would emit the following warning:
test.rb -- 1 warning:
[1]:Dummy has no descriptive comment (IrresponsibleModule)
Fixing this is simple - just an explaining comment:
# The Dummy class is responsible for ...
class Dummy
# Do things...
end
Complex method LolDba::HasMany#find_association_fk (22.5) Open
def find_association_fk
if (source = reflection_options.options[:source])
association_reflection = through_reflections[source.to_s]
return nil if association_reflection.options[:polymorphic]
get_through_foreign_key(association_reflection.klass, reflection_options)
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
LolDba::IndexFinder#self.check_for_indexes performs a nil-check Open
unless columns.nil? || reflection_options.options.include?(:class)
- Read upRead up
- Exclude checks
A NilCheck
is a type check. Failures of NilCheck
violate the "tell, don't ask" principle.
Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.
Example
Given
class Klass
def nil_checker(argument)
if argument.nil?
puts "argument isn't nil!"
end
end
end
Reek would emit the following warning:
test.rb -- 1 warning:
[3]:Klass#nil_checker performs a nil-check. (NilCheck)
LolDba::Migration#connection doesn't depend on instance state (maybe move it to another class?) Open
def connection
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
LolDba::SqlGenerator#migrator doesn't depend on instance state (maybe move it to another class?) Open
def migrator
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
LolDba::MigrationFormatter#format_index doesn't depend on instance state (maybe move it to another class?) Open
def format_index(table_name, key)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
LolDba::RelationInspector#get_through_foreign_key doesn't depend on instance state (maybe move it to another class?) Open
def get_through_foreign_key(target_class, reflection_options)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
LolDba::MigrationFormatter#migration_instructions doesn't depend on instance state (maybe move it to another class?) Open
def migration_instructions(formated_indexes)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
LolDba::SqlGenerator#specific_migration has the variable name 'm' Open
migration = migrator.migrations.find { |m| m.version == which.to_i }
- Read upRead up
- Exclude checks
An Uncommunicative Variable Name
is a variable name that doesn't communicate its intent well enough.
Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.
Line is too long. [119/100] Open
s.summary = 'A small package of rake tasks to track down missing database indexes and generate sql migration scripts'
- Exclude checks
Missing top-level class documentation comment. Open
class BelongsTo < RelationInspector
- Read upRead up
- 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
Missing top-level class documentation comment. Open
class ErrorLogging
- Read upRead up
- 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
Missing top-level class documentation comment. Open
class MigrationFormatter
- Read upRead up
- 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
Missing top-level class documentation comment. Open
class IndexFinder
- Read upRead up
- 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
Useless assignment to variable - index_name
. Open
index_name = [association_fk, foreign_key].map(&:to_s).sort
- Read upRead up
- Exclude checks
This cop checks for every useless assignment to local variable in every
scope.
The basic idea for this cop was from the warning of ruby -cw
:
assigned but unused variable - foo
Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.
Example:
# bad
def some_method
some_var = 1
do_something
end
Example:
# good
def some_method
some_var = 1
do_something(some_var)
end
Line is too long. [204/100] Open
s.description = 'lol_dba is a small package of rake tasks that scan your application models and displays a list of columns that probably should be indexed. Also, it can generate .sql migration scripts.'
- Exclude checks
Missing top-level module documentation comment. Open
module LolDba
- Read upRead up
- 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
Use ==
if you meant to do a comparison or wrap the expression in parentheses to indicate you meant to assign in a condition. Open
elsif belongs_to_reflections = through_reflections[reflection_name.singularize]
- Read upRead up
- Exclude checks
This cop checks for assignments in the conditions of if/while/until.
Example:
# bad
if some_var = true
do_something
end
Example:
# good
if some_var == true
do_something
end