I-de-ya/ideyabox

View on GitHub

Showing 33 of 66 total issues

Method update_model has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def update_model
        inject_into_file "app/models/#{resource_name}.rb", "\n  has_many :#{plural_child_name}, :through => :#{plural_linking_resource_name}\n  has_many :#{plural_linking_resource_name}\n
  # def self.has_not_this_#{child_name}(#{child_name}_id)
  #   h = Hash.new
  #   self.order(#{child_model.constantize.column_names.include?('title') ? '\'title\'' : 'created_at'}).each do |p|
Severity: Minor
Found in lib/generators/ideyabox/many_to_many/many_to_many_generator.rb - About 1 hr to fix

    Method has_not_this has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def has_not_this(model_name, *args)
        options = args.extract_options!
        join_model = options[:through].to_s.singularize.camelize
        self_id_sym = "#{self.to_s.underscore}_id".to_sym
        array_first_el = options[:by] ? options[:by] : :title
    Severity: Minor
    Found in lib/ar_ideyabox.rb - About 1 hr to fix

      Method has_not_this has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def has_not_this(model_name, *args)
          options = args.extract_options!
          join_model = options[:through].to_s.singularize.camelize
          self_id_sym = "#{self.to_s.underscore}_id".to_sym
          array_first_el = options[:by] ? options[:by] : :title
      Severity: Minor
      Found in lib/ar_ideyabox.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

      Avoid deeply nested control flow statements.
      Open

                    if (option.group_array_index != null) {
                      $("#" + this.results_data[option.group_array_index].dom_id).css('display', 'list-item');
                    }
      Severity: Major
      Found in app/assets/javascripts/chosen.jquery.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                      if (parts.length) {
                        for (_j = 0, _len2 = parts.length; _j < _len2; _j++) {
                          part = parts[_j];
                          if (regex.test(part)) {
                            found = true;
        Severity: Major
        Found in app/assets/javascripts/chosen.jquery.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                        if (this.result_highlight && result_id === this.result_highlight.attr('id')) {
                          this.result_clear_highlight();
                        }
          Severity: Major
          Found in app/assets/javascripts/chosen.jquery.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                          if (searchText.length) {
                            startpos = option.html.search(zregex);
                            text = option.html.substr(0, startpos + searchText.length) + '</em>' + option.html.substr(startpos + searchText.length);
                            text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
                          } else {
            Severity: Major
            Found in app/assets/javascripts/chosen.jquery.js - About 45 mins to fix

              Consider simplifying this complex logical expression.
              Open

                          if (parentItem != null && nextItem == null &&
                                  (o.rtl && (this.positionAbs.left + this.helper.outerWidth() > parentItem.offset().left + parentItem.outerWidth()) ||
                                  !o.rtl && (this.positionAbs.left < parentItem.offset().left))) {
                              parentItem.after(this.placeholder[0]);
                              this._clearEmpty(parentItem[0]);
              Severity: Major
              Found in app/assets/javascripts/jquery.mjs.nestedSortable.js - About 40 mins to fix

                Method cropable has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  def cropable(image_name, x,y,w,h)
                Severity: Minor
                Found in app/helpers/admin_helper.rb - About 35 mins to fix

                  Method update_model has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def update_model
                          inject_into_file "app/models/#{resource_name}.rb", "\n  has_many :#{plural_child_name}, :through => :#{plural_linking_resource_name}\n  has_many :#{plural_linking_resource_name}\n
                    # def self.has_not_this_#{child_name}(#{child_name}_id)
                    #   h = Hash.new
                    #   self.order(#{child_model.constantize.column_names.include?('title') ? '\'title\'' : 'created_at'}).each do |p|
                  Severity: Minor
                  Found in lib/generators/ideyabox/many_to_many/many_to_many_generator.rb - About 35 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 too many return statements within this function.
                  Open

                          return colors[jQuery.trim(color).toLowerCase()];
                  Severity: Major
                  Found in app/assets/javascripts/jquery.color.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
                    Severity: Major
                    Found in app/assets/javascripts/jquery.color.js - About 30 mins to fix

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

                        def sortable_columns(column, title = nil)
                          title ||= column.titleize
                          css_class = column == sort_column ? "current #{sort_direction}" : nil
                          direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc"
                          link_to title, {:sort => column, :direction => direction}, {:class => css_class}
                      Severity: Minor
                      Found in app/helpers/admin_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