activescaffold/active_scaffold

View on GitHub

Showing 277 of 366 total issues

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

    def show_blank_record?(associated)
      return false unless @show_blank_record
      return false unless association.klass.authorized_for?(:crud_type => :create) && !association.readonly?
      association.collection? || (association.singular? && associated.blank?)
    end
Severity: Minor
Found in lib/active_scaffold/data_structures/column.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

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

      def replace_id_params_in_action_link_url(link, record, url)
        url = record ? url.sub('--ID--', record.to_param.to_s) : url.clone
        if link.column&.association&.singular?
          child_id = record.send(link.column.association.name)&.to_param
          if child_id.present?
Severity: Minor
Found in lib/active_scaffold/helpers/action_link_helpers.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

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

    def update_column_association(parent_record, column, attribute, value)
      if belongs_to_counter_cache_hack?(column.association, attribute)
        parent_record.send "#{column.association.foreign_key}=", value&.id
        parent_record.association(column.name).target = value
      elsif column.association.collection? && column.association.through_singular?
Severity: Minor
Found in lib/active_scaffold/attribute_params.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

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

    def [](val)
      links = []
      @set.each do |item|
        if item.is_a?(ActiveScaffold::DataStructures::ActionLinks)
          collected = item[val]
Severity: Minor
Found in lib/active_scaffold/data_structures/action_links.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

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

      def datetime_from_to_for_trend(column, value)
        case value['opt']
        when 'PAST'
          trend_number = [value['number'].to_i, 1].max
          now = datetime_now
Severity: Minor
Found in lib/active_scaffold/finder.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

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

      def active_scaffold_add_existing_input(options)
        record = options.delete(:object)
        if !ActiveScaffold.js_framework.nil? && controller.respond_to?(:record_select_config, true)
          remote_controller = active_scaffold_controller_for(record_select_config.model).controller_path
          options[:controller] = remote_controller
Severity: Minor
Found in lib/active_scaffold/helpers/form_column_helpers.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 method.
Open

      return false unless association.source_reflection.collection? # create allowed if source is singular, rails creates joint model
Severity: Major
Found in lib/active_scaffold/data_structures/nested_info.rb - About 30 mins to fix

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

        def where(opts, *rest)
          if opts.present?
            opts = opts.with_indifferent_access if opts.is_a? Hash
            @conditions << (rest.empty? ? opts : [opts, *rest])
          end
    Severity: Minor
    Found in lib/active_scaffold/tableless.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

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

        def new_model(set_defaults = true)
          relation = beginning_of_chain
          if nested? && nested.plural_association? && nested.match_model?(active_scaffold_config.model)
            build_options = sti_nested_build_options(relation.klass)
          end
    Severity: Minor
    Found in lib/active_scaffold/actions/core.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

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

          def active_scaffold_column_boolean(record, column, ui_options: column.options)
            value = record.send(column.name)
            if value.nil? && ui_options[:include_blank]
              value = ui_options[:include_blank]
              value.is_a?(Symbol) ? as_(value) : value
    Severity: Minor
    Found in lib/active_scaffold/helpers/list_column_helpers.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

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

          def field_search_record_select_value(column, value, ui_options: column.options)
            return if value.blank?
            if ui_options[:multiple]
              column.association.klass.find value.select(&:present?).collect!(&:to_i)
            else
    Severity: Minor
    Found in lib/active_scaffold/bridges/record_select/helpers.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

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

          def active_scaffold_input_text_editor(column, options, ui_options: column.options)
            options[:class] = "#{options[:class]} mceEditor #{ui_options[:class]}".strip
    
            settings = tinymce_configuration(ui_options[:tinymce_config] || :default).options
                                                                                     .reject { |k, _v| k == 'selector' }
    Severity: Minor
    Found in lib/active_scaffold/bridges/tiny_mce/helpers.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

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

        def except(*skips)
          super.tap do |new_relation|
            unless new_relation.is_a?(RelationExtension)
              class << new_relation; include RelationExtension; end
            end
    Severity: Minor
    Found in lib/active_scaffold/tableless.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

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

          def self.format_to_datetime_picker(rails_time_format)
            date_format, time_format = split_datetime_format(to_datepicker_format(rails_time_format))
            datetime_picker_options = {}
            datetime_picker_options[:dateFormat] = date_format unless date_format.nil?
            unless time_format.nil?
    Severity: Minor
    Found in lib/active_scaffold/bridges/date_picker/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

    Function render_form_field has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      render_form_field: function(source, content, options) {
        var source = $(source);
        var element = source.up('.association-record'), selector = '';
        if (typeof(element) === 'undefined') {
          element = source.up('ol.form');
    Severity: Minor
    Found in app/assets/javascripts/prototype/active_scaffold.js - 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

    Function clonePatternField has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      clonePatternField: function() {
        var patternNodes = this.getPatternNodes(this.options.inplacePatternSelector);
        if (patternNodes.editNode == null) {
          alert('did not find any matching node for ' + this.options.editFieldSelector);
          return;
    Severity: Minor
    Found in app/assets/javascripts/prototype/active_scaffold.js - 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

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

        def self.active_record_column_type_cast(value, column_or_type)
          return Time.zone.at(value.to_i) if %i[time datetime].include?(column_or_type.type) && value =~ /\A\d+\z/
          cast_type = column_or_type.is_a?(ActiveRecord::ConnectionAdapters::Column) ? ActiveRecord::Type.lookup(column_or_type.type) : column_or_type
          cast_type ? cast_type.cast(value) : value
        end
    Severity: Minor
    Found in lib/active_scaffold/core.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

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

        def mark_respond_to_js
          if params.delete(:id) # so find_page doesn't filter by :id
            do_search if respond_to? :do_search, true
            set_includes_for_columns if active_scaffold_config.actions.include? :list
            @page = find_page(:pagination => active_scaffold_config.mark.mark_all_mode != :page)
    Severity: Minor
    Found in lib/active_scaffold/actions/mark.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

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

        def create_respond_to_js
          if successful? && !render_parent?
            do_refresh_list if active_scaffold_config.create.refresh_list
            if params[:dont_close]
              @saved_record = @record
    Severity: Minor
    Found in lib/active_scaffold/actions/create.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

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

          def inplace_edit_control(column)
            return unless inplace_edit?(active_scaffold_config.model, column) && inplace_edit_cloning?(column)
            unless ActiveScaffold.threadsafe
              column = column.dup
              column.options = column.options.dup
    Severity: Minor
    Found in lib/active_scaffold/helpers/list_column_helpers.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