payout/rester

View on GitHub

Showing 22 of 78 total issues

Class Params has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Params
      DEFAULT_OPTS = { strict: true }.freeze
      BASIC_TYPES = [String, Symbol, Float, Integer, Array, Hash].freeze

      DEFAULT_TYPE_MATCHERS = {
Severity: Minor
Found in lib/rester/service/resource/params.rb - About 3 hrs to fix

    Class Service has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Service
        autoload(:Request,    'rester/service/request')
        autoload(:Resource,   'rester/service/resource')
        autoload(:Middleware, 'rester/service/middleware')
    
    
    Severity: Minor
    Found in lib/rester/service.rb - About 3 hrs to fix

      Method assert_deep_include has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

              def assert_deep_include(response, stub, accessors=[])
                case stub
                when Hash
                  _type_error(response, stub, accessors) unless response.is_a?(Hash)
                  stub.all? { |k,v| assert_deep_include(response[k], v, accessors + [k]) }
      Severity: Minor
      Found in lib/rester/utils/rspec.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

      File params.rb has 259 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Rester
        class Service::Resource
          class Params
            DEFAULT_OPTS = { strict: true }.freeze
            BASIC_TYPES = [String, Symbol, Float, Integer, Array, Hash].freeze
      Severity: Minor
      Found in lib/rester/service/resource/params.rb - About 2 hrs to fix

        Method _setup_example has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def _setup_example(ex)
            # Gather the request args from the spec descriptions
            #
            # For example:
            #
        Severity: Minor
        Found in lib/rester/rspec.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 _add_validator has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def _add_validator(name, klass, opts)
                fail 'must specify param name' unless name
                fail 'validation options must be a Hash' unless opts.is_a?(Hash)
                default_opts = { match: DEFAULT_TYPE_MATCHERS[klass] }
                opts = default_opts.merge(opts)
        Severity: Minor
        Found in lib/rester/service/resource/params.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(verb, path, opts={})
                body = opts[:data] || ''
                query = opts[:query] || ''
        
                response = Timeout::timeout(timeout) do
        Severity: Minor
        Found in lib/rester/client/adapters/local_adapter.rb - About 1 hr to fix

          Method _process_request has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def _process_request(path, verb, params)
                  unless stub[path]
                    fail Errors::StubError, "#{path} not found"
                  end
          
          
          Severity: Minor
          Found in lib/rester/client/adapters/stub_adapter.rb - About 55 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 _request has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def _request(verb, path, opts={})
                  body = opts[:data] || ''
                  query = opts[:query] || ''
          
                  response = Timeout::timeout(timeout) do
          Severity: Minor
          Found in lib/rester/client/adapters/local_adapter.rb - About 55 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 _parse_with_class has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def _parse_with_class(klass, value)
                  if klass == String
                    value
                  elsif klass == Integer
                    value.to_i
          Severity: Minor
          Found in lib/rester/service/resource/params.rb - About 55 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 encode_www_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def encode_www_data(value, prefix = nil)
                  # Rack::Utils.build_nested_query(value)
                  case value
                  when Array
                    value.map { |v|
          Severity: Minor
          Found in lib/rester/utils.rb - About 55 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 _error_to_response has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def _error_to_response(error)
                  code = _error_to_http_code(error)
          
                  unless [401, 403, 404].include?(code)
                    body_h = { error: _error_name(error) }
          Severity: Minor
          Found in lib/rester/service/middleware/error_handling.rb - About 55 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 _process_response has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def _process_response(start_time, verb, path, status, headers, body)
          Severity: Minor
          Found in lib/rester/client.rb - About 45 mins to fix

            Method _validate_required has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def _validate_required(key, is_defined)
                    unless is_defined
                      _, key, index = /(\w+)(\[\d+\])?/.match(key).to_a
            
                      if required?(key)
            Severity: Minor
            Found in lib/rester/service/resource/params.rb - About 45 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 _find_service has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def _find_service
                    service = app
            
                    loop {
                      break if service.is_a?(Service)
            Severity: Minor
            Found in lib/rester/service/middleware/base.rb - About 45 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 _record_failure has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def _record_failure
                    if @failure_count < threshold
                      _synchronize do
                        if @failure_count < threshold
                          @failure_count += 1
            Severity: Minor
            Found in lib/rester/utils/circuit_breaker.rb - About 45 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 _param_diff has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def _param_diff(params, spec_params)
                    params = params.dup
                    # Compile a list of mismatched params values
                    diff = spec_params.map { |k,v|
                      param_value = params.delete(k)
            Severity: Minor
            Found in lib/rester/client/adapters/stub_adapter.rb - About 45 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 _validate_obj has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def _validate_obj(key, obj, opts)
                    fail if obj.nil? # Assert, at this point should be guaranteed
            
                    opts.each do |opt, value|
                      case opt
            Severity: Minor
            Found in lib/rester/service/resource/params.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

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

                  def _validate_str(key, value, klass, opts)
                    fail unless value.is_a?(String) # assert
                    if [Array, Hash].include?(klass)
                      _error!("expected #{key} to be of type #{klass}")
                    end
            Severity: Minor
            Found in lib/rester/service/resource/params.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 _determine_method has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def _determine_method(request)
                    if request.object_chain.length.odd?
                      case request.request_method
                      when 'GET'  then 'search'
                      when 'POST' then 'create'
            Severity: Minor
            Found in lib/rester/service/middleware/new_relic.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

            Severity
            Category
            Status
            Source
            Language