Showing 46 of 46 total issues
Method request_uri
has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring. Open
def request_uri(method, uri, options = {})
uri = URI.parse(uri)
unless uri.is_a?(URI::HTTP)
raise InvalidTarget.new(@target)
- 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 succeed_to_load
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
def succeed_to_load(options={})
response_body = Helper.load_fixtures(options[:fixture] || "fake_cc_user")
response_body["metadata"]["guid"] = options[:id] || "user-id-1"
if options[:no_organizations]
- 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 to_many
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def to_many(plural, opts = {})
to_many_relations[plural] = opts
singular = plural.to_s.sub(/s$/, "").to_sym
- 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 add_client_methods
has 98 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_client_methods(klass)
singular = klass.object_name
plural = klass.plural_object_name
define_base_client_methods do
Class App
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
class App < Model
include CFoundry::UploadHelpers
attribute :name, :string
to_one :space
Method to_one
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def to_one(name, opts = {})
to_one_relations[name] = opts
association_name = opts[:as] || name
default = opts[:default]
- 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 to_many
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_many(plural, opts = {})
to_many_relations[plural] = opts
singular = plural.to_s.sub(/s$/, "").to_sym
Class Model
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class Model
include ActiveModel::Validations
@@objects = {}
Method request_uri
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
def request_uri(method, uri, options = {})
uri = URI.parse(uri)
unless uri.is_a?(URI::HTTP)
raise InvalidTarget.new(@target)
Method add_client_methods
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def add_client_methods(klass)
singular = klass.object_name
plural = klass.plural_object_name
define_base_client_methods do
- 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 attribute
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def attribute(name, type, opts = {})
attributes[name] = opts
json_name = opts[:at] || name
default = opts[:default]
- 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 BaseClient
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class BaseClient # :nodoc:
include CFoundry::ProxyOptions
extend Forwardable
Method to_one
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_one(name, opts = {})
to_one_relations[name] = opts
association_name = opts[:as] || name
default = opts[:default]
Similar blocks of code found in 2 locations. Consider refactoring. Open
module OrganizationUsers
extend Helper
class << self
def succeed_to_delete(options = {})
- 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 66.
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
module SpaceUsers
extend Helper
class << self
def succeed_to_delete(options = {})
- 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 66.
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 health
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def health
if state == "STARTED"
healthy_count = running_instances
expected = total_instances
- 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 create!
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def create!
payload = {}
@manifest ||= {}
@manifest[:entity] ||= {}
- 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 log_request
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def log_request(time, request, response)
return unless @log
data = log_data(time, request, response)
- 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 create!
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create!
payload = {}
@manifest ||= {}
@manifest[:entity] ||= {}
Method attribute
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def attribute(name, type, opts = {})
attributes[name] = opts
json_name = opts[:at] || name
default = opts[:default]