Showing 5,267 of 5,597 total issues
ActivationReminderWorker#perform doesn't depend on instance state (maybe move it to another class?) Open
def perform(user_id)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
ThreeScale::Search::Scopes::ClassMethods#table_and_column performs a nil-check Open
if table.present? && column.nil?
- 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)
ThreeScale::Swagger::Specification::V10 has missing safe method 'validate!' Open
def validate!
- Read upRead up
- Exclude checks
A candidate method for the Missing Safe Method
smell are methods whose names end with an exclamation mark.
An exclamation mark in method names means (the explanation below is taken from here ):
The ! in method names that end with ! means, “This method is dangerous”—or, more precisely, this method is the “dangerous” version of an otherwise equivalent method, with the same name minus the !. “Danger” is relative; the ! doesn’t mean anything at all unless the method name it’s in corresponds to a similar but bang-less method name. So, for example, gsub! is the dangerous version of gsub. exit! is the dangerous version of exit. flatten! is the dangerous version of flatten. And so forth.
Such a method is called Missing Safe Method
if and only if her non-bang version does not exist and this method is reported as a smell.
Example
Given
class C
def foo; end
def foo!; end
def bar!; end
end
Reek would report bar!
as Missing Safe Method
smell but not foo!
.
Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:
class Parent
def foo; end
end
module Dangerous
def foo!; end
end
class Son < Parent
include Dangerous
end
class Daughter < Parent
end
In this example, Reek would not report the Missing Safe Method
smell for the method foo
of the Dangerous
module.
ThreeScale#master_billing_enabled? doesn't depend on instance state (maybe move it to another class?) Open
def master_billing_enabled?
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
ThreeScale::XML::Builder has missing safe method 'tag!' Open
def tag!(*args, &block)
- Read upRead up
- Exclude checks
A candidate method for the Missing Safe Method
smell are methods whose names end with an exclamation mark.
An exclamation mark in method names means (the explanation below is taken from here ):
The ! in method names that end with ! means, “This method is dangerous”—or, more precisely, this method is the “dangerous” version of an otherwise equivalent method, with the same name minus the !. “Danger” is relative; the ! doesn’t mean anything at all unless the method name it’s in corresponds to a similar but bang-less method name. So, for example, gsub! is the dangerous version of gsub. exit! is the dangerous version of exit. flatten! is the dangerous version of flatten. And so forth.
Such a method is called Missing Safe Method
if and only if her non-bang version does not exist and this method is reported as a smell.
Example
Given
class C
def foo; end
def foo!; end
def bar!; end
end
Reek would report bar!
as Missing Safe Method
smell but not foo!
.
Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:
class Parent
def foo; end
end
module Dangerous
def foo!; end
end
class Son < Parent
include Dangerous
end
class Daughter < Parent
end
In this example, Reek would not report the Missing Safe Method
smell for the method foo
of the Dangerous
module.
BackendRandomDataGeneratorWorker#perform doesn't depend on instance state (maybe move it to another class?) Open
def perform(options)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
CMS::UpgradeContentWorker#on_success doesn't depend on instance state (maybe move it to another class?) Open
def on_success(_, options)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
PersistEventWorker#perform doesn't depend on instance state (maybe move it to another class?) Open
def perform(event_attrs)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
ReverseProviderKeyWorker#perform doesn't depend on instance state (maybe move it to another class?) Open
def perform(provider_id)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
BackendStorageRewriteWorker#perform doesn't depend on instance state (maybe move it to another class?) Open
def perform(class_name, ids)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
NotificationMailer#abilities is a writable attribute Open
attr_accessor :event_class, :hidden, :abilities, :hidden_om
- Read upRead up
- Exclude checks
A class that publishes a setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.
The same holds to a lesser extent for getters, but Reek doesn't flag those.
Example
Given:
class Klass
attr_accessor :dummy
end
Reek would emit the following warning:
reek test.rb
test.rb -- 1 warning:
[2]:Klass declares the writable attribute dummy (Attribute)
EventsFetchWorker#perform doesn't depend on instance state (maybe move it to another class?) Open
def perform
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
RenameServiceNotifications#self.up performs a nil-check Open
notification.reject! { |key,value| value.nil? }
- 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)
ChangeHashValuesInSystemOperation#down doesn't depend on instance state (maybe move it to another class?) Open
def down
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
AddUniqueIndexToConnectors#self.up performs a nil-check Open
unless row[3].nil?
- 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)
EventsTenantIdShouldNotBeMaster#up doesn't depend on instance state (maybe move it to another class?) Open
def up
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
AddIndexToAlertsOnAlertId#index_options doesn't depend on instance state (maybe move it to another class?) Open
def index_options
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
BackfillTitlesCMSSections#up doesn't depend on instance state (maybe move it to another class?) Open
def up
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
hour_selector doesn't depend on instance state (maybe move it to another class?) Open
def hour_selector
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
ChangeHashValuesInSystemOperation#up doesn't depend on instance state (maybe move it to another class?) Open
def up
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.