railstaichung/rails-taichung

View on GitHub

Showing 51 of 177 total issues

Avoid deeply nested control flow statements.
Open

              } else if (target.is('.year')) {
                this.viewDate.setUTCDate(1);
                year = parseInt(target.text(), 10) || 0;
                this.viewDate.setUTCFullYear(year);
                this.element.trigger({
Severity: Major
Found in app/assets/javascripts/bootstrap-datetimepicker.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

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

      Avoid deeply nested control flow statements.
      Open

                      if (oldViewMode == this.viewMode && this.autoclose) {
                        this.hide();
                      }
      Severity: Major
      Found in app/assets/javascripts/bootstrap-datetimepicker.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/bootstrap-datetimepicker.js - About 45 mins to fix

          Consider simplifying this complex logical expression.
          Open

                if (arguments && arguments.length && (typeof arguments[0] === 'string' || arguments[0] instanceof Date)) {
                  date = arguments[0];
                  fromArgs = true;
                } else {
                  date = (this.isInput ? this.element.val() : this.element.find('input').val()) || this.element.data('date') || this.initialDate;
          Severity: Major
          Found in app/assets/javascripts/bootstrap-datetimepicker.js - About 40 mins to fix

            Function animate has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                animate: function(x,y,w,h,cb){
            Severity: Minor
            Found in app/assets/javascripts/Jcrop.js - About 35 mins to fix

              Function parseDate has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  parseDate: function (date, format, language, type, timezone) {
              Severity: Minor
              Found in app/assets/javascripts/bootstrap-datetimepicker.js - About 35 mins to fix

                Function formatDate has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    formatDate:       function (date, format, language, type, timezone) {
                Severity: Minor
                Found in app/assets/javascripts/bootstrap-datetimepicker.js - About 35 mins to fix

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

                    def beef_createtime(created_at)
                      time_gap = Time.now - created_at
                      if time_gap < 1.day.second then
                        diff = time_gap / 1.hour.second
                        time_result = "#{diff.floor} #{I18n.t('resource.hours_ago_submit')},"
                  Severity: Minor
                  Found in app/helpers/beefs_helper.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

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

                    def update
                      @event = current_user.events.find(params[:id])
                      if @event.start_time > @event.end_time
                        flash[:warning] = "時間錯誤"
                        render :edit
                  Severity: Minor
                  Found in app/controllers/events_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

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

                    def event_action(event)
                      if event.active?
                        if !current_user
                          link_to("立刻報名", new_user_session_path, class: "btn btn-primary btn-lg btn-block")
                        else
                  Severity: Minor
                  Found in app/helpers/events_helper.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