hackedteam/rcs-common

View on GitHub
lib/rcs-common/updater/client.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Client has 35 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Client
      include RCS::Tracer
      include TmpDir
      extend Resolver

Severity: Minor
Found in lib/rcs-common/updater/client.rb - About 4 hrs to fix

    File client.rb has 282 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'yajl/json_gem'
    require 'net/http'
    require 'uri'
    require 'timeout'
    require 'digest/md5'
    Severity: Minor
    Found in lib/rcs-common/updater/client.rb - About 2 hrs to fix

      Method request has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      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(' | ')}")
      
      
      Severity: Minor
      Found in lib/rcs-common/updater/client.rb - About 1 hr to fix

      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

            def request(payload, options = {}, retry_count = self.max_retries)
              msg = options[:store] ? [] : [payload]
              msg = ["#{payload.size} B", options.inspect]
              trace(:debug, "REQ #{msg.join(' | ')}")
      
      
      Severity: Minor
      Found in lib/rcs-common/updater/client.rb - About 1 hr to fix

        Method service_failure has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def service_failure(service_name, reset = 0, action1 = "restart/60000", action2 = "restart/60000", action3 = "restart/60000")
        Severity: Minor
        Found in lib/rcs-common/updater/client.rb - About 35 mins to fix

          Method rm_rf has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          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)
          Severity: Minor
          Found in lib/rcs-common/updater/client.rb - About 35 mins to fix

          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

          There are no issues that match your filters.

          Category
          Status