volontariat/voluntary

View on GitHub
app/assets/javascripts/voluntary/lib/jquery-competitive_list.js

Summary

Maintainability
F
4 days
Test Coverage

File jquery-competitive_list.js has 494 lines of code (exceeds 250 allowed). Consider refactoring.
Open

(function() {
  (function($, window) {
    var CompetitiveList;
    CompetitiveList = CompetitiveList = (function() {
      CompetitiveList.prototype.jqueryInstanceMethodName = 'competitiveList';
Severity: Minor
Found in app/assets/javascripts/voluntary/lib/jquery-competitive_list.js - About 7 hrs to fix

    Function nextMatch has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          CompetitiveList.prototype.nextMatch = function(from_start) {
            var autoWinnerMatchesHtml, competitorStrings, html, i, modalBodyHtml, modalFooterHtml, modalTitle, radioButtons, rows;
            autoWinnerMatchesHtml = '';
            if (this.currentAutoWinnerMatches.length > 0) {
              this.currentMatch = this.matches[this.currentMatchIndex];
    Severity: Major
    Found in app/assets/javascripts/voluntary/lib/jquery-competitive_list.js - About 2 hrs to fix

      Function moveCompetitorToPosition has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            CompetitiveList.prototype.moveCompetitorToPosition = function(competitorId, position, after_update_request_proc) {
              var defeatedCompetitor, outmatchedCompetitor, positionOfdefeatedCompetitor, positions;
              if (after_update_request_proc == null) {
                after_update_request_proc = null;
              }
      Severity: Major
      Found in app/assets/javascripts/voluntary/lib/jquery-competitive_list.js - About 2 hrs to fix

        Function letWinnerWinMatchesAgainstCompetitorsWhichLoseAgainstLoser has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              CompetitiveList.prototype.letWinnerWinMatchesAgainstCompetitorsWhichLoseAgainstLoser = function(winnerId, loserId) {
                var base;
                (base = this.defeatedCompetitorsByCompetitor)[loserId] || (base[loserId] = []);
                return $.each(this.matches, (function(_this) {
                  return function(index, match) {
        Severity: Minor
        Found in app/assets/javascripts/voluntary/lib/jquery-competitive_list.js - About 1 hr to fix

          Function sortByMostWins has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                CompetitiveList.prototype.sortByMostWins = function(after_update_request_proc) {
                  var $wrapper, data, positions, winsByCompetitor;
                  if (after_update_request_proc == null) {
                    after_update_request_proc = null;
                  }
          Severity: Minor
          Found in app/assets/javascripts/voluntary/lib/jquery-competitive_list.js - About 1 hr to fix

            Function letOutMatchedCompetitorsOfWinnerWinAgainstLoser has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  CompetitiveList.prototype.letOutMatchedCompetitorsOfWinnerWinAgainstLoser = function(winnerId, loserId) {
                    var base;
                    (base = this.outmatchedCompetitorsByCompetitor)[winnerId] || (base[winnerId] = []);
                    return $.each(this.outmatchedCompetitorsByCompetitor[winnerId], (function(_this) {
                      return function(index, competitorId) {
            Severity: Minor
            Found in app/assets/javascripts/voluntary/lib/jquery-competitive_list.js - About 1 hr to fix

              Function init has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    CompetitiveList.prototype.init = function(el, options) {
                      this.options = $.extend({}, this.defaults, options);
                      this.$el = $(el);
                      this.id = this.$el.attr('id');
                      $.data(el, this.constructor.prototype.jqueryInstanceMethodName, this);
              Severity: Minor
              Found in app/assets/javascripts/voluntary/lib/jquery-competitive_list.js - About 1 hr to fix

                Function start has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      CompetitiveList.prototype.start = function() {
                        var matchesAlreadyExist, matchesWithoutWinner;
                        matchesAlreadyExist = false;
                        this.matches || (this.matches = []);
                        if (this.matches.length > 0) {
                Severity: Minor
                Found in app/assets/javascripts/voluntary/lib/jquery-competitive_list.js - About 1 hr to fix

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

                              if (winnerId === _this.currentMatch['winner'] && loserId === _this.otherCompetitorOfMatch(_this.currentMatch, _this.currentMatch['winner'])) {
                                _this.matches[index]['auto_winner_recursion'] = false;
                                _this.matches[index]['auto_winner_reason'] = 'loser has been defeated because he loses against the loser <sup>[1]</sup> of last match';
                              } else {
                                _this.matches[index]['auto_winner_recursion'] = true;
                  app/assets/javascripts/voluntary/lib/jquery-competitive_list.js on lines 370..376

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

                  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 (winnerId === _this.currentMatch['winner'] && loserId === _this.otherCompetitorOfMatch(_this.currentMatch, _this.currentMatch['winner'])) {
                                    _this.matches[index]['auto_winner_recursion'] = false;
                                    _this.matches[index]['auto_winner_reason'] = "loser of last match has been defeated by outmatched competitor of<br/>winner <sup>[1]</sup>";
                                  } else {
                                    _this.matches[index]['auto_winner_recursion'] = true;
                  app/assets/javascripts/voluntary/lib/jquery-competitive_list.js on lines 328..334

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

                  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 (match['winner'] !== void 0) {
                                _this.removeCompetitorsComparisonResult(winnerId, otherLoserId);
                                if (!(_this.movingCompetitorToPosition === true || match['auto_winner'] === true)) {
                                  manual_winner_changed = true;
                                }
                  app/assets/javascripts/voluntary/lib/jquery-competitive_list.js on lines 356..361

                  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

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

                                  if (match['winner'] !== void 0) {
                                    _this.removeCompetitorsComparisonResult(competitorId, loserId);
                                    if (!(_this.movingCompetitorToPosition === true || match['auto_winner'] === true)) {
                                      manual_winner_changed = true;
                                    }
                  app/assets/javascripts/voluntary/lib/jquery-competitive_list.js on lines 314..319

                  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

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

                          $(document.body).on('click', '#bootstrap_modal .cancel_tournament_button', (function(_this) {
                            return function(event) {
                              event.preventDefault();
                              return _this.cancelTournament();
                            };
                  app/assets/javascripts/voluntary/lib/jquery-competitive_list.js on lines 61..66

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

                  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

                          return $(document.body).on('click', '#bootstrap_modal .select_winner_button', (function(_this) {
                            return function(event) {
                              event.preventDefault();
                              return _this.appointWinnerOfMatchByInput();
                            };
                  app/assets/javascripts/voluntary/lib/jquery-competitive_list.js on lines 55..60

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

                  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

                  There are no issues that match your filters.

                  Category
                  Status