Showing 7 of 11 total issues
Method open_api_dry
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def open_api_dry
route_base = try(:controller_path) || oas[:route_base]
::OpenApi::Router.get_actions_by_route_base(route_base)&.each do |action|
api_dry action do
# Common :index parameters
- 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 open_api_dry
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def open_api_dry
route_base = try(:controller_path) || oas[:route_base]
::OpenApi::Router.get_actions_by_route_base(route_base)&.each do |action|
api_dry action do
# Common :index parameters
Method register
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def register(name, path = nil, format: :normal)
name = name.to_sym
path = nil if Rails.env.test? && path&.match?('/data/logs') # for ci
return puts "Logger named #{name} has exists".red if loggers&.key?(name.to_sym)
- 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 can?
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def can? *permission_codes, source: nil, &block
block_condition = permission_codes.delete(:then) || permission_codes.delete(:else)
permission_codes.flatten.each do |code|
vp = vactual_permissions = [ *Array(MakeSure.permission_mapper[code] || code) ]
# vp = [ *vp, *PermissionCode.where(code: code).map(&:permissions).flatten.compact.map(&:name).uniq ]
- 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 must
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def must *logic_names
success = nil
logic_names.each do |logic_name|
logic = MakeSure.logics.fetch(logic_name)
result = logic[:lambda] ? @_make_sure_obj.instance_exec(&logic[:lambda]) : instance_eval(&logic[:block])
- 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 make_sure
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def make_sure(obj = NoPass, action = nil, *args, &block)
@_make_sure_obj = obj if obj == :it
@_make_sure_obj = current_user if obj == NoPass
return self if action.nil?
- 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 inherited
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def inherited(subclass)
super
subclass.class_eval do
break unless name.match?(/Controller|Doc/)
route_base name.sub('Doc', '').underscore.gsub('::', '/') if name.match?(/Doc/)
- 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"