Showing 202 of 278 total issues
File submissions_controller.rb
has 304 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'submission_processor'
# Receives submissions and presents the full submission list and submission view.
# Also handles rerun requests.
class SubmissionsController < ApplicationController
Method parse_condition
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def parse_condition(str)
if DateAndTimeUtils.looks_like_date_or_time(str)
time = DateAndTimeUtils.to_time(str)
raise 'Date out of range' if time.year > 10_000 || time.year < 1 # Prevent database datetime overflow
raise "You can't have multiple unlock dates for the same exercise" if @datetime_count > 0 # Multiple unlock dates don't work correctly
- 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 show
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
@submission = Submission.find_by!(id: params[:id])
unless @submission.processed?
authorization_skip!
sandbox_status = :created
Method parse_condition
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_condition(str)
if DateAndTimeUtils.looks_like_date_or_time(str)
time = DateAndTimeUtils.to_time(str)
raise 'Date out of range' if time.year > 10_000 || time.year < 1 # Prevent database datetime overflow
raise "You can't have multiple unlock dates for the same exercise" if @datetime_count > 0 # Multiple unlock dates don't work correctly
File user.rb
has 289 lines of code (exceeds 250 allowed). Consider refactoring. Open
class User < ApplicationRecord
include Comparable
include Gravtastic
include Swagger::Blocks
gravtastic
Method show
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
@course ||= @submission.course
@exercise ||= @submission.exercise
@organization = @course.organization
Method respond_with_error
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def respond_with_error(msg, code = 500, exception = nil, extra_json_keys = {})
respond_to do |format|
format.html do
render 'shared/respond_with_error',
locals: { message: ERB::Util.html_escape(msg), exception: exception },
- 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 submission_review_column
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def submission_review_column(submission)
if submission.reviewed?
if can? :create_review, submission.course
link_to 'Available', new_submission_review_path(submission)
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 refresh
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def self.refresh(course_template_refresh_task)
course_template = course_template_refresh_task.course_template
command = "#{self.langs_executable_path}/current refresh-course"\
" --cache-path #{course_template.cache_path}"\
" --cache-root #{Course.cache_root}"\
- 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 visible_to?
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def visible_to?(user, ignore_email_verification = false)
if user.administrator?
true
elsif !ignore_email_verification && !user.email_verified?
false
- 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_available_points
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def update_available_points
@rust_data['exercises'].each do |exercise|
added = []
removed = []
- 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 create
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
unauthorize_guest!
@exercise = Exercise.find(params[:exercise_id])
authorize! :read, @exercise
Method index
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
if params[:course_id]
@course = Course.find(params[:course_id])
@parent = @course
@numeric_stats = @course.exercises.where(hidden: false).sort.map do |ex|
Class ApplicationController
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class ApplicationController < ActionController::Base
include BreadCrumbs
helper :all
Method show
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
authorization_skip!
organization = Organization.find_by!(slug: params[:organization_slug])
course = organization.courses.find_by(name: "#{params[:organization_slug]}-#{params[:course_name]}")
course = organization.courses.find_by!(name: params[:course_name]) unless course
Method create
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
if !params[:submission] || !params[:submission][:file]
return respond_not_found('No ZIP file selected or failed to receive it')
end
Class CoursesController
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class CoursesController < ApplicationController
before_action :set_organization
before_action :set_course, except: %i[help index show_json]
skip_authorization_check only: [:index]
Method update_course_points
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_course_points(task)
finished_successfully = false
course = Course.find(task.course_id)
Rails.logger.info("Batch publishing points for course #{course.name} with moocfi id: #{course.moocfi_id}")
if !course.moocfi_id
Method index
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def index
unauthorize_guest!
exercise = Exercise.find(params[:exercise_id])
course = exercise.course
authorize! :read, exercise
- 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 run
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def run
Rails.logger.info('Creating directory vendor/tmc-langs-rust') unless File.directory?('vendor/tmc-langs-rust')
Dir.mkdir('vendor/tmc-langs-rust') unless File.directory?('vendor/tmc-langs-rust')
executable = "vendor/tmc-langs-rust/tmc-langs-cli-x86_64-unknown-linux-gnu-#{@@rust_langs_version}"
- 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"