Showing 57 of 65 total issues
Class Application
has 44 methods (exceeds 20 allowed). Consider refactoring. Open
class Application
include Storable
# list of attributes to be fetched from storage
ATTRIBUTES = [:state, :plan_id, :plan_name, :redirect_url].freeze
Class Service
has 40 methods (exceeds 20 allowed). Consider refactoring. Open
class Service
include Storable
# list of attributes to be fetched from storage
ATTRIBUTES = %i[state referrer_filters_required backend_version provider_key].freeze
Method create_granularity_class
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_granularity_class(name)
Class.new do
include Instance
@name = name
Class Metric
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class Metric
module KeyHelpers
def key(service_id, id, attribute)
encode_key("metric/service_id:#{service_id}/id:#{id}/#{attribute}")
end
Method cfg_sentinels_handler
has a Cognitive Complexity of 22 (exceeds 5 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
- Read upRead up
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
Class Status
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Status
# This is the default field we respond with when using OAuth redirects
# We only use 'redirect_uri' if a request sent such a param. See #397.
REDIRECT_URI_FIELD = 'redirect_url'.freeze
private_constant :REDIRECT_URI_FIELD
Class Memoizer
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Memoizer
EXPIRE = 60
PURGE = 60
MAX_ENTRIES = 10000
ACTIVE = true
Class UsageReport
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class UsageReport
attr_reader :type, :period
def initialize(status, usage_limit)
@status = status
Method reschedule_failed_jobs
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def reschedule_failed_jobs
# There might be several callers trying to requeue failed jobs at the
# same time. We need to use a lock to avoid rescheduling the same
# failed job more than once.
key = dist_lock.lock
- Read upRead up
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_stats_keys_with_val_0
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def delete_stats_keys_with_val_0(redis_conn, log_deleted_keys)
cursor = 0
loop do
with_retries do
- Read upRead up
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
Class Listener
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class Listener < Sinatra::Base
disable :logging
enable :raise_errors
disable :show_exceptions
File listener.rb
has 255 lines of code (exceeds 250 allowed). Consider refactoring. Open
require '3scale/backend/version'
require '3scale/backend/cors'
require '3scale/backend/csp'
require 'json'
File application.rb
has 254 lines of code (exceeds 250 allowed). Consider refactoring. Open
module ThreeScale
module Backend
class Application
include Storable
Method normalize_non_empty_keys!
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def normalize_non_empty_keys!
AUTH_AUTHREP_COMMON_PARAMS.each do |p|
thisparam = params[p]
if !thisparam.nil?
if thisparam.class != String
- Read upRead up
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_api_method
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def do_api_method(method_name)
halt 403 if params.nil?
normalize_non_empty_keys!
- Read upRead up
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_compact_s
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def to_compact_s
s = year * 10000 + month * 100 + day
if sec != 0
s = s * 100000 + hour * 1000 + min * 10
MODS[sec] == 0 ? s + DIVS[sec] : s * 10 + sec
- Read upRead up
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 new_to_compact_s
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def new_to_compact_s
s = year * 10000 + month * 100 + day
if sec != 0
s = s * 100000 + hour * 1000 + min * 10
MODS[sec] == 0 ? s + DIVS[sec] : s * 10 + sec
- Read upRead up
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 12 (exceeds 5 allowed). Consider refactoring. Open
def start(job_queue)
loop do
break if @shutdown
jobs = fetch(wait: false, max: Worker::DEFAULT_MAX_CONCURRENT_JOBS)
- Read upRead up
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 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]
- Read upRead up
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