Showing 199 of 199 total issues
Class Account
has 47 methods (exceeds 20 allowed). Consider refactoring. Open
class Account < AccountAttributes
KILLBILL_API_ACCOUNTS_PREFIX = "#{KILLBILL_API_PREFIX}/accounts"
include KillBillClient::Model::TagHelper
Method request
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
def request(method, relative_uri, options = {})
head = headers.dup
head.update options[:head] if options[:head]
head.delete_if { |_, value| value.nil? }
- 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 request
has 109 lines of code (exceeds 25 allowed). Consider refactoring. Open
def request(method, relative_uri, options = {})
head = headers.dup
head.update options[:head] if options[:head]
head.delete_if { |_, value| value.nil? }
File account.rb
has 340 lines of code (exceeds 250 allowed). Consider refactoring. Open
module KillBillClient
module Model
class Account < AccountAttributes
KILLBILL_API_ACCOUNTS_PREFIX = "#{KILLBILL_API_PREFIX}/accounts"
File invoice.rb
has 331 lines of code (exceeds 250 allowed). Consider refactoring. Open
module KillBillClient
module Model
class Invoice < InvoiceAttributes
include KillBillClient::Model::CustomFieldHelper
Method instantiate_record_from_json
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def instantiate_record_from_json(resource_class, data)
record = resource_class.send :new
kb_ancestors = resource_class.ancestors.select { |ancestor| !@@attribute_names[ancestor.name].nil? }
data.each do |name, value|
- 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 Invoice
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class Invoice < InvoiceAttributes
include KillBillClient::Model::CustomFieldHelper
include KillBillClient::Model::TagHelper
include KillBillClient::Model::AuditLogWithHistoryHelper
Method create_proc_condition_for_wait_for_plugin_command_completion
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def create_proc_condition_for_wait_for_plugin_command_completion(options, plugin_key, plugin_version, state=nil, is_negate=false)
proc_condition = Proc.new {
node_infos = KillBillClient::Model::NodesInfo.nodes_info(options)
res = true
- 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 has_custom_fields
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
def has_custom_fields(url_prefix, id_alias)
define_method('custom_fields') do |*args|
audit = args[0] || 'NONE'
options = args[1] || {}
Class Transaction
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Transaction < PaymentTransactionAttributes
include KillBillClient::Model::CustomFieldHelper
include KillBillClient::Model::AuditLogWithHistoryHelper
include KillBillClient::Model::TagHelper
Class Tenant
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class Tenant < TenantAttributes
KILLBILL_API_TENANTS_PREFIX = "#{KILLBILL_API_PREFIX}/tenants"
KILLBILL_API_TENANTS_NOTIFICATION = "#{KILLBILL_API_TENANTS_PREFIX}/registerNotificationCallback"
KILLBILL_API_TENANTS_SYSTEM_CONFIGURATION = "#{KILLBILL_API_TENANTS_PREFIX}/uploadPerTenantConfig"
KILLBILL_API_TENANTS_PLUGIN_PAYMENT_STATE_MACHINE = "#{KILLBILL_API_TENANTS_PREFIX}/uploadPluginPaymentStateMachineConfig"
Class Resource
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class Resource
attr_reader :clazz,
:etag,
:session_id,
Method has_tags
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def has_tags(url_prefix, id_alias)
define_method('tags') do |*args|
included_deleted = args[0] || false
audit = args[1] || 'NONE'
Method from_response
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def from_response(resource_class, response)
case response['Content-Type']
when nil
response.body
when %r{application/pdf}
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
define_method('add_custom_field') do |*args|
custom_fields = args[0]
user = args[1]
reason = args[2]
- 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 63.
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
define_method('modify_custom_field') do |*args|
custom_fields = args[0]
user = args[1]
reason = args[2]
- 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 63.
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 trigger_node_command_wait_for_plugin_command_completion
has 12 arguments (exceeds 4 allowed). Consider refactoring. Open
def trigger_node_command_wait_for_plugin_command_completion(node_command_type, plugin_key, plugin_version, plugin_props, local_node_only, user, reason, comment, options, timeout_sec, sleep_sec, &proc_condition)
Method from_response
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def from_response(resource_class, response)
case response['Content-Type']
when nil
response.body
when %r{application/pdf}
Method build_uri
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def build_uri(relative_uri, options)
# Need to encode in case of spaces (e.g. /1.0/kb/security/users/Mad Max/roles)
encoded_relative_uri = URI::DEFAULT_PARSER.escape(relative_uri)
if URI(encoded_relative_uri).scheme.nil?
uri = (options[:base_uri] || KillBillClient::API.base_uri)
- 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 change_plan_dry_run
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
def change_plan_dry_run(account_id, bundle_id, subscription_id, target_date, product_name, product_category, billing_period, price_list_name,
effective_date, billing_policy, options = {})