remomueller/contour

View on GitHub

Showing 40 of 40 total issues

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

        if ('autoclose' in options) {
            this.autoclose = options.autoclose;
        } else if ('dateAutoclose' in this.element.data()) {
            this.autoclose = this.element.data('date-autoclose');
        }
Severity: Major
Found in app/assets/javascripts/external/bootstrap-datepicker.js and 3 other locations - About 1 hr to fix
app/assets/javascripts/external/bootstrap-datepicker.js on lines 52..56
app/assets/javascripts/external/bootstrap-datepicker.js on lines 91..95
app/assets/javascripts/external/bootstrap-datepicker.js on lines 113..117

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

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

        if ('calendarWeeks' in options) {
            this.calendarWeeks = options.calendarWeeks;
        } else if ('dateCalendarWeeks' in this.element.data()) {
            this.calendarWeeks = this.element.data('date-calendar-weeks');
        }
Severity: Major
Found in app/assets/javascripts/external/bootstrap-datepicker.js and 3 other locations - About 1 hr to fix
app/assets/javascripts/external/bootstrap-datepicker.js on lines 52..56
app/assets/javascripts/external/bootstrap-datepicker.js on lines 84..88
app/assets/javascripts/external/bootstrap-datepicker.js on lines 91..95

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

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

        if ('forceParse' in options) {
            this.forceParse = options.forceParse;
        } else if ('dateForceParse' in this.element.data()) {
            this.forceParse = this.element.data('date-force-parse');
        }
