Showing 5,299 of 5,637 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
def self.down
change_table :contracts do |t|
t.string :limit_hits
t.string :limit_stored
t.string :limit_transfer
- 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 102.
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
def self.up
change_table :contracts do |t|
t.remove :limit_hits
t.remove :limit_stored
t.remove :limit_transfer
- 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 102.
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
Function disableInterface
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
function disableInterface(){
function enable_checkboxes(){
checkboxes_disabled(false);
}
Method extract_range_and_granularity
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def extract_range_and_granularity(options)
if options[:period]
period = sanitize_period(options[:period])
granularity = options[:granularity] || GRANULARITIES[period]
length = 1.send(period)
- 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 Provider
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Provider < Drops::Base
example %(
<div>Domain {{ provider.domain }}</div>
Identical blocks of code found in 2 locations. Consider refactoring. Open
box.find(".select-plan-button").click(function(){
var planID = $(this).attr('data-plan-id');
var planName = $(this).attr('data-plan-name');
box.fadeOut();
PlanWidget.callback(planName, planID);
- 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 88.
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
box.find(".select-plan-button").click(function(){
var planID = $(this).attr('data-plan-id');
var planName = $(this).attr('data-plan-name');
box.fadeOut();
PlanWidget.callback(planName, planID);
- 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 88.
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
File provider_steps.rb
has 276 lines of code (exceeds 250 allowed). Consider refactoring. Open
def import_simple_layout(provider)
simple_layout = SimpleLayout.new(provider)
simple_layout.import_pages!
simple_layout.import_js_and_css! if @javascript
end
Class InvoiceReportData
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Pdf::Finance::InvoiceReportData
LINE_ITEMS_HEADING = %w[Name Quantity Cost Charged].freeze
DATE_FORMAT = "%e %B, %Y"
LOGO_ATTACHMENT_STYLE = :invoice
File application_helper.rb
has 270 lines of code (exceeds 250 allowed). Consider refactoring. Open
module ApplicationHelper # rubocop:disable Metrics/ModuleLength
# this is used just to not load font awesome in tests
def capybara_webkit?
Rails.env.test? && defined?(Capybara.current_driver) && Capybara.current_driver == :webkit
Method friendly_service_setting
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def friendly_service_setting service, setting
value = service.send setting
message, value = case setting
when :custom_keys_enabled
['Custom application keys are VALUE', value ? 'enabled' : 'disabled']
- 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 rolling_updates.rb
has 266 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Logic
module RollingUpdates
class UnknownFeatureError < StandardError; end
class UnknownFeatureConfigError < StandardError
include Bugsnag::MetaData
File simple_layout.rb
has 265 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'sprockets'
require 'compass-rails'
require 'sass'
class SimpleLayout
File account.rb
has 265 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Liquid
module Drops
class Account < Drops::Model
info %{
Class Template
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class CMS::Template < ApplicationRecord
include Symbolize
include ThreeScale::Search::Scopes
include CMS::Filtering
Class FrontendController
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class FrontendController < ApplicationController
SecureHeaders::Configuration.override(:disable_x_frame) do |config|
config.x_frame_options = SecureHeaders::OPT_OUT
end
Class ClusterClient
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class ClusterClient
class ClusterClientError < StandardError; end
class ResourceNotFound < ClusterClientError
def initialize(resource_type, name, namespace, labels = {})
Class Contract
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class Contract < ApplicationRecord
# Need to define table_name before audited because of
# https://github.com/collectiveidea/audited/blob/f03c5b5d1717f2ebec64032d269316dc74476056/lib/audited/auditor.rb#L305-L311
self.table_name = 'cinstances'
Class ClientBase
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class ClientBase
class ClientError < StandardError
include Bugsnag::MetaData
def initialize(error_message, options = {})
Method assert_line_items
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def assert_line_items(items)
items.hashes.each_with_index do |line, i|
name = line['name']
cost = line['cost']
cost = /#{cost}\./ unless cost.include?('.')
- 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"