crowdAI/crowdai

View on GitHub

Showing 178 of 178 total issues

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

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

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

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

                        class Scope
                          attr_reader :participant, :scope
                      
                          def initialize(participant, scope)
                            @participant = participant
                      Severity: Major
                      Found in app/policies/challenge_policy.rb and 1 other location - About 1 hr to fix
                      app/policies/participant_challenge_policy.rb on lines 7..38

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

                      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

                        class Scope
                          attr_reader :participant, :scope
                      
                          def initialize(participant, scope)
                            @participant = participant
                      Severity: Major
                      Found in app/policies/participant_challenge_policy.rb and 1 other location - About 1 hr to fix
                      app/policies/challenge_policy.rb on lines 87..118

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

                      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 4 locations. Consider refactoring.
                      Open

                        def format_options(participant,submission)
                          challenge = submission.challenge
                      
                          options = {
                            participant_id:   participant.id,
                      Severity: Major
                      Found in app/mailers/leaderboard_notification_mailer.rb and 3 other locations - About 55 mins to fix
                      app/mailers/admin/submission_notification_mailer.rb on lines 12..34
                      app/mailers/submission_graded_notification_mailer.rb on lines 12..34
                      app/mailers/topic_notification_mailer.rb on lines 11..33

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

                      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 4 locations. Consider refactoring.
                      Open

                        def format_options(participant,submission)
                          challenge = submission.challenge
                      
                          options = {
                            participant_id:   participant.id,
                      Severity: Major
                      Found in app/mailers/submission_graded_notification_mailer.rb and 3 other locations - About 55 mins to fix
                      app/mailers/admin/submission_notification_mailer.rb on lines 12..34
                      app/mailers/leaderboard_notification_mailer.rb on lines 12..34
                      app/mailers/topic_notification_mailer.rb on lines 11..33

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

                      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 4 locations. Consider refactoring.
                      Open

                        def format_options(participant,submission)
                          challenge = submission.challenge
                      
                          options = {
                            participant_id:   participant.id,
                      Severity: Major
                      Found in app/mailers/admin/submission_notification_mailer.rb and 3 other locations - About 55 mins to fix
                      app/mailers/leaderboard_notification_mailer.rb on lines 12..34
                      app/mailers/submission_graded_notification_mailer.rb on lines 12..34
                      app/mailers/topic_notification_mailer.rb on lines 11..33

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

                      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 4 locations. Consider refactoring.
                      Open

                        def format_options(participant,topic)
                          challenge = topic.challenge
                      
                          options = {
                            participant_id:   participant.id,
                      Severity: Major
                      Found in app/mailers/topic_notification_mailer.rb and 3 other locations - About 55 mins to fix
                      app/mailers/admin/submission_notification_mailer.rb on lines 12..34
                      app/mailers/leaderboard_notification_mailer.rb on lines 12..34
                      app/mailers/submission_graded_notification_mailer.rb on lines 12..34

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

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

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

                        def comment
                          message = "#{@notifiable.participant.name} commented on a discussion thread you are participating in."
                          if @notifiable.participant.image_file.file.present?
                            thumbnail_url = @notifiable.participant.image_file.url
                          else
                      Severity: Major
                      Found in app/services/notification_service.rb and 2 other locations - About 55 mins to fix
                      app/services/notification_service.rb on lines 35..52
                      app/services/notification_service.rb on lines 55..72

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

                      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 3 locations. Consider refactoring.
                      Open

                        def topic
                          message = "#{@notifiable.participant.name} posted a topic in a challenge you are following."
                          if @notifiable.participant.image_file.file.present?
                            thumbnail_url = @notifiable.participant.image_file.url
                          else
                      Severity: Major
                      Found in app/services/notification_service.rb and 2 other locations - About 55 mins to fix
                      app/services/notification_service.rb on lines 15..32
                      app/services/notification_service.rb on lines 55..72

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

                      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