Showing 202 of 278 total issues
Method show
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
if params[:username].present? && params[:session_id].present?
user = User.find_by(login: params[:username])
user ||= User.find_by('lower(email) = ?', params[:username].downcase)
# Allows using oauth2 tokens of the new api for authenticating
Method update_available_points
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_available_points
@rust_data['exercises'].each do |exercise|
added = []
removed = []
Method run
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
return unless @kafka_bridge_url && @kafka_bridge_secret && @service_id
return if @kafka_bridge_url.empty? || @kafka_bridge_secret.empty? || @service_id.empty?
KafkaBatchUpdatePoints.where(realtime: false).each do |task|
finished_successfully = false
Method show
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
course_id = params[:course_id]
user_id = params[:id]
course = Course.where(id: course_id).first || Course.where(name: course_id).first
Method extra_field
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def extra_field(field_value, method_options)
field = field_value.field
return '' if field.options[:hidden]
return raw(field.label) if field.field_type == :html
Method sh!
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def sh!(*args)
options = {
assert_silent: false,
escape: true,
timeout: nil
Method create
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def create
course = Course.find(course_notification_params[:course_id])
authorize! :send_mail_to_participants, course
participants = User.course_students(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"
Further reading
Method maybe_update_password
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def maybe_update_password(user, user_params)
if user_params[:old_password].present? || user_params[:password].present?
if !user.has_password?(user_params[:old_password])
user.errors.add(:old_password, 'incorrect')
elsif user_params[:password] != user_params[:password_repeat]
- 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 index_json_data
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def index_json_data
result = []
@participants.each do |user|
record = { id: user.id, username: user.login, email: user.email }
@extra_fields.each do |field|
- 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 eligible_students
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def eligible_students
unauthorize_guest!
return respond_with_error("This feature is only for MOOC-organization's 2019 programming MOOC") unless params[:course_name] == '2019-ohjelmointi' && params[:organization_slug] == 'mooc'
- 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 check_client_version_api_v8
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def check_client_version_api_v8
if should_check_for_client_version?
begin
check_client_minimum_version(params[:client], params[:client_version])
rescue StandardError
- 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 find_source_files_under
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.find_source_files_under(root_dir)
files = []
total_size = 0
Pathname(root_dir).realpath.find do |file|
Find.prune if file.directory? && should_skip_dir?(file)
- 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 award_points
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def award_points
submission = @review.submission
exercise = submission.exercise
course = exercise.course
raise 'Exercise of submission has been moved or deleted' unless 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 source_file?
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.source_file?(file)
return false unless file.file?
dir = file.parent.to_s
name = file.basename.to_s.downcase
name.end_with?('.java', '.jsp') ||
- 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 a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def show
@exercise = Exercise.find(params[:exercise_id])
@course = @exercise.course
@organization = @course.organization
- 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 can_handle_hidden_fields
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def can_handle_hidden_fields(params)
return false unless params[:client] == 'netbeans_plugin'
splitted = params[:client_version].split('.')
min_version = [1, 2, 5]
min_version.each_with_index do |version_number, i|
- 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 check_api_version
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def check_api_version
if should_check_api_version?
if params[:api_version].blank?
return respond_with_error('Please update the TMC client. No API version received from client.', 404, nil, obsolete_client: true)
elsif params[:api_version].to_s != ApiVersion::API_VERSION.to_s
- 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 maybe_update_password
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def maybe_update_password(user, user_params)
if user_params[:old_password].present? || user_params[:password].present?
if !user.has_password?(user_params[:old_password])
user.errors.add(:old_password, 'incorrect')
elsif user_params[:password] != user_params[:password_repeat]
- 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_user_progress
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def update_user_progress(task)
finished_successfully = false
user = User.find(task.user_id)
course = Course.find(task.course_id)
Rails.logger.info("Publishing progress for user #{user.id} with moocfi id: #{course.moocfi_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"
Further reading
Method hash_file_tree
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.hash_file_tree(root_path)
paths = []
root_path = File.expand_path(root_path)
Find.find(root_path) do |path|
paths << path unless File.directory?(path)
- 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"