activescaffold/active_scaffold

View on GitHub

Showing 296 of 296 total issues

Method params_for has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

      def params_for(options = {})
        unless @params_for
          @params_for = {}
          params.except(*BLACKLIST_PARAMS).each do |key, value|
            @params_for[key.to_sym] = copy_param(value)
Severity: Minor
Found in lib/active_scaffold/helpers/controller_helpers.rb - About 2 hrs 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 condition_for_search_ui has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

      def condition_for_search_ui(column, value, like_pattern, search_ui)
        case search_ui
        when :boolean, :checkbox
          if value == 'null'
            condition_for_null_type(column, value)
Severity: Minor
Found in lib/active_scaffold/finder.rb - About 2 hrs 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 update_column has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      update_column: function(element, url, send_form, source_id, val, additional_params) {
        if (!element) element = jQuery('#' + source_id);
        var as_form = element.closest('form.as_form');
        var params = null;

Severity: Major
Found in app/assets/javascripts/jquery/active_scaffold.js - About 2 hrs to fix

    File list.rb has 255 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module ActiveScaffold::Actions
      module List
        def self.included(base)
          base.before_action :list_authorized_filter, only: :index
          base.helper_method :list_columns, :count_on_association_class?
    Severity: Minor
    Found in lib/active_scaffold/actions/list.rb - About 2 hrs to fix

      Method update_columns_options has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def update_columns_options(column, scope, options, force = false, form_columns: nil, url_params: {})
              record = options[:object]
              subform_controller = controller.class.active_scaffold_controller_for(record.class) if scope
              if @main_columns && (scope.nil? || subform_controller == controller.class)
                form_columns ||= @main_columns.visible_columns_names
      Severity: Minor
      Found in lib/active_scaffold/helpers/form_column_helpers.rb - About 2 hrs 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 form_attribute has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def form_attribute(column, record, scope = nil, only_value = false, col_class = nil)
              column_options = active_scaffold_input_options(column, scope, object: record)
              collapsible_id = column_options.delete :collapsible_id
              attributes = field_attributes(column, record)
              attributes[:class] = "#{attributes[:class]} #{col_class}" if col_class.present?
      Severity: Minor
      Found in lib/active_scaffold/helpers/form_column_helpers.rb - About 2 hrs 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

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

            enable: function() {
              var _this = this;
              jQuery.each(this.set.links, function(index, item) {
                if (item.url != _this.url) return;
                item.tag.removeClass('disabled');
      Severity: Major
      Found in app/assets/javascripts/jquery/active_scaffold.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/jquery/active_scaffold.js on lines 1492..1498

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

      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

            disable: function() {
              var _this = this;
              jQuery.each(this.set.links, function(index, item) {
                if (item.url != _this.url) return;
                item.tag.addClass('disabled');
      Severity: Major
      Found in app/assets/javascripts/jquery/active_scaffold.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/jquery/active_scaffold.js on lines 1484..1490

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

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

            def active_scaffold_error_messages_for(*params)
              options = params.extract_options!.symbolize_keys
              options.reverse_merge!(container_tag: :div, list_type: :ul)
      
              objects = Array.wrap(options.delete(:object) || params).map do |object|
      Severity: Minor
      Found in lib/active_scaffold/helpers/view_helpers.rb - About 1 hr to fix

        Method column_class has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

              def column_class(column, column_value, record)
                classes = ActiveScaffold::Registry.cache :column_classes, column.cache_key do
                  classes = "#{column.name}-column "
                  classes << 'sorted ' if active_scaffold_config.actions.include?(:list) && active_scaffold_config.list.user.sorting.sorts_on?(column)
                  classes << 'numeric ' if column.number?
        Severity: Minor
        Found in lib/active_scaffold/helpers/view_helpers.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

        Method action_link_url_options has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

              def action_link_url_options(link, record)
                url_options = {action: link.action}
                url_options[:id] = '--ID--' unless record.nil?
                url_options[:controller] = link.controller.to_s if link.controller
                url_options.merge! link.parameters if link.parameters
        Severity: Minor
        Found in lib/active_scaffold/helpers/action_link_helpers.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

        Method query_string_for_action_links has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

              def query_string_for_action_links(link)
                if defined?(@query_string) && link.parameters.none? { |k, _| @query_string_params.include? k }
                  return [@query_string, @non_nested_query_string]
                end
        
        
        Severity: Minor
        Found in lib/active_scaffold/helpers/action_link_helpers.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

        Method columns_reader has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.columns_reader(name, options, &block)
              var = :"@#{name}"
              define_method name do
                unless instance_variable_defined?(var) # lazy evaluation
                  action, columns = options[:copy] if options[:copy]
        Severity: Minor
        Found in lib/active_scaffold/config/base.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

        Method sorting has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

              def sorting
                if @_sorting.nil?
                  # we want to store as little as possible in the session, but we want to return a Sorting data structure. so we recreate it each page load based on session data.
                  self['sort'] = [@params['sort'], @params['sort_direction']] if @params['sort'] && @params['sort_direction']
                  self['sort'] = nil if @params['sort_direction'] == 'reset'
        Severity: Minor
        Found in lib/active_scaffold/config/list.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

        Method pagination_ajax_links has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def pagination_ajax_links(current_page, url_options, options, inner_window, outer_window)
                start_number = current_page.number - inner_window
                end_number = current_page.number + inner_window
                start_number = 1 if start_number <= 0
                if current_page.pager.infinite?
        Severity: Minor
        Found in lib/active_scaffold/helpers/pagination_helpers.rb - About 1 hr to fix

          Method authorized_for? has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

                  def authorized_for?(options = {})
                    raise InvalidArgument if options[:crud_type].blank? && options[:action].blank?
          
                    if current_ability.present?
                      crud_type_result = options[:crud_type].nil? ? true : current_ability.can?(options[:crud_type], self)
          Severity: Minor
          Found in lib/active_scaffold/bridges/cancan/cancan_bridge.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

          Method get_column_value has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

                def get_column_value(record, column)
                  record = record.send(column.delegated_association.name) if column.delegated_association
                  if record
                    method, list_ui = get_column_method(record, column)
                    value =
          Severity: Minor
          Found in lib/active_scaffold/helpers/list_column_helpers.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

          Method setup_parent has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def setup_parent(record)
                cfg = main_form_controller.active_scaffold_config
                association = cfg.columns[subform_child_association]&.association&.reverse_association
                return if association.nil?
          
          
          Severity: Minor
          Found in lib/active_scaffold/actions/core.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

          Method render_list_column has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

                def render_list_column(text, column, record)
                  if column.link && !skip_action_link?(column.link, record)
                    link = column.link
                    associated = record.send(column.association.name) if column.association
                    authorized = link.action.nil?
          Severity: Minor
          Found in lib/active_scaffold/helpers/list_column_helpers.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

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

              removeHoverEffect: function() {
                  if (this.settings.hover_class)
                      this.dom.removeClass(this.settings.hover_class);
                  else
                      this.dom.css("background-color", this.settings.bg_out);
          Severity: Major
          Found in app/assets/javascripts/jquery/jquery.editinplace.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/jquery/jquery.editinplace.js on lines 164..169

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

          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

          Severity
          Category
          Status
          Source
          Language