lib/expressly/api.rb
Method execute
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def execute(method_uri, http_verb, body = nil, limit = 4)
raise 'too many HTTP redirects' if limit == 0
uri = URI.parse("#{@endpoint}#{method_uri}")
http = Net::HTTP.new(uri.host, uri.port)
Method execute
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def execute(method_uri, http_verb, body = nil, limit = 4)
raise 'too many HTTP redirects' if limit == 0
uri = URI.parse("#{@endpoint}#{method_uri}")
http = Net::HTTP.new(uri.host, uri.port)
- 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
(...)
interpreted as grouped expression. Open
Open
raise (if is_json && !body['id'].nil? then ExpresslyError.new(body) else HttpError.new(response) end)
- Read upRead up
- Exclude checks
Checks for space between the name of a called method and a left parenthesis.
Example:
# bad
puts (x + y)
Example:
# good
puts(x + y)
Put one space between the method name and the first argument. Open
Open
attr_accessor :id, :code, :description, :causes, :actions
- Read upRead up
- Exclude checks
Checks that exactly one space is used between a method name and the first argument for method calls without parentheses.
Alternatively, extra spaces can be added to align the argument with something on a preceding or following line, if the AllowForAlignment config parameter is true.
Example:
# bad
something x
something y, z
something'hello'
# good
something x
something y, z
something 'hello'