File external_graders_controller.rb
has 360 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Api::ExternalGradersController < Api::BaseController
before_action :auth_by_api_key, only: [:show, :update]
before_action :auth_by_api_key_and_client_id, only: [:create]
def show #GET
Method create
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create #POST
Rails.logger.info "[api] Api::ExternalGradersController#create"
Rails.logger.info "[api] params: #{params}"
message = nil
status = nil
Method update
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update #PATCH
Rails.logger.info "[api] Api::ExternalGradersController#update"
Rails.logger.info "[api] params: #{params}"
message = nil
status = nil
Method create
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def create #POST
Rails.logger.info "[api] Api::ExternalGradersController#create"
Rails.logger.info "[api] params: #{params}"
message = nil
status = nil
- 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 15 (exceeds 5 allowed). Consider refactoring. Open
def update #PATCH
Rails.logger.info "[api] Api::ExternalGradersController#update"
Rails.logger.info "[api] params: #{params}"
message = nil
status = nil
- 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 grading_params
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def grading_params
case params[:grading_status]
when 'graded'
if params[:grading_message].blank?
grading_message = 'Graded successfully'
Consider simplifying this complex logical expression. Open
unless (media_large.present? && media_thumbnail.present? && media_content_type.present?) || (media_large.blank? && media_thumbnail.blank? && media_content_type.blank?)
raise MediaFieldsIncomplete
end
Method media_fields_present?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def media_fields_present?
media_large = params[:media_large]
media_thumbnail = params[:media_thumbnail]
media_content_type = params[:media_content_type]
unless (media_large.present? && media_thumbnail.present? && media_content_type.present?) || (media_large.blank? && media_thumbnail.blank? && media_content_type.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
Avoid too many return
statements within this method. Open
return false
Method get_challenge_round_id
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_challenge_round_id(challenge:, params:)
if params[:challenge_round_id].present?
round = ChallengeRound.where(
challenge_id: challenge.id,
id: params[:challenge_round_id]).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 grading_params
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def grading_params
case params[:grading_status]
when 'graded'
if params[:grading_message].blank?
grading_message = 'Graded successfully'
- 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"