Showing 5,267 of 5,597 total issues
Liquid::Template::FallbackResolver#build_path doesn't depend on instance state (maybe move it to another class?) Open
def build_path(name, prefix, partial)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
ThreeScale::SidekiqLoggingMiddleware#call doesn't depend on instance state (maybe move it to another class?) Open
def call(worker_class, msg, *)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
ThreeScale::Metrics::Yabeda#event_status_code_class performs a nil-check Open
code = if event.payload[:status].nil? && event.payload[:exception].present?
- 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)
TrackingNotifications#current_user doesn't depend on instance state (maybe move it to another class?) Open
def current_user
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Arel::Visitors takes parameters ['collector', 'o'] to 4 methods Open
def visit_Arel_Nodes_In(o, collector)
strip_order_from_select(o)
super
end
- Read upRead up
- Exclude checks
In general, a Data Clump
occurs when the same two or three items frequently appear together in classes and parameter lists, or when a group of instance variable names start or end with similar substrings.
The recurrence of the items often means there is duplicate code spread around to handle them. There may be an abstraction missing from the code, making the system harder to understand.
Example
Given
class Dummy
def x(y1,y2); end
def y(y1,y2); end
def z(y1,y2); end
end
Reek would emit the following warning:
test.rb -- 1 warning:
[2, 3, 4]:Dummy takes parameters [y1, y2] to 3 methods (DataClump)
A possible way to fix this problem (quoting from Martin Fowler):
The first step is to replace data clumps with objects and use the objects whenever you see them. An immediate benefit is that you'll shrink some parameter lists. The interesting stuff happens as you begin to look for behavior to move into the new objects.
ThreeScale::SidekiqRetrySupport::Middleware#call doesn't depend on instance state (maybe move it to another class?) Open
def call(worker, msg, *)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Liquid::Tags::InternalError#render doesn't depend on instance state (maybe move it to another class?) Open
def render(context)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
current_user doesn't depend on instance state (maybe move it to another class?) Open
def current_user
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
RailsSQLiFix#sanitize_actioncontroller_parameters doesn't depend on instance state (maybe move it to another class?) Open
def sanitize_actioncontroller_parameters(attributes)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
sanitize_redis_config doesn't depend on instance state (maybe move it to another class?) Open
def sanitize_redis_config(cfg)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Kernel#report_and_supress_exceptions doesn't depend on instance state (maybe move it to another class?) Open
def report_and_supress_exceptions
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
clause performs a nil-check Open
table_name = (model.nil? ? adapter.quoted_table_name : model.quoted_table_name)
column_name = (model.nil? ? adapter.quote(@column.to_s) : model.connection.quote_column_name(@column.to_s))
- 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)
RailsSQLiFix#action_controller_parameters_in? doesn't depend on instance state (maybe move it to another class?) Open
def action_controller_parameters_in?(attributes)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Line contains inconsistent indentation Open
values = {type: key, items: values, description: ThreeScaleAutoComplete.TipDescriptions[key]}
- Exclude checks
AuditedHacks::InstanceMethods#write_audit performs a nil-check Open
attrs[:associated] = send(audit_associated_with) unless audit_associated_with.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)
Line contains inconsistent indentation Open
values = {type: key, items: values, description: ThreeScaleAutoComplete.TipDescriptions[key]}
- Exclude checks
Identical blocks of code found in 2 locations. Consider refactoring. Open
def slice_and_use_defaults(params, *allowed)
options = super(params, *allowed)
return options unless options.key?(:metric_name)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 29.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
def slice_and_use_defaults(params, *allowed)
options = super(params, *allowed)
return options unless options.key?(:metric_name)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 29.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
def rejected(account)
self.provider_account = account.provider_account
headers('Return-Path' => from_address(account),
'X-SMTPAPI' => '{"category": "Account rejected"}')
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 29.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
def approved(account)
self.provider_account = account.provider_account
headers('Return-Path' => from_address(account),
'X-SMTPAPI' => '{"category": "Account approved"}')
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 29.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76