Showing 3 of 5 total issues
Method export
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def export
delegate_job(BookmarkingCoursesJob, current_user, params[:password]) do
alert = []
alert << '非學生帳號' unless current_user.student?
alert << '追蹤清單是空的' if current_user.favorite_courses.empty?
- 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 import
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def import
delegate_job(ImportClassScheduleJob, current_user, params[:password]) do
alert = []
alert << '非學生帳號' unless current_user.student?
alert << '密碼空白' if params[:password].blank?
- 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 vote_status
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def vote_status(object, btn_type)
return '' if @votes.nil? || @votes == []
found = @votes.find do |vote|
vote[:votable_type] == object.class.name && vote[:votable_id] == object.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"