Assignment Branch Condition size for update is too high. [42.07/15] Open
def update
@course = Course.find(params[:id])
if params[:course][:directory_path] && @course.directory_path != params[:course][:directory_path]
begin
FileHelper.delete_directory(@course)
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for add_ta is too high. [35.75/15] Open
def add_ta
@course = Course.find(params[:course_id])
@user = User.find_by(name: params[:user][:name])
if @user.nil?
flash.now[:error] = "The user inputted \"" + params[:user][:name] + "\" does not exist."
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for create is too high. [28.18/15] Open
def create
@course = Course.new
@course.name = params[:course][:name]
@course.institutions_id = params[:course][:institutions_id]
@course.directory_path = params[:course][:directory_path]
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for copy is too high. [25.08/15] Open
def copy
orig_course = Course.find(params[:id])
new_course = orig_course.dup
new_course.instructor_id = session[:user].id
new_course.name = 'Copy of ' + orig_course.name
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for remove_ta is too high. [16.79/15] Open
def remove_ta
@ta_mapping = TaMapping.find(params[:id])
@ta = User.find(@ta_mapping.ta_id)
# if the user does not have any other TA mappings, then the role should be changed to student
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method update
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def update
@course = Course.find(params[:id])
if params[:course][:directory_path] && @course.directory_path != params[:course][:directory_path]
begin
FileHelper.delete_directory(@course)
- 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"