plentz/lol_dba

View on GitHub

Showing 83 of 83 total issues

LolDba::HasAndBelongsToMany has no descriptive comment
Open

  class HasAndBelongsToMany < RelationInspector

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
Severity: Minor
Found in lib/lol_dba/rails_compatibility.rb by reek

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
Severity: Minor
Found in lib/lol_dba/sql_migrations/writer.rb by reek

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)
Severity: Minor
Found in lib/lol_dba/index_finding/has_many.rb by flog

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)

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

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

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)

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)

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)

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 }

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'
Severity: Minor
Found in lol_dba.gemspec by rubocop

Missing top-level class documentation comment.
Open

  class BelongsTo < RelationInspector

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

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

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

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

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.'
Severity: Minor
Found in lol_dba.gemspec by rubocop

Missing top-level module documentation comment.
Open

module LolDba
Severity: Minor
Found in lib/lol_dba.rb by rubocop

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]

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
Severity
Category
Status
Source
Language