andypike/rectify

View on GitHub

Showing 121 of 125 total issues

Rectify::Query#| calls 'other.cached_query' 2 times
Open

        Rectify::Query.new(cached_query.merge(other.cached_query))
      elsif eager? && other.eager?
        Rectify::Query.new(cached_query | other.cached_query)
Severity: Minor
Found in lib/rectify/query.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

Rectify::RSpec::DatabaseReporter has no descriptive comment
Open

    class DatabaseReporter

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

Rectify::FormatAttributesHash#convert_hash_keys calls 'value.map' 2 times
Open

        value.map { |v| convert_hash_keys(v) }
      when Hash
        Hash[value.map { |k, v| [underscore_key(k), convert_hash_keys(v)] }]
Severity: Minor
Found in lib/rectify/format_attributes_hash.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

Rectify::SqlQuery has no descriptive comment
Open

  module SqlQuery
Severity: Minor
Found in lib/rectify/sql_query.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

Rectify::RSpec::Helpers#stub_form doesn't depend on instance state (maybe move it to another class?)
Open

      def stub_form(attributes)
Severity: Minor
Found in lib/rectify/rspec/helpers.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

Rectify::Form#attributes_with_values performs a nil-check
Open

      attributes.reject { |attribute| public_send(attribute).nil? }
Severity: Minor
Found in lib/rectify/form.rb by reek

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)

Rectify::FormatAttributesHash#underscore_key doesn't depend on instance state (maybe move it to another class?)
Open

    def underscore_key(k)
Severity: Minor
Found in lib/rectify/format_attributes_hash.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

Rectify::Form#map_model has unused parameter 'model'
Open

    def map_model(model)
Severity: Minor
Found in lib/rectify/form.rb by reek

Unused Parameter refers to methods with parameters that are unused in scope of the method.

Having unused parameters in a method is code smell because leaving dead code in a method can never improve the method and it makes the code confusing to read.

Example

Given:

class Klass
  def unused_parameters(x,y,z)
    puts x,y # but not z
  end
end

Reek would emit the following warning:

[2]:Klass#unused_parameters has unused parameter 'z' (UnusedParameters)

Rectify::BuildFormFromModel#build has the variable name 'a'
Open

        matching_attributes.each do |a|
Severity: Minor
Found in lib/rectify/build_form_from_model.rb by reek

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.

Rectify::BuildFormFromModel#matching_attributes has the variable name 'a'
Open

        .select { |a| model.respond_to?(a.name) }
        .map    { |a| FormAttribute.new(a) }
Severity: Minor
Found in lib/rectify/build_form_from_model.rb by reek

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.

Rectify::Form#array_attributes_that_respond_to has the variable name 'f'
Open

        .select { |f| f.respond_to?(message) }
Severity: Minor
Found in lib/rectify/form.rb by reek

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.

Rectify::FormatAttributesHash#convert_hash_keys has the variable name 'v'
Open

        value.map { |v| convert_hash_keys(v) }
      when Hash
        Hash[value.map { |k, v| [underscore_key(k), convert_hash_keys(v)] }]
Severity: Minor
Found in lib/rectify/format_attributes_hash.rb by reek

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.

Rectify::Query#self.merge has the variable name 'e'
Open

      queries.reduce(NullQuery.new) { |a, e| a.merge(e) }
Severity: Minor
Found in lib/rectify/query.rb by reek

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.

Rectify::Form#array_attributes_that_respond_to has the variable name 'a'
Open

        .select { |a| a.is_a?(Array) }
Severity: Minor
Found in lib/rectify/form.rb by reek

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.

Rectify::FormatAttributesHash#convert_hash_keys has the variable name 'k'
Open

        Hash[value.map { |k, v| [underscore_key(k), convert_hash_keys(v)] }]
Severity: Minor
Found in lib/rectify/format_attributes_hash.rb by reek

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.

Rectify::Form#with_context has the variable name 'f'
Open

        .each { |f| f.with_context(context) }

      array_attributes_that_respond_to(:with_context)
        .each { |f| f.with_context(context) }
Severity: Minor
Found in lib/rectify/form.rb by reek

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.

Rectify::RSpec::DatabaseReporter::QueryStats#initialize has the variable name 'h'
Open

          @stats = Hash.new { |h, k| h[k] = [] }

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.

Rectify::Form#attributes_that_respond_to has the variable name 'f'
Open

        .select { |f| f.respond_to?(message) }
Severity: Minor
Found in lib/rectify/form.rb by reek

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.

Rectify::Query#self.merge has the variable name 'a'
Open

      queries.reduce(NullQuery.new) { |a, e| a.merge(e) }
Severity: Minor
Found in lib/rectify/query.rb by reek

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.

Rectify::RSpec::DatabaseReporter::QueryStats#initialize has the variable name 'k'
Open

          @stats = Hash.new { |h, k| h[k] = [] }

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.

Severity
Category
Status
Source
Language