Showing 5,377 of 5,713 total issues
Method provider_request
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
def provider_request
return unless provider?
hourly(&:group)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Class Cinstance
has 52 methods (exceeds 20 allowed). Consider refactoring. Open
class Cinstance < Contract
include SaveDestroyForServiceAssociation
# Maximum number of cinstances permitted between provider and buyer
MAX = 10
Class Plan
has 51 methods (exceeds 20 allowed). Consider refactoring. Open
class Plan < ApplicationRecord
include Searchable
class PeriodRangeCalculationError < StandardError; end
include Symbolize
File service.rb
has 435 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'backend_client'
class Service < ApplicationRecord # rubocop:disable Metrics/ClassLength
include Searchable
include Backend::ModelExtensions::Service
File invoice.rb
has 426 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Invoice < ApplicationRecord
%I[due_on period issued_on last_charging_retry].each do |attr|
attribute attr, :date
end
Identical blocks of code found in 2 locations. Consider refactoring. Open
markCurrentPlan: function(planPreviewBoxId){
var box = $('#' + planPreviewBoxId);
var $current = box.find('div.plan-preview[data-plan-id="' + this.currentPlan + '"]');
$(".current-plan-notice").hide();
- 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 159.
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
markCurrentPlan: function(planPreviewBoxId){
var box = $('#' + planPreviewBoxId);
var $current = box.find('div.plan-preview[data-plan-id="' + this.currentPlan + '"]');
$(".current-plan-notice").hide();
- 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 159.
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
Class Account
has 43 methods (exceeds 20 allowed). Consider refactoring. Open
class Account < Drops::Model
info %{
A developer account. See `User` drop if you are looking for the email addresses or similar information.
}
File account.rb
has 403 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Account < ApplicationRecord
attribute :credit_card_expires_on, :date
self.ignored_columns = %i[proxy_configs_file_name proxy_configs_content_type proxy_configs_file_size
proxy_configs_updated_at proxy_configs_conf_file_name proxy_configs_conf_content_type
proxy_configs_conf_file_size proxy_configs_conf_updated_at]
Method error_messages_for
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
def error_messages_for(*params)
ignore_me = ['Account is invalid', 'Bought cinstances is invalid']
options = params.extract_options!.symbolize_keys
objects = if object = options.delete(:object)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File 20100125103539_browser_cms_tables.rb
has 398 lines of code (exceeds 250 allowed). Consider refactoring. Open
class BrowserCmsTables < ActiveRecord::Migration
def self.up
create_table "attachment_versions", :force => true do |t|
t.integer "attachment_id"
t.integer "version"
File user.rb
has 389 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'digest/sha1'
class User < ApplicationRecord
include Symbolize
Class Application
has 40 methods (exceeds 20 allowed). Consider refactoring. Open
class Application < Drops::Contract
drop_example "Using application drop in liquid.", %{
<h1>Application {{ application.name }} (<span title="Application ID">{{ application.application_id }}</span>)</h1>
<p>{{ application.description }}</p>
}
Similar blocks of code found in 2 locations. Consider refactoring. Open
showPlan: function(previewBoxId, planID){
var box = $('#' + previewBoxId);
if(typeof(planID) == 'undefined'){
planID = this.currentPlan;
- 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 141.
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 2 locations. Consider refactoring. Open
showPlan: function(previewBoxId, planID){
var box = $('#' + previewBoxId);
if(typeof(planID) == 'undefined'){
planID = this.currentPlan;
- 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 141.
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
Method up
has 128 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.up
create_table :blogs do |t|
t.string :name
t.string :format
t.text :template
Class BillingStrategy
has 37 methods (exceeds 20 allowed). Consider refactoring. Open
class Finance::BillingStrategy < ApplicationRecord
module NonAuditedColumns
def non_audited_columns
super - [inheritance_column]
end
Method charge!
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def charge!(automatic = true)
ensure_payable_state!
unless chargeable?
logger.info "Not charging invoice #{id} (buyer #{buyer_account_id}), reason: #{reason_cannot_charge}"
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method clause
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def clause(*args)
model = (args.length >= 2 ? args[0] : nil)
is_delta = (args.length >= 2 ? args[1] : args[0]) || false
table_name = (model.nil? ? adapter.quoted_table_name : model.quoted_table_name)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Class NotificationMailer
has 35 methods (exceeds 20 allowed). Consider refactoring. Open
class NotificationMailer < ActionMailer::Base
default from: Rails.configuration.three_scale.notification_email
layout 'notification_email'