Showing 16 of 20 total issues
Method new
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def new
if StudentApplication.remaining.count <= @settings.applicants_remaining
if StudentApplication.remaining.count <= StudentApplication.needs_comparison.count + 1
return redirect_to admin_remaining_path, flash: { success: t('admins.comparisons.complete') }
- 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 new
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
def new
if StudentApplication.remaining.count <= @settings.applicants_remaining
if StudentApplication.remaining.count <= StudentApplication.needs_comparison.count + 1
return redirect_to admin_remaining_path, flash: { success: t('admins.comparisons.complete') }
Function simulate_and_compute_params
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def simulate_and_compute_params(bonus=2, penalty=2, threshold=-7, apps_total=250, apps_cutoff=50, runs=10):
class AppMeta:
def __init__(self, rank, wins, losses):
self.rank = rank
self.wins = wins
- 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 a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def create
response_params = student_application_params[:responses]
applicant = Applicant.find_or_create_by(email: response_params[:email])
if verify_unique_semester_application applicant
# Start with a fresh student app object
- 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
Function getAddressComponents
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function getAddressComponents(place) {
// If you want lat/lng, you can look at:
// - place.geometry.location.lat()
// - place.geometry.location.lng()
- 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
Function getAddressComponents
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getAddressComponents(place) {
// If you want lat/lng, you can look at:
// - place.geometry.location.lat()
// - place.geometry.location.lng()
Method create
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create
last_comp_by_user = Comparison.order(:created_at).where(admin: current_admin).last
if last_comp_by_user && (Time.now - last_comp_by_user.created_at).to_i < 15.seconds
redirect_to root_path, flash: {
error: "You can't create comparisons that quickly. Please read applications carefully."
- 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 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
response_params = student_application_params[:responses]
applicant = Applicant.find_or_create_by(email: response_params[:email])
if verify_unique_semester_application applicant
# Start with a fresh student app object
Function simulate_and_compute_params
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def simulate_and_compute_params(bonus=2, penalty=2, threshold=-7, apps_total=250, apps_cutoff=50, runs=10):
Method validate_short_text
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate_short_text(errors)
q = self.question
if q.input_type == "email"
unless self.answer =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
errors.add("'#{self.answer}'", "is not a valid email")
- 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 response_to
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def response_to(tag)
response = self.responses.includes(:question).select { |r| r.question.tag == tag }.first
return nil if response.nil?
if response.question.question_type == "checkbox"
return true if response.answer == "yes"
- 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 validate_attachment
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate_attachment(errors)
q = self.question
if self.file_file_size # check if file exists, can't use file to check this because of default file
if self.file_file_size > (q.file_size_limit * 1000000) && q.file_size_limit > 0
errors.add(q.title, "is too large, limit is #{q.file_size_limit} Megabytes")
- 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 redirect_to root_path, flash: { error: t('admins.comparisons.insufficient')}
Avoid too many return
statements within this method. Open
return
Method right_col_html
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def right_col_html(attribute)
h.content_tag :div, class: "row-right" do
val = send(attribute.is_a?(Array) ? attribute[0] : attribute)
if !!val == val
val = yesno(val)
- 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 action_toggle_published_link
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def action_toggle_published_link
link_to toggle_publish_admin_project_path(object),
method: :post,
class: 'icon hint--top',
id: dom_id(object, :toggle_publish),
- 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"