crowdAI/crowdai

View on GitHub

Showing 178 of 178 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  showSection() {
    this.expandTarget.classList.add('display-none');
    this.collapseTarget.classList.remove('display-none');
    this.sectionTarget.classList.remove('display-none');
  }
app/javascript/stimulus_js/controllers/expanding_section_controller.js on lines 12..16

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 65.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method index has 36 lines of code (exceeds 25 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 1 hr to fix

    Function getInnerText has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      getInnerText: function(node) {
        // gets the text we want to use for sorting for a cell.
        // strips leading and trailing whitespace.
        // this is *not* a generic getInnerText function; it's special to sorttable.
        // for example, you can override the cell text with a customkey attribute.
    Severity: Minor
    Found in app/assets/javascripts/modules/sorttable.js - About 1 hr to fix

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

        def change
          drop_view :leaderboards
          drop_table :team_participants
          remove_column :submissions, :team_id
          drop_table :teams
      Severity: Minor
      Found in doc/technical/archived_migrations/20160502081246_remove_teams.rb - About 1 hr to fix

        Method day has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def day
            submissions = @challenge
              .submissions
              .where(
                  "participant_id = ? and created_at >= ?",
        Severity: Minor
        Found in app/queries/submissions_remaining_query.rb - About 1 hr to fix

          Function dean_addEvent has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          function dean_addEvent(element, type, handler) {
              if (element.addEventListener) {
                  element.addEventListener(type, handler, false);
              } else {
                  // assign each event handler a unique ID
          Severity: Minor
          Found in app/assets/javascripts/modules/sorttable.js - 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 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
                  drop_view :leaderboard
                  create_view :leaderboards,
                  "
                  SELECT * FROM (

              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
                      create_view :leaderboards,
                      "
                      SELECT s.id,
                             s.challenge_id,

                    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 change has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def change
                            drop_view :leaderboards
                            create_view :leaderboard,
                            "
                            SELECT * FROM (

                        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 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

                              Similar blocks of code found in 2 locations. Consider refactoring.
                              Open

                                  create_table :login_activities do |t|
                                    t.string :scope
                                    t.string :strategy
                                    t.string :identity
                                    t.boolean :success
                              doc/technical/archived_migrations/20180126133748_create_login_activities.rb on lines 3..18

                              Duplicated Code

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Tuning

                              This issue has a mass of 50.

                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                              Refactorings

                              Further Reading

                              Similar blocks of code found in 2 locations. Consider refactoring.
                              Open

                                  create_table :login_activities do |t|
                                    t.text :scope
                                    t.text :strategy
                                    t.text :identity
                                    t.boolean :success
                              doc/technical/archived_migrations/20180814070229_create_login_activities.rb on lines 3..18

                              Duplicated Code

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Tuning

                              This issue has a mass of 50.

                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                              Refactorings

                              Further Reading

                              Severity
                              Category
                              Status
                              Source
                              Language