activescaffold/active_scaffold

View on GitHub

Showing 246 of 296 total issues

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

    def update_save(attributes: params[:record], no_record_param_update: false)
      active_scaffold_config.model.transaction do
        unless no_record_param_update
          @record = update_record_from_params(@record, active_scaffold_config.update.columns, attributes)
        end
Severity: Minor
Found in lib/active_scaffold/actions/update.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_bitfields has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def _setup_bitfields
          return unless model.respond_to?(:bitfields) && model.bitfields.present?

          supported_actions = %i[create update show subform]
          model.bitfields.each do |column_name, options|
Severity: Minor
Found in lib/active_scaffold/bridges/bitfields/bitfields_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 do_field_search has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def do_field_search
        filtered_columns = []
        text_search = active_scaffold_config.field_search.text_search
        columns = active_scaffold_config.field_search.columns
        search_params.each do |key, value|
Severity: Minor
Found in lib/active_scaffold/actions/field_search.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 condition_for_datetime has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def condition_for_datetime(column, value, like_pattern = nil)
        operator = ActiveScaffold::Finder::NUMERIC_COMPARATORS.include?(value['opt']) && value['opt'] != 'BETWEEN' ? value['opt'] : nil
        from_value, to_value = datetime_from_to(column, value)

        if column.search_sql.is_a? Proc
Severity: Minor
Found in lib/active_scaffold/finder.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 condition_value_for_numeric has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def condition_value_for_numeric(column, value)
        return value if value.nil?

        value = column.number_to_native(value) if column.options[:format] && column.search_ui != :number
        case column.search_ui || column.column_type
Severity: Minor
Found in lib/active_scaffold/finder.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 subgroup has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def subgroup(name, label = nil)
      group = self if name == self.name
      group ||= @set.find do |item|
        name == item.name if item.is_a?(ActiveScaffold::DataStructures::ActionLinks)
      end
Severity: Minor
Found in lib/active_scaffold/data_structures/action_links.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 has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def render(*args, &block)
      if args.first.is_a?(Hash) && args.first[:active_scaffold]
        render_embedded args.first
      elsif args.first == :super
        if @lookup_context # rails 6
Severity: Minor
Found in lib/active_scaffold/extensions/action_view_rendering.rb - About 1 hr to fix

    Method action_link_html_options has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def action_link_html_options(link, record, options)
            link_id = get_action_link_id(link, record)
            html_options = link.html_options.merge(class: [link.html_options[:class], link.action.to_s].compact.join(' '))
            html_options[:link] = action_link_text(link, record, options)
    
    
    Severity: Minor
    Found in lib/active_scaffold/helpers/action_link_helpers.rb - About 1 hr to fix

      Method query_string_for_action_links has 32 lines of code (exceeds 25 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

        Method override_helper_per_model has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def override_helper_per_model(method, model, cache_keys = nil)
                cache_keys ||= [method, model.name]
                ActiveScaffold::Registry.cache(*cache_keys) do
                  model_names = [model.name]
                  model_names << model.base_class.name if model.respond_to?(:base_class) && model.base_class != model
        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 set_includes_for_sorting has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def set_includes_for_sorting(columns, sorting)
              sorting.each_column do |col|
                next if sorting.constraint_columns.include? col.name
                next unless col.includes.present? && columns.exclude?(col)
        
        
        Severity: Minor
        Found in lib/active_scaffold/actions/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 options_for_render_super has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def options_for_render_super(options)
              options ||= {}
              options[:locals] ||= {}
              if view_stack.last
                options[:locals] = view_stack.last[:locals].merge!(options[:locals]) if view_stack.last[:locals]
        Severity: Minor
        Found in lib/active_scaffold/extensions/action_view_rendering.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 show_column_value has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def show_column_value(record, column)
                value_record = column.delegated_association ? record.send(column.delegated_association.name) : record
                return get_column_value(record, column) unless value_record
        
                # check for an override helper
        Severity: Minor
        Found in lib/active_scaffold/helpers/show_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 find_duplicate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def find_duplicate(link)
              links = []
              @set.each do |item|
                next if item == :separator
        
        
        Severity: Minor
        Found in lib/active_scaffold/data_structures/action_links.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 parse_time_with_format has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def parse_time_with_format(value, format, offset)
                format.gsub!(/%-d|%-m|%_m/) { |s| s.gsub(/[-_]/, '') } # strptime fails with %-d, %-m, %_m
                en_value = I18n.locale == :en ? value : translate_days_and_months(value, format)
                time = Time.strptime(en_value, format)
                offset ? time : Time.zone.local_to_utc(time).in_time_zone
        Severity: Minor
        Found in lib/active_scaffold/finder.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 add has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def add(action, options = {})
              link =
                if action.is_a?(ActiveScaffold::DataStructures::ActionLink) || action.is_a?(ActiveScaffold::DataStructures::ActionLinks)
                  action
                else
        Severity: Minor
        Found in lib/active_scaffold/data_structures/action_links.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 register_constraints_with_action_columns has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def register_constraints_with_action_columns(constrained_fields = nil)
              constrained_fields ||= []
              constrained_fields |= active_scaffold_constraints.flat_map { |k, v| columns_from_constraint(k, v) }.compact
              exclude_actions = []
              %i[list update].each do |action_name|
        Severity: Minor
        Found in lib/active_scaffold/constraints.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 create_record_row has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              create_record_row: function(active_scaffold_id, html, options) {
                if (typeof(active_scaffold_id) == 'string') active_scaffold_id = '#' + active_scaffold_id;
                var tbody = jQuery(active_scaffold_id).find(options.body_selector || 'tbody.records').first(), new_row;
        
                if (options.insert_at == 'top') {
        Severity: Minor
        Found in app/assets/javascripts/jquery/active_scaffold.js - About 1 hr to fix

          Method conditions_from_params has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def conditions_from_params
                @conditions_from_params ||= begin
                  conditions = [{}]
                  supporting_range = %i[date datetime integer decimal float bigint]
                  params.except(:controller, :action, :page, :sort, :sort_direction, :format, :id).each do |key, value|
          Severity: Minor
          Found in lib/active_scaffold/actions/core.rb - About 1 hr to fix

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

                  insert: function(content) {
                    this.close_previous_adapter();
            
                    if (this.position === 'replace') {
                      this.position = 'after';
            Severity: Minor
            Found in app/assets/javascripts/jquery/active_scaffold.js - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language