3scale/apisonator

View on GitHub

Showing 65 of 65 total issues

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

          def extract_query_string(env)
            qs = env[QUERY_STRING]
            if env[REQUEST_METHOD].to_s.upcase == STR_POST
              provider_key = begin
                ::Rack::Request.new(env).params[STR_PROVIDER_KEY]
Severity: Minor
Found in lib/3scale/backend/logging/middleware/writer.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 validate has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def validate(oauth, provider_key, report_usage, params, request_info)
        service = Service.load_with_provider_key!(params[:service_id], provider_key)
        oidc_service = !oauth && service.backend_version == 'oauth'.freeze

        # service_id cannot be taken from params since it might be missing there
Severity: Minor
Found in lib/3scale/backend/transactor.rb - About 1 hr to fix

    Method process_all has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

          def process_all
            barrier = Async::Barrier.new
            semaphore = Async::Semaphore.new(@max_concurrent_jobs, parent: barrier)
    
            Worker.logger.info "Start processing all.."
    Severity: Minor
    Found in lib/3scale/backend/worker_async.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 delete_keys has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

              def delete_keys(redis_conn, services, log_deleted_keys)
                cursor = 0
    
                loop do
                  with_retries do
    Severity: Minor
    Found in lib/3scale/backend/stats/cleaner.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 do_authrep has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

          def do_authrep(method, provider_key, params, context_info)
            request_info = context_info[:request] || {}
            status = begin
                       validate(method == :oauth_authrep, provider_key, true, params, request_info)
                     rescue ApplicationNotFound => e
    Severity: Minor
    Found in lib/3scale/backend/transactor.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 do_batch has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def do_batch(list)
              all = Hash.new
    
              list.each do |item|
                obj = decode(item)
    Severity: Minor
    Found in lib/3scale/backend/transactor/notify_batcher.rb - About 1 hr to fix

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

                def update_alerts(applications)
                  current_timestamp = Time.now.getutc
      
                  applications.each do |_appid, values|
                    service_id = values[:service_id]
      Severity: Minor
      Found in lib/3scale/backend/stats/aggregator.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 to_xml has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

              def to_xml(options = {})
                xml = ''
                xml << '<?xml version="1.0" encoding="UTF-8"?>'.freeze unless options[:skip_instruct]
                xml << '<status>'.freeze
      
      
      Severity: Minor
      Found in lib/3scale/backend/transactor/status.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 valid_encoding? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

              def valid_encoding?
                self.each do |k, v|
                  return false if k.is_a?(String) && !k.valid_encoding?
                  if v.is_a?(String) || v.is_a?(Array) || v.is_a?(Hash)
                    return false unless v.valid_encoding?
      Severity: Minor
      Found in lib/3scale/backend/extensions/hash.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 cfg_sentinels_handler has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                def cfg_sentinels_handler(options)
                  # get role attr and remove from options
                  # will only be validated and included when sentinels are valid
                  role = options.delete :role
                  sentinels = options.delete :sentinels
      Severity: Minor
      Found in lib/3scale/backend/storage_helpers.rb - About 1 hr to fix

        Method define_metrics has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def define_metrics
                  Yabeda.configure do
                    group :apisonator_listener do
                      counter :response_codes do
                        comment 'Response codes'
        Severity: Minor
        Found in lib/3scale/backend/listener_metrics.rb - About 1 hr to fix

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

                  def with_app_id_from_params(service_id, app_id, user_key)
                    if app_id
                      raise AuthenticationError unless user_key.nil?
                    elsif user_key
                      app_id = load_id_by_key(service_id, user_key)
          Severity: Minor
          Found in lib/3scale/backend/application.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 aggregate_values has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                    def aggregate_values(value, timestamp, keys, cmd, client = storage)
                      keys_for_bucket = []
          
                      keys.each do |metric_type, prefix_key|
                        granularities(metric_type).each do |granularity|
          Severity: Minor
          Found in lib/3scale/backend/stats/aggregators/base.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 run has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.run(rack)
                  rack.instance_eval do
                    use Rack::InternalErrorCatcher if Backend.production?
          
                    Backend::Logging::External.setup_rack self
          Severity: Minor
          Found in lib/3scale/backend/rack.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 perform_logged has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                    def perform_logged(service_id, raw_transactions, _enqueue_time, context_info = {})
                      context_info ||= {} # avoid nils potentially existing in older versions
                      request_info = context_info['request'.freeze] || {}
          
                      transactions = parse_transactions(service_id, raw_transactions, request_info)
          Severity: Minor
          Found in lib/3scale/backend/transactor/report_job.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 validate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def validate(oauth, provider_key, report_usage, params, request_info)
                  service = Service.load_with_provider_key!(params[:service_id], provider_key)
                  oidc_service = !oauth && service.backend_version == 'oauth'.freeze
          
                  # service_id cannot be taken from params since it might be missing there
          Severity: Minor
          Found in lib/3scale/backend/transactor.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 service_id has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def service_id
                  if params[:service_id].nil? || params[:service_id].empty?
                    @service_id ||= Service.default_id!(params[:provider_key])
                  else
                    unless Service.authenticate_service_id(params[:service_id], params[:provider_key])
          Severity: Minor
          Found in lib/3scale/backend/listener.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 work has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def work
                  register_worker
          
                  loop do
                    break if @shutdown
          Severity: Minor
          Found in lib/3scale/backend/worker_sync.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 parse_transactions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                    def parse_transactions(service_id, raw_transactions, request_info)
                      transactions = []
                      exts = request_info['extensions'.freeze]&.symbolize_names || {}
          
                      group_by_application_id(service_id, raw_transactions) do |app_id, group|
          Severity: Minor
          Found in lib/3scale/backend/transactor/report_job.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 parse_non_unix_timestamp has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def parse_non_unix_timestamp(ts)
                    parts = Date._parse ts
          
                    if parts.has_key?(:year) && parts.has_key?(:mon) && parts.has_key?(:mday)
                      utc_time = Time.utc(parts[:year],
          Severity: Minor
          Found in lib/3scale/backend/extensions/time.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

          Severity
          Category
          Status
          Source
          Language