Showing 97 of 178 total issues
Method week
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def week
submissions = @challenge
.submissions
.where(
"participant_id = ? and created_at >= ?", @participant_id,
Method change
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change
create_view :leaderboards,
"
SELECT s.id,
s.challenge_id,
Method change
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change
create_table(:users) do |t|
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
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'
Method change
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change
drop_view :leaderboard
create_view :leaderboards,
"
SELECT * FROM (
Method change
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change
drop_view :leaderboards;
create_view :leaderboards, "
SELECT s.id,
s.competition_id,
Method round
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def round
submissions = @challenge
.submissions
.where(
"post_challenge IS FALSE and participant_id = ? and challenge_round_id = ?",
Method change
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change
drop_view :leaderboards
create_view :leaderboard,
"
SELECT * FROM (
Method submission_params
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def submission_params
params
.require(:submission)
.permit(
:challenge_id,
Method change
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change
create_table :visits do |t|
t.string :visit_token
t.string :visitor_token
Method webhook
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def webhook
if params[:api_key] == ENV['MAILCHIMP_INBOUND_API_KEY']
if params['type'] == 'unsubscribe' && params['data']['list_id'] == ENV['MAILCHIMP_LIST_ID']
participant = Participant.where(email: params['data']['email']).first
if participant
- 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 set_submissions
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def set_submissions(challenge_id, grading_status, after, challenge_round_id)
if grading_status.blank? && after.blank? && challenge_round_id.blank?
@submissions = Submission.where(challenge_id: challenge_id)
elsif grading_status.blank? && after.blank? && challenge_round_id.present?
@submissions = Submission.where("challenge_id = ? AND challenge_round_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 change
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def change
add_column :submissions, :grading_status_cd, :string, default: 'ready'
Submission.find_each do |submission|
if submission.score.blank? && submission.grading_message.blank?
submission.grading_status = 'ready'
- 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 participant_sql
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def participant_sql(participant)
if participant.present?
participant_id = participant.id
email = participant.email
else
Method ranking_change_helper
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def ranking_change_helper(entry)
if entry.previous_row_num == 0 || entry.previous_row_num == entry.row_num
output = "<td class='change'>" +
image_tag(
"icon-change-none.csv",
Method format_options
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def format_options(participant:,body:,csv_file:)
options = {
participant_id: participant.id,
subject: "[crowdAI] Personal Data download",
to: participant.email,
Method current_tab
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def current_tab
case controller.controller_name
when 'challenges'
'overview'
when 'leaderboards'
Method index
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
@current_round = current_round
if @challenge.completed?
if params[:post_challenge] == 'on'
@post_challenge = 'on'
Method sql
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def sql
%Q[
SELECT c.id AS id
FROM comments c,
email_preferences p
Method participant_sql
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def participant_sql(participant)
if participant.present?
participant_id = participant.id
email = participant.email
else