lib/azure/armrest/configuration.rb
Class Configuration
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Configuration
# Clear all class level caches. Typically used for testing only.
def self.clear_caches
token_cache.clear
end
Method initialize
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def initialize(args)
# Use defaults, and override with provided arguments
options = {
:api_version => '2015-01-01',
:accept => 'application/json',
Method initialize
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def initialize(args)
# Use defaults, and override with provided arguments
options = {
:api_version => '2015-01-01',
:accept => 'application/json',
- 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 set_provider_api_versions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def set_provider_api_versions
# A lookup table for getting api-version strings per provider and service.
@provider_api_versions = Hash.new { |hash, key| hash[key] = {} }
providers.each do |rp|
- 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
Variable value
used in void context. Open
Open
value
- Read upRead up
- Exclude checks
Checks for operators, variables, literals, lambda, proc and nonmutating methods used in void context.
Example: CheckForMethodsWithNoSideEffects: false (default)
# bad
def some_method
some_num * 10
do_something
end
def some_method(some_var)
some_var
do_something
end
Example: CheckForMethodsWithNoSideEffects: true
# bad
def some_method(some_array)
some_array.sort
do_something(some_array)
end
# good
def some_method
do_something
some_num * 10
end
def some_method(some_var)
do_something
some_var
end
def some_method(some_array)
some_array.sort!
do_something(some_array)
end