codn/adminpanel

View on GitHub

Showing 57 of 139 total issues

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

        , showWidget: function(e) {
            e.stopPropagation();
            e.preventDefault();

            if (this.open) {
Severity: Minor
Found in app/assets/javascripts/adminpanel/bootstrap-timepicker.js - About 1 hr to fix

    Method field_value has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def field_value(attr_type, attribute, object)
          case attr_type
          when 'select'
            belong_to_object_name(object, attribute.gsub('_id', ''))
          when 'checkbox'
    Severity: Minor
    Found in app/helpers/adminpanel/shared_pages_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 dateUpdated has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            dateUpdated: function(e){
                // `this.updating` is a workaround for preventing infinite recursion
                // between `changeDate` triggering and `setUTCDate` calling.  Until
                // there is a better mechanism.
                if (this.updating)
    Severity: Minor
    Found in app/assets/javascripts/adminpanel/bootstrap-datepicker.js - About 1 hr to fix

      Function getElements has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        Dropzone.getElements = function(els, name) {
          var e, el, elements, _i, _j, _len, _len1, _ref;
          if (els instanceof Array) {
            elements = [];
            try {
      Severity: Minor
      Found in app/assets/javascripts/adminpanel/dropzone.js - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

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

          Avoid deeply nested control flow statements.
          Open

                        if (option.selected) {
                          formData.append(inputName, option.value);
                        }
          Severity: Major
          Found in app/assets/javascripts/adminpanel/dropzone.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                                    if (this.viewMode === 1)
                                                        this._trigger('changeYear', this.viewDate);
            Severity: Major
            Found in app/assets/javascripts/adminpanel/bootstrap-datepicker.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                              if (this.o.minViewMode === 2){
                                                  this._setDate(UTCDate(year, month, day));
                                              }
              Severity: Major
              Found in app/assets/javascripts/adminpanel/bootstrap-datepicker.js - About 45 mins to fix

                Method collection_check_boxes has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def collection_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {})
                Severity: Minor
                Found in app/helpers/adminpanel/adminpanel_form_builder.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

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

                    Method adminpanel_form_for has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def adminpanel_form_for(object, *args, &block)
                          options = args.extract_options!
                          options.reverse_merge! builder: Adminpanel::AdminpanelFormBuilder, html: { class: 'form-horizontal' }
                          if @model.has_gallery?
                            options[:html][:"data-parent-object-class"] = @model.to_s
                    Severity: Minor
                    Found in app/helpers/adminpanel/application_helper.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

                    Avoid deeply nested control flow statements.
                    Open

                                                    if (this.o.minViewMode === 1){
                                                        this._setDate(UTCDate(year, month, day));
                                                        this.showMode();
                                                    } else {
                                                        this.showMode(-1);
                    Severity: Major
                    Found in app/assets/javascripts/adminpanel/bootstrap-datepicker.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                  if (hours > 12) {
                                                      hours = hours - 12;
                                                  }
                      Severity: Major
                      Found in app/assets/javascripts/adminpanel/bootstrap-timepicker.js - About 45 mins to fix

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

                            def create
                              merge_params
                              @resource_instance = @model.new(send(whitelisted_params))
                              respond_to do |format|
                                if @resource_instance.save
                        Severity: Minor
                        Found in app/controllers/concerns/adminpanel/rest_actions.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

                        Consider simplifying this complex logical expression.
                        Open

                            if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) {
                              if (!("classList" in document.createElement("a"))) {
                                capableBrowser = false;
                              } else {
                                _ref = Dropzone.blacklistedBrowsers;
                        Severity: Major
                        Found in app/assets/javascripts/adminpanel/dropzone.js - About 40 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              return false;
                          Severity: Major
                          Found in app/assets/javascripts/adminpanel/dropzone.js - About 30 mins to fix

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

                                def create
                                  user = User.find_by_email(params[:session][:email].downcase)
                                  if user && user.authenticate(params[:session][:password])
                                    sign_in user
                                    flash[:success] = I18n.t('authentication.signin_success')
                            Severity: Minor
                            Found in app/controllers/adminpanel/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