bigcommerce/gruf

View on GitHub

Showing 25 of 26 total issues

Method bind_method has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def bind_method(service_ref, controller, method_name, desc)
method_key = method_name.to_s.underscore.to_sym
controller_name = controller.name
service_ref.class_eval do
if desc.request_response?
Severity: Major
Found in lib/gruf/controllers/service_binder.rb - About 2 hrs to fix

    Method call has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def call(&block)
    return yield if options.fetch(:ignore_methods, [])&.include?(request.method_name)
     
    result = Gruf::Interceptors::Timer.time(&block)
     
     

    Method reset has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def reset
    VALID_CONFIG_KEYS.each do |k, v|
    send(:"#{k}=", v)
    end
    self.server_binding_url = "#{::ENV.fetch('GRPC_SERVER_HOST',
    Severity: Minor
    Found in lib/gruf/configuration.rb - About 1 hr to fix

      Method call has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def call(&block)
      return yield if options.fetch(:ignore_methods, [])&.include?(request.method_name)
       
      result = Gruf::Interceptors::Timer.time(&block)
       
       

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

        def redact!(parts = [], idx = 0, params = {}, redacted_string = 'REDACTED')
        return unless parts.is_a?(Array) && params.is_a?(Hash)
         
        return if idx >= parts.size || !params.key?(parts[idx])
         
         

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

        def call(request_method, params = {}, metadata = {}, opts = {}, &block)
        Severity: Minor
        Found in lib/gruf/client.rb - About 35 mins to fix

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

          def call(request_method, params = {}, metadata = {}, opts = {}, &block)
          Severity: Minor
          Found in lib/gruf/synchronized_client.rb - About 35 mins to fix

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

            def execute(call_sig, req, metadata, opts = {}, &block)
            Severity: Minor
            Found in lib/gruf/client.rb - About 35 mins to fix

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

              def intercept!(&block)
              return yield if @interceptors.none?
               
              i = @interceptors.shift
              return yield unless i
              Severity: Minor
              Found in lib/gruf/interceptors/context.rb - About 35 mins to fix

              Method call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              def call(request_method, params = {}, metadata = {}, opts = {}, &block)
              request_method = request_method.to_sym
              req = if params.respond_to?(:to_proto) || streaming_request?(request_method)
              params
              else
              Severity: Minor
              Found in lib/gruf/client.rb - About 35 mins to fix

              Method formatter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              def formatter
              unless @formatter
              fmt = options.fetch(:formatter, :plain)
              @formatter = case fmt
              when Symbol
              Severity: Minor
              Found in lib/gruf/interceptors/instrumentation/request_logging/interceptor.rb - About 35 mins to fix

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              def insert_after(after_class, interceptor_class, options = {})
              interceptors_mutex do
              pos = @registry.find_index { |opts| opts.fetch(:klass, '') == after_class }
              raise InterceptorNotFoundError if pos.nil?
               
               
              Severity: Minor
              Found in lib/gruf/interceptors/registry.rb and 1 other location - About 30 mins to fix
              lib/gruf/hooks/registry.rb on lines 87..96

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              def request_response(request: nil, call: nil, method: nil, metadata: nil, &block)
              rc = Gruf::Outbound::RequestContext.new(
              type: :request_response,
              requests: [request],
              call: call,
              Severity: Minor
              Found in lib/gruf/interceptors/client_interceptor.rb and 1 other location - About 30 mins to fix
              lib/gruf/interceptors/client_interceptor.rb on lines 86..94

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              def server_streamer(request: nil, call: nil, method: nil, metadata: nil, &block)
              rc = Gruf::Outbound::RequestContext.new(
              type: :server_streamer,
              requests: [request],
              call: call,
              Severity: Minor
              Found in lib/gruf/interceptors/client_interceptor.rb and 1 other location - About 30 mins to fix
              lib/gruf/interceptors/client_interceptor.rb on lines 46..54

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              def insert_after(after_class, hook_class, options = {})
              hooks_mutex do
              pos = @registry.find_index { |opts| opts.fetch(:klass, '') == after_class }
              raise HookNotFoundError if pos.nil?
               
               
              Severity: Minor
              Found in lib/gruf/hooks/registry.rb and 1 other location - About 30 mins to fix
              lib/gruf/interceptors/registry.rb on lines 87..96

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              def bidi_streamer(requests: nil, call: nil, method: nil, metadata: nil, &block)
              rc = Gruf::Outbound::RequestContext.new(
              type: :bidi_streamer,
              requests: requests,
              call: call,
              Severity: Minor
              Found in lib/gruf/interceptors/client_interceptor.rb and 1 other location - About 30 mins to fix
              lib/gruf/interceptors/client_interceptor.rb on lines 66..74

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              def client_streamer(requests: nil, call: nil, method: nil, metadata: nil, &block)
              rc = Gruf::Outbound::RequestContext.new(
              type: :client_streamer,
              requests: requests,
              call: call,
              Severity: Minor
              Found in lib/gruf/interceptors/client_interceptor.rb and 1 other location - About 30 mins to fix
              lib/gruf/interceptors/client_interceptor.rb on lines 105..113

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              define_method(method_key) do |messages, active_call, &block|
              Gruf::Autoloaders.controllers.with_fresh_controller(controller_name) do |fresh_controller|
              c = fresh_controller.new(
              method_key: method_key,
              service: service_ref,
              Severity: Minor
              Found in lib/gruf/controllers/service_binder.rb and 1 other location - About 25 mins to fix
              lib/gruf/controllers/service_binder.rb on lines 78..87

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              define_method(method_key) do |message, active_call, &block|
              Gruf::Autoloaders.controllers.with_fresh_controller(controller_name) do |fresh_controller|
              c = fresh_controller.new(
              method_key: method_key,
              service: service_ref,
              Severity: Minor
              Found in lib/gruf/controllers/service_binder.rb and 1 other location - About 25 mins to fix
              lib/gruf/controllers/service_binder.rb on lines 91..100

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              def insert_before(before_class, interceptor_class, options = {})
              interceptors_mutex do
              pos = @registry.find_index { |opts| opts.fetch(:klass, '') == before_class }
              raise InterceptorNotFoundError if pos.nil?
               
               
              Severity: Minor
              Found in lib/gruf/interceptors/registry.rb and 1 other location - About 25 mins to fix
              lib/gruf/hooks/registry.rb on lines 66..75
              Severity
              Category
              Status
              Source
              Language