activescaffold/active_scaffold

View on GitHub

Showing 276 of 365 total issues

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

      def build_associated(association, parent_record)
        if association.through? && association.through_reflection.collection?
          # build full chain, only check create_associated on initial parent_record
          parent_record = build_associated(association.class.new(association.through_reflection), parent_record)
          source_assoc = association.class.new(association.source_reflection)
Severity: Minor
Found in lib/active_scaffold/helpers/controller_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 override_helper_per_model has a Cognitive Complexity of 10 (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.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 active_scaffold_search_calendar_date_select_field has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def active_scaffold_search_calendar_date_select_field(column, options, current_search, name, ui_options: column.options)
          value =
            if current_search.is_a? Hash
              controller.class.condition_value_for_datetime(column, current_search[name], column.column_type == :date ? :to_date : :to_time)
            else
Severity: Minor
Found in lib/active_scaffold/bridges/calendar_date_select/as_cds_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_create has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def do_create(options = {})
      attributes = options[:attributes] || params[:record]
      active_scaffold_config.model.transaction do
        @record = new_model
        # before assign params, to set foreign_type of constraints in polymorphic association with multiple id
Severity: Minor
Found in lib/active_scaffold/actions/create.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 setup has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

       setup: function(options) {
               
               /*
                       options - object to store initialization parameters - passed in from dhtmlHistory or directly into historyStorage
                       options.debugMode - boolean that causes hidden form fields to be shown for development purposes.
Severity: Minor
Found in app/assets/javascripts/prototype/dhtml_history.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 columns_from_constraint has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def columns_from_constraint(column_name, value)
      return if params_hash?(value)
      if value.is_a?(Array)
        column = active_scaffold_config.columns[column_name]
        if column&.association&.polymorphic?
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

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

      def add_query_string_to_cached_url(link, url)
        query_string, non_nested_query_string = query_string_for_action_links(link)
        nested_params = (!link.nested_link? && non_nested_query_string)
        if query_string || nested_params
          url << (url.include?('?') ? '&' : '?')
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 add_link has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def add_link(attribute, options = {})
      column = @core.columns[attribute.to_sym]
      raise ArgumentError, "unknown column #{attribute}" if column.nil?
      raise ArgumentError, "column #{attribute} is not an association" if column.association.nil?

Severity: Minor
Found in lib/active_scaffold/config/nested.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_defaults_for_column has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def setup_defaults_for_column
      if active_record_class.respond_to?(:defined_enums) && active_record_class.defined_enums[name.to_s]
        @form_ui = :select
        @options = {:options => active_record_class.send(name.to_s.pluralize).keys.map(&:to_sym)}
      elsif column_number?
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 in_subform? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def in_subform?(column, parent_record, parent_column)
        return true unless column.association

        if column.association.reverse.nil?
          # Polymorphic associations can't appear because they *might* be the reverse association
Severity: Minor
Found in lib/active_scaffold/helpers/form_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 update_record_from_params has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def update_record_from_params(parent_record, columns, attributes, avoid_changes = false)
      crud_type = parent_record.new_record? ? :create : :update
      return parent_record unless parent_record.authorized_for?(:crud_type => crud_type)

      multi_parameter_attrs = multi_parameter_attributes(attributes)
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 subgroup has a Cognitive Complexity of 10 (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

Function handleSaveEditor has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    handleSaveEditor: function(anEvent) {
        if (false === this.triggerDelegateCall('shouldCloseEditInPlace', true, anEvent))
            return;

        var editor = this.dom.find('[name]:input:not(:button,[name=""])').not('input:checkbox:not(:checked)').not('input:radio:not(:checked)');
Severity: Minor
Found in app/assets/javascripts/jquery/jquery.editinplace.js - About 1 hr to fix

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

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

            def active_scaffold_new_record_subform(column, record, html_options, ui_options: column.options, new_record_attributes: nil, locals: {}, skip_link: false)
              klass =
                if column.association.polymorphic? && column.association.belongs_to?
                  type = record.send(column.association.foreign_type)
                  column.association.klass(record) if type.present? && (ui_options[:add_new] == true || type.in?(ui_options[:add_new]))
      Severity: Minor
      Found in lib/active_scaffold/helpers/form_column_helpers.rb - About 1 hr to fix

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

                def method_missing(name, *args, &block)
                  CowProxy.debug { "method missing #{name} in #{__getobj__.name}" }
                  return super if name.match?(/[!?]$/)
                  subgroup =
                    if _instance_variable_defined?("@#{name}")
        Severity: Minor
        Found in lib/active_scaffold/extensions/cow_proxy.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

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

            def create_association_with_parent(record, check_match = false)
              return unless create_association_with_parent?(check_match)
              if nested.child_association&.singular?
                record.send("#{nested.child_association.name}=", nested_parent_record)
              elsif nested.create_through_singular?
        Severity: Minor
        Found in lib/active_scaffold/actions/nested.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

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

              def active_scaffold_input_ancestry(column, options, ui_options: column.options)
                record = options[:object]
                select_options = []
                select_control_options = {:selected => record.parent_id}
                select_control_options[:include_blank] = as_(:_select_) if record.parent_id.nil?
        Severity: Minor
        Found in lib/active_scaffold/bridges/ancestry/ancestry_bridge.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

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

            def updated_record_with_form(columns, attributes, scope)
              if attributes && scope
                attributes = scope.delete('[').split(']').inject(attributes) { |h, idx| h[idx] }
                id = attributes[:id]
              else
        Severity: Minor
        Found in lib/active_scaffold/actions/core.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

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

              def main_path_to_return
                if params[:return_to]
                  params[:return_to]
                else
                  exclude_parameters = %i[utf8 associated_id]
        Severity: Minor
        Found in lib/active_scaffold/helpers/controller_helpers.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

        Severity
        Category
        Status
        Source
        Language