Showing 162 of 163 total issues
Method validate_each
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(record, attr, value)
if value.respond_to?(:each)
value.each do |v|
error = validate_value(v)
record.errors.add(attr, message: error) if error
- 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 update?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def update?
return false unless user
return false if user.has_role?(:banned)
return true if can_administrate?
# admins are allowed to update comments on locked posts
- 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 progress_limit
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def progress_limit
return unless progress
progress_cap = media&.progress_limit
default_cap = [media&.default_progress_limit, 50].compact.max
- 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 auto_query_for
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def auto_query_for(field, value)
value = value.first if value.is_a?(Array) && value&.count == 1
case value
when Range
- 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 aozora_user
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def aozora_user
return unless ao_importable?
return @aozora_user if @aozora_user
return Zorro::DB::User.find(_id: @user.ao_id).first if @user
- 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_each
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(record, attribute, value)
ama = if value.respond_to?(:post)
AMA.for_original_post(value.post).first
elsif value.is_a?(Post)
AMA.for_original_post(value).first
- 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 annotate_with_reason
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def annotate_with_reason(act)
if act['target'].is_a?(Post)
user_id = act['target'].user_id
group_id = act['target'].target_group_id
act['reason'] = 'media'
- 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 fill_defaults
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def fill_defaults(activity)
activity.tap do |act|
act.actor ||= user
act.object ||= library_entry
act.to ||= []
- 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
Avoid too many return
statements within this method. Open
return false if banned_from_group?
Avoid too many return
statements within this method. Open
return true if group && has_group_permission?(:content)
Avoid too many return
statements within this method. Open
return false if user.flags.banned?
Avoid too many return
statements within this method. Open
return false if group.closed? && !member?
Avoid too many return
statements within this method. Open
return :unreleased if start_date&.future?
Avoid too many return
statements within this method. Open
return false if banned_from_group?
Avoid too many return
statements within this method. Open
return false if group.closed? && !member?
Avoid too many return
statements within this method. Open
return false unless /[a-z]{2}(_[a-z]{2})?/.match?(title)
Avoid too many return
statements within this method. Open
return false if group.closed? && !member?
Avoid too many return
statements within this method. Open
return false if banned_from_group?
Avoid too many return
statements within this method. Open
return false if user.has_role?(:banned)
Avoid too many return
statements within this method. Open
return false if group.closed? && !member?