crowdAI/crowdai

View on GitHub

Showing 178 of 178 total issues

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

  def mention
    message = "#{@notifiable.participant.name} mentioned you in a post."
    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 35..52

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

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

  def change
    create_table :versions, versions_table_options do |t|
      t.string   :item_type, item_type_options
      t.integer  :item_id,   null: false
      t.string   :event,     null: false
doc/technical/archived_migrations/20170811173059_create_versions.rb on lines 18..41

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

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

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

  def change
    create_table :versions, versions_table_options do |t|
      t.string   :item_type, item_type_options
      t.integer  :item_id,   null: false
      t.string   :event,     null: false
doc/technical/archived_migrations/20160825111253_create_versions.rb on lines 18..41

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

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

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

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

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

      def format_options(participant,challenge_call_response)
        options = {
          participant_id:   participant.id,
          subject:          "[ADMIN:crowdAI] Challenge Call response",
          to:               participant.email,
    app/mailers/admin/organizer_application_notification_mailer.rb on lines 10..30

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

    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

      def format_options(participant,organizer_application)
        options = {
          participant_id:   participant.id,
          subject:          "[ADMIN:crowdAI] Organizer Application Requested",
          to:               participant.email,
    Severity: Minor
    Found in app/mailers/admin/organizer_application_notification_mailer.rb and 1 other location - About 40 mins to fix
    app/mailers/admin/challenge_call_response_notification_mailer.rb on lines 10..30

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

    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

    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

          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

        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

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

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

                def s3_file_obj
                  s3_key = dataset_file.dataset_file_s3_key
                  return nil if s3_key.nil?
                  s3_file_obj = Aws::S3::Object.new(bucket_name: ENV['AWS_S3_BUCKET'], key: s3_key)
                  if s3_file_obj && s3_file_obj.key && !s3_file_obj.key.blank?
              Severity: Minor
              Found in app/concepts/dataset/cells/list_detail.rb and 1 other location - About 35 mins to fix
              app/concepts/task_dataset/cells/list_detail.rb on lines 41..49

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

              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

                def s3_file_obj
                  s3_key = task_dataset_file.dataset_file_s3_key
                  return nil if s3_key.nil?
                  s3_file_obj = Aws::S3::Object.new(bucket_name: ENV['AWS_S3_BUCKET'], key: s3_key)
                  if s3_file_obj && s3_file_obj.key && !s3_file_obj.key.blank?
              Severity: Minor
              Found in app/concepts/task_dataset/cells/list_detail.rb and 1 other location - About 35 mins to fix
              app/concepts/dataset/cells/list_detail.rb on lines 74..82

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

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

              Severity
              Category
              Status
              Source
              Language