droidlabs/motion-prime

View on GitHub
motion-prime/api_client.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Class ApiClient has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

class ApiClient
  attr_accessor :access_token

  def initialize(options = {})
    self.access_token = options[:access_token]
Severity: Minor
Found in motion-prime/api_client.rb - About 2 hrs to fix

    Method request! has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

      def request!(method, path, data, files = nil, options = {}, &block)
        use_callback = block_given?
        path_with_base = path_with_base(path, config.api_namespace)
        client_method = files.present? ? :"multipart_#{method}" : method
        AFMotion::Client.shared.send client_method, path_with_base, data do |response, form_data, progress|
    Severity: Minor
    Found in motion-prime/api_client.rb - About 2 hrs 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 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def request!(method, path, data, files = nil, options = {}, &block)
    Severity: Minor
    Found in motion-prime/api_client.rb - About 45 mins to fix

      Method cached_request! has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def cached_request!(method, path, data, files = nil, options = {}, &block)
      Severity: Minor
      Found in motion-prime/api_client.rb - About 45 mins to fix

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

          def request(method, path, params = {}, options = {}, &block)
        Severity: Minor
        Found in motion-prime/api_client.rb - About 35 mins to fix

          Method request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def request(method, path, params = {}, options = {}, &block)
              files = params.delete(:_files)
              data = request_params(params.merge(access_token: access_token))
          
              if !options.has_key?(:allow_queue) && config.default_methods_queue.include?(method.to_sym)
          Severity: Minor
          Found in motion-prime/api_client.rb - About 25 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

          Method cached_request! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def cached_request!(method, path, data, files = nil, options = {}, &block)
              use_callback = block_given?
              params = data.map { |key, value| "#{key}=#{value}" }.join('&')
              cache_key = [method, path, params].join(' ')
              response = read_cache(cache_key)
          Severity: Minor
          Found in motion-prime/api_client.rb - About 25 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