crowdAI/crowdai

View on GitHub

Showing 97 of 178 total issues

Function makeSortable has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

  makeSortable: function(table) {
    if (table.getElementsByTagName('thead').length == 0) {
      // table doesn't have a tHead. Since it should have, create one and
      // put the first table row in it.
      the = document.createElement('thead');
Severity: Minor
Found in app/assets/javascripts/modules/sorttable.js - About 1 day 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 117 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def change
    execute "drop view participant_challenges;"
    add_column :challenges, :description_markdownx, :text, after: :end_time
    add_column :challenges, :descriptionx, :text, after: :description_markdownx
    add_column :challenges, :evaluation_markdownx, :text, after: :descriptionx
Severity: Major
Found in doc/technical/archived_migrations/20170515114626_reordercols3.rb - About 4 hrs to fix

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

      Method challenge_params has 115 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def challenge_params
          params
            .require(:challenge)
            .permit(
              :id,
      Severity: Major
      Found in app/controllers/challenges_controller.rb - About 4 hrs to fix

        Method create_leaderboard has 108 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def create_leaderboard(leaderboard_type:)
            post_challenge, cuttoff_dttm = leaderboard_params(leaderboard_type: leaderboard_type)
        
            sql = %Q[
              INSERT INTO base_leaderboards (
        Severity: Major
        Found in app/services/calculate_leaderboard_service.rb - About 4 hrs to fix

          File sorttable.js has 338 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /*
            SortTable
            version 2
            7th April 2007
            Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/
          Severity: Minor
          Found in app/assets/javascripts/modules/sorttable.js - About 4 hrs to fix

            File calculate_leaderboard_service.rb has 322 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            class CalculateLeaderboardService
            
              def initialize(challenge_round_id:)
                @round = ChallengeRound.find(challenge_round_id)
                @order_by = get_order_by
            Severity: Minor
            Found in app/services/calculate_leaderboard_service.rb - About 3 hrs to fix

              Method change has 93 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def change
                execute "drop rule update_challenge_views on challenge_views;"
                drop_view :challenge_views
              
                create_view :challenge_views, "
              Severity: Major
              Found in doc/technical/archived_migrations/20160601063815_mm.rb - About 3 hrs to fix

                Method change has 93 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def change
                    execute "drop rule update_challenge_views on challenge_views;"
                    drop_view :challenge_views
                
                    create_view :challenge_views, "
                Severity: Major
                Found in doc/technical/archived_migrations/20160601063448_ren_vw.rb - About 3 hrs to fix

                  Method change has 92 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def change
                      execute "update submissions set score = 0, score_secondary = 0 where challenge_id = 12;"
                    execute "update submissions set score = 30.1795168296, score_secondary = 32.6215108021 where id = 3530;"
                  execute "update submissions set score = 29.7315225146, score_secondary = 32.2190151623 where id = 3532;"
                  execute "update submissions set score = 28.9940347595, score_secondary = 31.520271205 where id = 3535;"
                  Severity: Major
                  Found in doc/technical/archived_migrations/20180112152241_regrade_take3.rb - About 3 hrs to fix

                    Method change has 91 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def change
                        create_view :challenge_views, "
                        SELECT
                        c.id,
                        c.organizer_id,
                    Severity: Major
                    Found in doc/technical/archived_migrations/20160601050459_challenge_view.rb - About 3 hrs to fix

                      Function makeSortable has 89 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        makeSortable: function(table) {
                          if (table.getElementsByTagName('thead').length == 0) {
                            // table doesn't have a tHead. Since it should have, create one and
                            // put the first table row in it.
                            the = document.createElement('thead');
                      Severity: Major
                      Found in app/assets/javascripts/modules/sorttable.js - About 3 hrs to fix

                        Method change has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def change
                            drop_view :leaderboards
                            create_view :leaderboards,
                            "
                            SELECT l.row_num,

                          Method change has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def change
                              execute "update submissions set score = 0, score_secondary = 0 where challenge_id = 12;"
                              execute "update submissions set score = 28.5914468, score_secondary = 31.01892051 where id = 3530;"
                          execute "update submissions set score = 28.17302633, score_secondary = 30.62651468 where id = 3532;"
                          execute "update submissions set score = 27.08935975, score_secondary = 29.55906082 where id = 3535;"

                            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
                            Severity: Major
                            Found in app/controllers/api/external_graders_controller.rb - About 2 hrs to fix

                              Method insert_baseline_rows has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def insert_baseline_rows(leaderboard_type:)
                                  post_challenge, cuttoff_dttm = leaderboard_params(leaderboard_type: leaderboard_type)
                                  sql = %Q[
                                    INSERT INTO base_leaderboards (
                                      id,
                              Severity: Major
                              Found in app/services/calculate_leaderboard_service.rb - About 2 hrs to fix

                                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
                                Severity: Major
                                Found in app/controllers/api/external_graders_controller.rb - About 2 hrs to fix

                                  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
                                  Severity: Minor
                                  Found in app/controllers/api/external_graders_controller.rb - About 2 hrs 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 56 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    def change
                                      drop_view :participant_challenges
                                      create_view :participant_challenges, "
                                      SELECT p.id,
                                             pc.challenge_id,    -- fk to challenges
                                  Severity: Major
                                  Found in doc/technical/archived_migrations/20160609145519_fix_view_bug.rb - About 2 hrs to fix

                                    Method change has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      def change
                                        drop_view :participant_challenges
                                        create_view :participant_challenges, "
                                        SELECT p.id,
                                               pc.challenge_id,    -- fk to challenges
                                    Severity: Major
                                    Found in doc/technical/archived_migrations/20160609134105_refactor_views2.rb - About 2 hrs to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language