3scale/apisonator

View on GitHub

Showing 57 of 65 total issues

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

          def self.to_hash(service_id, plan_id, metric_id, period, value)
Severity: Minor
Found in app/api/internal/usagelimits.rb - About 35 mins to fix

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

          def update_utilization(service_id, app_id, max_utilization, max_record, timestamp)
    Severity: Minor
    Found in lib/3scale/backend/alerts.rb - About 35 mins to fix

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

                def aggregate_values(value, timestamp, keys, cmd, client = storage)
      Severity: Minor
      Found in lib/3scale/backend/stats/aggregators/base.rb - About 35 mins to fix

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

                  def delete!(redis_conns, log_deleted_keys: nil)
                    services = services_to_delete
                    logger.info("Going to delete the stats keys for these services: #{services.to_a}")
        
                    unless services.empty?
        Severity: Minor
        Found in lib/3scale/backend/stats/cleaner.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 threescale_extensions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.threescale_extensions(env, params = nil)
                options = env['HTTP_3SCALE_OPTIONS'.freeze]
                if options
                  ::Rack::Utils.parse_nested_query(options).symbolize_names
                else
        Severity: Minor
        Found in lib/3scale/backend/listener.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 fetch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def fetch(wait: true, max: nil)
                queue, encoded_jobs = wait ? wait_pop_from_queue : try_pop_from_queue(max)
                return if !encoded_jobs || encoded_jobs.empty?
        
                # filter_map to ignore `decode_job` errors causing it to return `nil`
        Severity: Minor
        Found in lib/3scale/backend/job_fetcher.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 clear_queue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def clear_queue
            fetcher = JobFetcher.new(fetch_timeout: 1)
            worker = new_worker(fetcher)
            queues = fetcher.instance_variable_get(:@queues)
            redis = async? ? fetcher.instance_variable_get(:@redis) : dup_resque_redis
        Severity: Minor
        Found in bench/worker/worker_bench.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 valid_encoding? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                def valid_encoding?
                  self.each do |v|
                    if v.is_a?(String) || v.is_a?(Array) || v.is_a?(Hash)
                      return false unless v.valid_encoding?
                    end
        Severity: Minor
        Found in lib/3scale/backend/extensions/array.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 process_parents has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def process_parents(usage)
                  usage.inject(usage.dup) do |memo, (id, val)|
                    is_set_op = Usage.is_set?(val)
        
                    while (id = parent_id(id))
        Severity: Minor
        Found in lib/3scale/backend/metric/collection.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 perform_wrapper has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def perform_wrapper(args)
                  start_time = Time.now.getutc
                  status_ok, message = perform_logged(*args)
                  stats_mem = Memoizer.stats
                  end_time = Time.now.getutc
        Severity: Minor
        Found in lib/3scale/backend/background_job.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 resolve_slave has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def resolve_slave
                  @sentinel_endpoints.each do |sentinel_endpoint|
                    client = Async::Redis::Client.new(sentinel_endpoint, protocol: Protocol::ExtendedRESP2.new(credentials: @sentinel_credentials))
        
                    begin
        Severity: Minor
        Found in lib/3scale/backend/async_redis/sentinels_client_acl_tls.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 apply has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def apply
                  invalid_exception = RedirectURIInvalid
                  redirect_uri = if params.has_key? REDIRECT_URL
                                   invalid_exception = RedirectURLInvalid
                                   params[REDIRECT_URL]
        Severity: Minor
        Found in lib/3scale/backend/validators/redirect_uri.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 start has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def self.start(global_options, options, args)
                  manifest = global_options[:manifest]
                  return unless manifest
                  argv = ['puma']
                  argv_add argv, options[:daemonize], '-d'
        Severity: Minor
        Found in lib/3scale/backend/server/puma.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 utilization has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def utilization(app_usage_reports)
                max_utilization = -1.0
                max_record = nil
                max = proc do |item|
                  if item.max_value > 0
        Severity: Minor
        Found in lib/3scale/backend/alerts.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 fix_date_cols has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                  def fix_date_cols(hash, period_val)
                    DATE_COLS.each do |date_col|
                      hash[date_col] = if date_col == 'year'
                                         period_val.slice! 0, 4
                                       else
        Severity: Minor
        Found in lib/3scale/backend/stats/stats_parser.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 apply has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def apply
                  if service.referrer_filters_required? && application.has_referrer_filters?
                    if application.referrer_filters.any? { |filter| matches?(filter, params[:referrer]) }
                      succeed!
                    else
        Severity: Minor
        Found in lib/3scale/backend/validators/referrer.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 parse_json_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def parse_json_params(params)
                  # Puma::NullIO (in v4.3.9) does not implement "closed?"
                  body_closed = if request.body.respond_to?(:closed?)
                                  request.body.closed?
                                elsif request.body.respond_to?(:eof?)
        Severity: Minor
        Found in app/api/internal/internal.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