crowdAI/crowdai

View on GitHub

Showing 97 of 178 total issues

Method sql has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def sql
    %Q[
      SELECT p.participant_id AS id
        FROM comments c,
             email_preferences p,
Severity: Minor
Found in app/queries/comment_every_email_participants_query.rb - About 1 hr to fix

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

      def change
          drop_view :leaderboards
          create_view :leaderboards,
          "
          SELECT s.id,

      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/leaderboard_policy.rb - About 1 hr to fix

        Method index has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def index
            @current_round_id = current_round_id
            if params[:baselines] == 'on'
              @search = policy_scope(Submission)
                .where(
        Severity: Minor
        Found in app/controllers/submissions_controller.rb - About 55 mins 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 remaining_text has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def remaining_text
            case challenge.status
            when :running, :perpetual
              if remaining_time_in_days > 7
                "#{pluralize(remaining_time_in_days,'day')} left"
        Severity: Minor
        Found in app/concepts/challenge/cells/list_detail.rb - About 45 mins 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 file_type has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def file_type
            if dataset_file.hosting_location == 'External'
              if dataset_file.external_url.present?
                ext = dataset_file.external_url.split('/')[-1].split('.')[-1]
                ext && ext.upcase
        Severity: Minor
        Found in app/concepts/dataset/cells/list_detail.rb - About 45 mins 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

        Function show has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          show: function(){
            if($('#notebook-data').length > 0){
              var notebook_json = $('#notebook-data')[0].outerText;
              var anchor = document.querySelector("#notebook-holder");
        
        
        Severity: Minor
        Found in app/assets/javascripts/controllers/articles_controller.js - About 45 mins 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

        Avoid deeply nested control flow statements.
        Open

                                if (textInputRange.compareEndPoints("EndToEnd", endRange) > -1) {
                                    end = len;
                                } else {
                                    end = -textInputRange.moveEnd("character", -len);
                                    end += normalizedValue.slice(0, end).split("\n").length - 1;
        Severity: Major
        Found in app/assets/javascripts/modules/rangy_inputs.js - About 45 mins to fix

          Method index has a Cognitive Complexity of 8 (exceeds 5 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 45 mins 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 validate_token has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def validate_token(token)
              pref_token = EmailPreferencesToken.where(email_preferences_token: token).first
          
              if pref_token.present?
                if @participant && @participant.id != pref_token.participant.id
          Severity: Minor
          Found in app/services/email_preferences_token_service.rb - About 45 mins 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

          Consider simplifying this complex logical expression.
          Open

              if controller.controller_name == 'registrations' ||
                 (controller.controller_name == 'challenges' && controller.action_name == 'edit') ||
                 (controller.controller_name == 'organizers' && controller.action_name == 'edit') ||
                 (controller.controller_name == 'sessions')
                    return "class='no-margin-top'"
          Severity: Major
          Found in app/helpers/application_helper.rb - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                  if (current_participant.first_name.blank?   ||
                      current_participant.last_name.blank?    ||
                      current_participant.affiliation.blank?  ||
                      current_participant.address.blank?      ||
                      current_participant.city.blank?         ||
            Severity: Major
            Found in app/concepts/participant_clef_task/cell.rb - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                  unless (media_large.present? && media_thumbnail.present? && media_content_type.present?) || (media_large.blank? && media_thumbnail.blank? && media_content_type.blank?)
                    raise MediaFieldsIncomplete
                  end
              Severity: Major
              Found in app/controllers/api/external_graders_controller.rb - About 40 mins to fix

                Method awesome_link has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  def awesome_link(icon_class = nil, link_name = nil, url_options = nil, html_options = nil, &block)
                Severity: Minor
                Found in app/helpers/font_awesome_helper.rb - About 35 mins to fix

                  Method build_body has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    def build_body(participant,digest_type,comments,submissions,topics)
                  Severity: Minor
                  Found in app/mailers/email_digest_mailer.rb - About 35 mins to fix

                    Method footer_class has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def footer_class
                        if controller.controller_name == 'registrations' ||
                           (controller.controller_name == 'challenges' && controller.action_name == 'edit') ||
                           (controller.controller_name == 'organizers' && controller.action_name == 'edit') ||
                           (controller.controller_name == 'sessions')
                    Severity: Minor
                    Found in app/helpers/application_helper.rb - About 35 mins 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 vote_link has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def vote_link(votable)
                        if current_participant
                          vote_id = participant_vote_id(votable) if current_participant
                          if vote_id.nil?
                            upvote_link(votable)
                    Severity: Minor
                    Found in app/helpers/votes_helper.rb - About 35 mins 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 update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def update
                        @email_preference.attributes = email_preference_params
                        if @email_preference.newsletter_change == [false,true]
                          # from off to on
                          MailchimpService.new(@participant.id).subscribe
                    Severity: Minor
                    Found in app/controllers/email_preferences_controller.rb - About 35 mins 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 media_fields_present? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def media_fields_present?
                        media_large = params[:media_large]
                        media_thumbnail = params[:media_thumbnail]
                        media_content_type = params[:media_content_type]
                        unless (media_large.present? && media_thumbnail.present? && media_content_type.present?) || (media_large.blank? && media_thumbnail.blank? && media_content_type.blank?)
                    Severity: Minor
                    Found in app/controllers/api/external_graders_controller.rb - About 35 mins 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

                    Avoid too many return statements within this function.
                    Open

                          return node.text.replace(/^\s+|\s+$/g, '');
                    Severity: Major
                    Found in app/assets/javascripts/modules/sorttable.js - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language