Severity: Major
Found in app/assets/javascripts/external/bootstrap-datepicker.js and 3 other locations - About 1 hr to fix
app/assets/javascripts/external/bootstrap-datepicker.js on lines 84..88
app/assets/javascripts/external/bootstrap-datepicker.js on lines 91..95
app/assets/javascripts/external/bootstrap-datepicker.js on lines 113..117

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

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

        _attachEvents: function(){
            this._detachEvents();
            if (this.isInput) { // single input
                this._events = [
                    [this.element, {
Severity: Minor
Found in app/assets/javascripts/external/bootstrap-datepicker.js - About 1 hr to fix

    Method sort_field_helper has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def sort_field_helper(order, sort_field, display_name)
        sort_field_order = (order == sort_field) ? "#{sort_field} DESC" : sort_field
        symbol = (order == sort_field) ? '»' : (order == sort_field + ' DESC' ? '«' : '«»')
        selected_class = (order == sort_field) ? 'selected' : (order == sort_field + ' DESC' ? 'selected' : '')
        content_tag(:span, class: selected_class) do
    Severity: Minor
    Found in app/helpers/contour_helper.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

    Function EventTarget has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        var EventTarget = function() {
            var eventSplitter = /\s+/;
            return {
                on: function(events, callback) {
                    var event;
    Severity: Minor
    Found in app/assets/javascripts/external/typeahead.js - About 1 hr to fix

      Function initialize has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  initialize: function(datasetDefs) {
                      var datasets;
                      datasetDefs = utils.isArray(datasetDefs) ? datasetDefs : [ datasetDefs ];
                      if (datasetDefs.length === 0) {
                          $.error("no datasets provided");
      Severity: Minor
      Found in app/assets/javascripts/external/typeahead.js - About 1 hr to fix

        Function _loadPrefetchData has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    _loadPrefetchData: function(o) {
                        var that = this, thumbprint = VERSION + (o.thumbprint || ""), storedThumbprint, storedProtocol, storedItemHash, storedAdjacencyList, isExpired, deferred;
                        if (this.storage) {
                            storedThumbprint = this.storage.get(keys.thumbprint);
                            storedProtocol = this.storage.get(keys.protocol);
        Severity: Minor
        Found in app/assets/javascripts/external/typeahead.js - About 1 hr to fix

          Function _getLocalSuggestions has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                      _getLocalSuggestions: function(terms) {
                          var that = this, firstChars = [], lists = [], shortestList, suggestions = [];
                          utils.each(terms, function(i, term) {
                              var firstChar = term.charAt(0);
                              !~utils.indexOf(firstChars, firstChar) && firstChars.push(firstChar);
          Severity: Minor
          Found in app/assets/javascripts/external/typeahead.js - About 1 hr to fix

            Function updateNavArrows has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    updateNavArrows: function() {
                        var d = new Date(this.viewDate),
                            year = d.getUTCFullYear(),
                            month = d.getUTCMonth();
                        switch (this.viewMode) {
            Severity: Minor
            Found in app/assets/javascripts/external/bootstrap-datepicker.js - About 1 hr to fix

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

                      function buildDomStructure(input) {
                          var $wrapper = $(html.wrapper), $dropdown = $(html.dropdown), $input = $(input), $hint = $(html.hint);
                          $wrapper = $wrapper.css(css.wrapper);
                          $dropdown = $dropdown.css(css.dropdown);
                          $hint.css(css.hint).css({
              Severity: Minor
              Found in app/assets/javascripts/external/typeahead.js - About 1 hr to fix

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

                        moveMonth: function(date, dir){
                            if (!dir) return date;
                            var new_date = new Date(date.valueOf()),
                                day = new_date.getUTCDate(),
                                month = new_date.getUTCMonth(),
                Severity: Minor
                Found in app/assets/javascripts/external/bootstrap-datepicker.js - About 1 hr to fix

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

                                      [this.element, {
                                          focus: $.proxy(this.show, this),
                                          keyup: $.proxy(this.update, this),
                                          keydown: $.proxy(this.keydown, this)
                                      }]
                  Severity: Major
                  Found in app/assets/javascripts/external/bootstrap-datepicker.js and 1 other location - About 1 hr to fix
                  app/assets/javascripts/external/bootstrap-datepicker.js on lines 160..164

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

                  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

                                      [this.element.find('input'), {
                                          focus: $.proxy(this.show, this),
                                          keyup: $.proxy(this.update, this),
                                          keydown: $.proxy(this.keydown, this)
                                      }],
                  Severity: Major
                  Found in app/assets/javascripts/external/bootstrap-datepicker.js and 1 other location - About 1 hr to fix
                  app/assets/javascripts/external/bootstrap-datepicker.js on lines 150..154

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

                  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 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def create
                      if signed_in?
                        # TODO: Should use "Resource" and not "User"
                        params[:user][:password] = params[:user][:password_confirmation] = Digest::SHA1.hexdigest(Time.now.usec.to_s)[0..19] if params[:user][:password].blank? and params[:user][:password_confirmation].blank?
                  
                  
                  Severity: Minor
                  Found in app/controllers/contour/registrations_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

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

                              if (this.isInput) {
                                  element = this.element;
                              } else if (this.component){
                                  element = this.element.find('input');
                              }
                  Severity: Minor
                  Found in app/assets/javascripts/external/bootstrap-datepicker.js and 1 other location - About 55 mins to fix
                  app/assets/javascripts/external/bootstrap-datepicker.js on lines 739..743

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

                  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

                                  if (this.isInput) {
                                      element = this.element;
                                  } else if (this.component){
                                      element = this.element.find('input');
                                  }
                  Severity: Minor
                  Found in app/assets/javascripts/external/bootstrap-datepicker.js and 1 other location - About 55 mins to fix
                  app/assets/javascripts/external/bootstrap-datepicker.js on lines 597..601

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

                  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

                  Avoid deeply nested control flow statements.
                  Open

                                                  if (month === 0) {
                                                      month = 11;
                                                      year -= 1;
                                                  } else {
                                                      month -= 1;
                  Severity: Major
                  Found in app/assets/javascripts/external/bootstrap-datepicker.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                } else if (target.is('.new')) {
                                                    if (month == 11) {
                                                        month = 0;
                                                        year += 1;
                                                    } else {
                    Severity: Major
                    Found in app/assets/javascripts/external/bootstrap-datepicker.js - About 45 mins to fix

                      Method create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def create
                          self.resource = warden.authenticate!(auth_options)
                          set_flash_message(:notice, :signed_in) if is_flashing_format?
                          sign_in(resource_name, resource)
                          yield resource if block_given?
                      Severity: Minor
                      Found in app/controllers/contour/sessions_controller.rb - About 25 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