activescaffold/active_scaffold

View on GitHub

Showing 276 of 365 total issues

Method condition_value_for_datetime has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def condition_value_for_datetime(column, value, conversion = :to_time)
        return if value.nil? || value.blank?
        if value.is_a? Hash
          local_time_from_hash(value, conversion)
        elsif value.respond_to?(:strftime)
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 initialize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(name, active_record_class, delegated_association = nil) #:nodoc:
      @name = name.to_sym
      @active_record_class = active_record_class
      @column = _columns_hash[name.to_s]
      if @column.nil? && active_record? && active_record_class._default_attributes.key?(name.to_s)
Severity: Minor
Found in lib/active_scaffold/data_structures/column.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 default_select_columns has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def default_select_columns
      if association.nil? && column
        [field]
      elsif association&.polymorphic?
        [field, quoted_field(quoted_field_name(association.foreign_type))]
Severity: Minor
Found in lib/active_scaffold/data_structures/column.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_page has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def find_page(options = {})
      options.assert_valid_keys :sorting, :per_page, :page, :count_includes, :pagination, :select
      options[:per_page] ||= 999_999_999
      options[:page] ||= 1

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

      def active_scaffold_input_radio(column, html_options, ui_options: column.options)
        record = html_options[:object]
        html_options.merge!(ui_options[:html_options] || {})
        options =
          if column.association
Severity: Minor
Found in lib/active_scaffold/helpers/form_column_helpers.rb - About 1 hr to fix

    Method condition_for_column has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def condition_for_column(column, value, text_search, session)
            like_pattern = like_pattern(text_search)
            value = value.with_indifferent_access if value.is_a? Hash
            column_method = "condition_for_#{column.name}_column"
            if respond_to?(column_method)
    Severity: Minor
    Found in lib/active_scaffold/finder.rb - About 1 hr to fix

      Method column_numerical_constraints has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def column_numerical_constraints(column, options)
              validators = column.active_record_class.validators.select do |v|
                v.is_a?(ActiveModel::Validations::NumericalityValidator) &&
                  v.attributes.include?(column.name) &&
                  !v.options[:if] && !v.options[:unless]
      Severity: Minor
      Found in lib/active_scaffold/helpers/form_column_helpers.rb - About 1 hr to fix

        Method initialize has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def initialize(name, active_record_class, delegated_association = nil) #:nodoc:
              @name = name.to_sym
              @active_record_class = active_record_class
              @column = _columns_hash[name.to_s]
              if @column.nil? && active_record? && active_record_class._default_attributes.key?(name.to_s)
        Severity: Minor
        Found in lib/active_scaffold/data_structures/column.rb - About 1 hr to fix

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

              def render_field_for_update_columns
                return if (@column = active_scaffold_config.columns[params.delete(:column)]).nil?
                @source_id = params.delete(:source_id)
                @columns = @column.update_columns || []
                @scope = params.delete(:scope)
          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

          Function update_column has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            update_column: function(element, url, send_form, source_id, val, additional_params) {
              if (!element) element = $(source_id);
              
              var as_form = element.up('form.as_form');
              var params = null;
          Severity: Minor
          Found in app/assets/javascripts/prototype/active_scaffold.js - 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 _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?
                    model.bitfields.each do |column_name, options|
                      columns = options.keys.sort_by { |column| self.columns[column].weight }
                      %i[create update show subform].each do |action|
          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 keeping_errors has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def keeping_errors
              old_errors = errors.dup if errors.present?
              result = yield
              old_errors&.each do |e|
                if e.is_a?(String) || e.is_a?(Symbol)
          Severity: Minor
          Found in lib/active_scaffold/extensions/unsaved_record.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 target_scope has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def target_scope
                super.tap do |scope|
                  if klass < ActiveScaffold::Tableless
                    class << scope; include RelationExtension; end
                    assoc_conditions = scope.proxy_association&.send(:association_scope)&.conditions
          Severity: Minor
          Found in lib/active_scaffold/tableless.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 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 look_for_parent_sti_controller has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def look_for_parent_sti_controller
                klass = self.class.active_scaffold_config.model
                loop do
                  klass = klass.superclass
                  controller = self.class.active_scaffold_controller_for(klass)
          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 update_column_from_params has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def update_column_from_params(parent_record, column, attribute, avoid_changes = false)
                value = column_value_from_param_value(parent_record, column, attribute, avoid_changes)
                if column.association
                  if avoid_changes
                    parent_record.association(column.name).target = value
          Severity: Minor
          Found in lib/active_scaffold/attribute_params.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 attributes_hash_is_empty? has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def attributes_hash_is_empty?(hash, klass)
                hash.all? do |key, value|
                  # convert any possible multi-parameter attributes like 'created_at(5i)' to simply 'created_at'
                  column_name = key.to_s.split('(', 2)[0]
          
          
          Severity: Minor
          Found in lib/active_scaffold/attribute_params.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)
                  when :integer   then
          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

          Severity
          Category
          Status
          Source
          Language