Showing 21 of 21 total issues
Class Configuration
has 47 methods (exceeds 20 allowed). Consider refactoring. Open
class Configuration
class Registration
def add_config_option(key)
self.class.class_eval { attr_accessor key.to_sym }
end
Method api_error_handler
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def api_error_handler(exception)
ApiGuardian.logger.error 'ApiError: ' + exception.class.name + ' - ' + exception.message
if exception.is_a? Pundit::NotAuthorizedError
user_not_authorized
- 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 ApiController
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class ApiController < ActionController::API
include ::Pundit
include ApiGuardian::Concerns::ApiErrors::Handler
include ApiGuardian::Concerns::ApiRequest::Validator
Method api_error_handler
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def api_error_handler(exception)
ApiGuardian.logger.error 'ApiError: ' + exception.class.name + ' - ' + exception.message
if exception.is_a? Pundit::NotAuthorizedError
user_not_authorized
Method permissions
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def permissions
arr = role_permissions_collection.map do |rp|
rp.permission.name if rp.granted
end.compact
- 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 change
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change
create_table :oauth_applications, id: :uuid do |t|
t.string :name, null: false
t.string :uid, null: false
t.string :secret, null: false
Method complete_reset_password
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.complete_reset_password(attributes)
instance = new(nil)
# Find user by token
user = instance.find_by_reset_password_token(attributes[:token])
- 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 remove_permission
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def remove_permission(name, destroy = false)
role_permissions.includes(:permission).each do |rp|
next unless rp.permission.name == name
if destroy
rp.destroy
- 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 authenticate_request
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.authenticate_request(user, request)
return true unless ApiGuardian.configuration.enable_2fa
if user.otp_enabled
otp_header_name = ApiGuardian.configuration.otp_header_name
- 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_content_type
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def validate_content_type
if request.body.read != ''
allowed = determine_content_types
content_type = request.headers['Content-Type']
- 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_auth_header
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate_auth_header
fail StandardError, 'Digits Auth Headers invalid or missing' unless auth_header
auth_header.gsub('OAuth ', '').split(', ').each do |piece|
key = piece.split('=')[0]
next unless key == 'oauth_consumer_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 array_permission_check
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def array_permission_check(actions)
grants = []
perms = load_permission(actions)
unless perms.length > 0
- 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 authenticate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def authenticate(auth_hash)
# Validate auth data
response = get_auth_response auth_hash
return nil unless response
- 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 render_error
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def render_error(status, code, title, detail, exception = nil)
Method password_score
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def password_score(user)
password = user.password
zxcvbn_weak_words = []
- 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 7 (exceeds 5 allowed). Consider refactoring. Open
def can?(action)
if action.is_a?(Array)
if action.length == 1
single_permission_check action.first
else
- 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 authenticate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def authenticate(access_token)
# Get FB user object
client = ApiGuardian::Helpers::Facebook.new(access_token)
response = client.authorize!
- 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 single_permission_check
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def single_permission_check(action)
perm = load_permission(action).first
fail ApiGuardian::Errors::InvalidPermissionName, "Permission '#{action}' is not valid." unless perm
role_permissions_collection.each do |rp|
- 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_request_type
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate_request_type
top_params = params.fetch(:data)
fail ApiGuardian::Errors::InvalidRequestBody, 'type' unless top_params.fetch(:type, nil)
expected_request_type = resource_name.pluralize.underscore.dasherize.gsub(/\//, '-').sub(/^-/, '')
- 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_request_id
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate_request_id
top_params = params.fetch(:data)
fail ApiGuardian::Errors::InvalidRequestBody, 'id' unless top_params.fetch(:id, nil)
expected_request_id = params[:id]
- 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"