lib/rcs-common/updater/client.rb
Class Client
has 35 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Client
include RCS::Tracer
include TmpDir
extend Resolver
File client.rb
has 282 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
require 'yajl/json_gem'
require 'net/http'
require 'uri'
require 'timeout'
require 'digest/md5'
Method request
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
def request(payload, options = {}, retry_count = self.max_retries)
msg = options[:store] ? [] : [payload]
msg = ["#{payload.size} B", options.inspect]
trace(:debug, "REQ #{msg.join(' | ')}")
- 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 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def request(payload, options = {}, retry_count = self.max_retries)
msg = options[:store] ? [] : [payload]
msg = ["#{payload.size} B", options.inspect]
trace(:debug, "REQ #{msg.join(' | ')}")
Method service_failure
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def service_failure(service_name, reset = 0, action1 = "restart/60000", action2 = "restart/60000", action3 = "restart/60000")
Method rm_rf
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def rm_rf(path, allow: [], check: true)
if localhost?
FileUtils.rm_rf(unixpath(path))
else
request("ruby -e 'require \"fileutils\"; FileUtils.rm_rf(\"#{unixpath(path)}\");'", exec: 1)
- 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"