crowdAI/crowdai

View on GitHub

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,
Severity: Minor
Found in app/queries/submissions_remaining_query.rb - About 1 hr to fix

    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'
        Severity: Minor
        Found in app/controllers/api/external_graders_controller.rb - About 1 hr to fix

          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,
            Severity: Minor
            Found in doc/technical/archived_migrations/20160405125530_remove_username.rb - About 1 hr to fix

              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 = ?",
              Severity: Minor
              Found in app/queries/submissions_remaining_query.rb - About 1 hr to fix

                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,
                  Severity: Minor
                  Found in app/controllers/submissions_controller.rb - About 1 hr to fix

                    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
                    
                    
                    Severity: Minor
                    Found in doc/technical/archived_migrations/20160601071807_create_visits.rb - About 1 hr to fix

                      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
                      Severity: Minor
                      Found in app/controllers/api/mailchimps_controller.rb - About 1 hr to fix

                      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 = ?",
                      Severity: Minor
                      Found in app/controllers/api/submissions_controller.rb - About 1 hr to fix

                      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'

                      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
                      Severity: Minor
                      Found in app/policies/submission_policy.rb - About 1 hr to fix

                        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",
                        Severity: Minor
                        Found in app/helpers/leaderboard_helper.rb - About 1 hr to fix

                          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,
                          Severity: Minor
                          Found in app/mailers/gdpr_export_mailer.rb - About 1 hr to fix

                            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'
                            Severity: Minor
                            Found in app/helpers/tabs_helper.rb - About 1 hr to fix

                              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'
                              Severity: Minor
                              Found in app/controllers/leaderboards_controller.rb - About 1 hr to fix

                                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
                                Severity: Minor
                                Found in app/queries/comments_digest_query.rb - About 1 hr to fix

                                  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
                                  Severity: Minor
                                  Found in app/policies/ongoing_leaderboard_policy.rb - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language