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)
    
    

    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 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])
        
        

        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 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 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 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 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

              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 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

              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 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

              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

              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

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 33.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              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

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 33.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              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

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 33.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              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

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 33.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              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

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 32.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              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

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 32.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              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

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 31.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              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

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 31.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

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

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

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 31.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language