crowdAI/crowdai

View on GitHub

Showing 178 of 178 total issues

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

  sort_ddmm: function(a,b) {
    mtch = a[0].match(sorttable.DATE_RE);
    y = mtch[3]; m = mtch[2]; d = mtch[1];
    if (m.length == 1) m = '0'+m;
    if (d.length == 1) d = '0'+d;
Severity: Major
Found in app/assets/javascripts/modules/sorttable.js and 1 other location - About 1 day to fix
app/assets/javascripts/modules/sorttable.js on lines 288..302

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

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

  sort_mmdd: function(a,b) {
    mtch = a[0].match(sorttable.DATE_RE);
    y = mtch[3]; d = mtch[2]; m = mtch[1];
    if (m.length == 1) m = '0'+m;
    if (d.length == 1) d = '0'+d;
Severity: Major
Found in app/assets/javascripts/modules/sorttable.js and 1 other location - About 1 day to fix
app/assets/javascripts/modules/sorttable.js on lines 273..287

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

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

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

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

    $(document).on('turbolinks:load', function() {
      $('.url').blur(function() {
        var self = this;
        $(self).val($(self).val().toLowerCase());
        var url = $(self).val();
app/assets/javascripts/pages/participants_edit.js on lines 1..10

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

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

$(document).on('turbolinks:load', function() {
  $('.url').blur(function() {
    var self = this;
    $(self).val($(self).val().toLowerCase());
    var url = $(self).val();
Severity: Major
Found in app/assets/javascripts/pages/participants_edit.js and 1 other location - About 6 hrs to fix
app/assets/javascripts/controllers/participants_controller.js on lines 3..12

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

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

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

            $('#email_preference_receive_daily_digest').change(function(){
              var self = this;
              if($(self).is(":checked")){
                $(self).prop('disabled',true);
                $('#email_preference_receive_every_email').prop('disabled',false);
        app/assets/javascripts/controllers/email_preferences_controller.js on lines 49..58

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

        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

            $('#email_preference_receive_weekly_digest').change(function(){
              var self = this;
              if($(self).is(":checked")){
                $(self).prop('disabled',true);
                $('#email_preference_receive_every_email').prop('disabled',false);
        app/assets/javascripts/controllers/email_preferences_controller.js on lines 38..47

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

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

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

                    if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) {
                      // if we're already sorted by this column in reverse, just
                      // re-reverse the table, which is quicker
                      sorttable.reverse(this.sorttable_tbody);
                      this.className = this.className.replace('sorttable_sorted_reverse',
          Severity: Major
          Found in app/assets/javascripts/modules/sorttable.js and 1 other location - About 4 hrs to fix
          app/assets/javascripts/modules/sorttable.js on lines 94..106

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

          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

                    if (this.className.search(/\bsorttable_sorted\b/) != -1) {
                      // if we're already sorted by this column, just
                      // reverse the table, which is quicker
                      sorttable.reverse(this.sorttable_tbody);
                      this.className = this.className.replace('sorttable_sorted',
          Severity: Major
          Found in app/assets/javascripts/modules/sorttable.js and 1 other location - About 4 hrs to fix
          app/assets/javascripts/modules/sorttable.js on lines 107..119

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

          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

          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

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

              $('#email_preference_receive_weekly_digest').change(function(){
                var self = this;
                if($(self).is(":checked")){
                  $('#email_preference_receive_every_email').prop('disabled',false);
                  $('#email_preference_receive_daily_digest').attr('checked',false);
            Severity: Major
            Found in app/assets/javascripts/pages/email_preferences_edit.js and 2 other locations - About 3 hrs to fix
            app/assets/javascripts/pages/email_preferences_edit.js on lines 2..10
            app/assets/javascripts/pages/email_preferences_edit.js on lines 12..20

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

            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

              $('#email_preference_receive_every_email').change(function(){
                var self = this;
                if($(self).is(":checked")){
                  $('#email_preference_receive_daily_digest').prop('disabled',false);
                  $('#email_preference_receive_weekly_digest').prop('disabled',false);
            Severity: Major
            Found in app/assets/javascripts/pages/email_preferences_edit.js and 2 other locations - About 3 hrs to fix
            app/assets/javascripts/pages/email_preferences_edit.js on lines 12..20
            app/assets/javascripts/pages/email_preferences_edit.js on lines 22..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 110.

            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

              $('#email_preference_receive_daily_digest').change(function(){
                var self = this;
                if($(self).is(":checked")){
                  $('#email_preference_receive_every_email').prop('disabled',false);
                  $('#email_preference_receive_weekly_digest').prop('disabled',false);
            Severity: Major
            Found in app/assets/javascripts/pages/email_preferences_edit.js and 2 other locations - About 3 hrs to fix
            app/assets/javascripts/pages/email_preferences_edit.js on lines 2..10
            app/assets/javascripts/pages/email_preferences_edit.js on lines 22..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 110.

            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

            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/20160601063448_ren_vw.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
                  Severity
                  Category
                  Status
                  Source
                  Language