Showing 5,380 of 5,717 total issues
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 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"
Further reading
File email_template.rb
has 257 lines of code (exceeds 250 allowed). Consider refactoring. Open
class CMS::EmailTemplate < CMS::Template
validates :system_name, presence: true
validates :current, presence: true
validates :system_name, uniqueness: { scope: %i[provider_id], allow_blank: true, case_sensitive: true }
Class Event
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class Event
class Error < ::StandardError; end
class MissingResourceError < Error; end
# This object represents one webhook event
Class Section
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class CMS::Section < ApplicationRecord
include ThreeScale::Search::Scopes
include CMS::Filtering
extend System::Database::Scopes::IdOrSystemName
include NormalizePathAttribute
Class ApplicationKey
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class ApplicationKey < ApplicationRecord
include SaveDestroyForApplicationAssociation
KEYS_LIMIT = 5
Class ApplicationsController
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class DeveloperPortal::Admin::ApplicationsController < ::DeveloperPortal::BaseController
self.responder = ThreeScale::Api::Responder
include Liquid::TemplateSupport
Class SimpleLayout
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class SimpleLayout
attr_reader :provider
def initialize(provider)
Class Service
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class Service < Drops::Model
allowed_name :service
def initialize(service, opts = {})
Method verify!
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def verify!(object)
# this controller shouldnt be checked
return true if @env["action_controller.request.path_parameters"]["controller"] == "provider/domains"
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ($("#fields_definition_required")[0].checked){
$("#fields_definition_hidden")[0].checked=false;
$("#fields_definition_read_only")[0].checked=false;
$("#fields_definition_hidden").attr('disabled',true);
$("#fields_definition_read_only").attr('disabled',true);
- 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 74.
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
if (($("#fields_definition_required").size() != 0 ) &&
($("#fields_definition_required")[0].checked)){
$("#fields_definition_hidden")[0].checked=false;
$("#fields_definition_read_only")[0].checked=false;
$("#fields_definition_hidden").attr('disabled',true);
- 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 74.
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 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.up
create_table :contracts do |t|
t.column :id, :int, :null => false, :autoincrement => true
#the provider
Method down
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.down
create_table "news_article_versions", :force => true do |t|
t.integer "news_article_id"
t.integer "version"
t.string "name"
Method freeze_closed_invoices
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.freeze_closed_invoices
Invoice.reset_column_information
all = Invoice.count
count = 0
Method to_xml
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_xml(options = {})
result = options[:builder] || ThreeScale::XML::Builder.new
result.application do |xml|
unless new_record?
Method down
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.down
create_table :liquid_pages do |table|
table.integer :account_id
table.string :title
table.text :content
Method up
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.up
pages = LiquidPage.find_all_by_title('layout')
pages.each do |page|
puts "Hacking layout of: #{page.account.try!(:org_name)}"