activescaffold/active_scaffold

View on GitHub

Showing 361 of 361 total issues

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

Method active_scaffold_search_select has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def active_scaffold_search_select(column, html_options, options = {}, ui_options: column.options)
        record = html_options.delete(:object)
        associated = html_options.delete :value
        if column.association
          associated = associated.is_a?(Array) ? associated.map(&:to_i) : associated.to_i unless associated.nil?
Severity: Minor
Found in lib/active_scaffold/helpers/search_column_helpers.rb - About 1 hr to fix

    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

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

              Element[(element.value == 'null' || element.value == 'not_null') ? 'hide' : 'show'](element.readAttribute('id').sub('_opt', '_numeric'));
          Severity: Minor
          Found in app/assets/javascripts/prototype/active_scaffold.js and 1 other location - About 55 mins to fix
          app/assets/javascripts/prototype/active_scaffold.js on lines 308..308

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

          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

              Element[(element.value == 'PAST' || element.value == 'FUTURE') ? 'show' : 'hide'](element.readAttribute('id').sub('_opt', '_trend'));
          Severity: Minor
          Found in app/assets/javascripts/prototype/active_scaffold.js and 1 other location - About 55 mins to fix
          app/assets/javascripts/prototype/active_scaffold.js on lines 302..302

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

          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 date_options has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.date_options(locale)
                  date_picker_options = {
                    :closeText => as_(:close),
                    :prevText => as_(:previous),
                    :nextText => as_(:next),
          Severity: Minor
          Found in lib/active_scaffold/bridges/date_picker/helper.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 column_heading_value has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def column_heading_value(column, sorting, sort_direction)
                  if column.name == :as_marked
                    mark_column_heading
                  elsif column.sortable?
                    options = {:id => nil, :class => 'as_sort',
          Severity: Minor
          Found in lib/active_scaffold/helpers/list_column_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

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

              def sti_nested_build_options(klass)
                config = active_scaffold_config_for(klass)
                return unless config
                column = klass.inheritance_column
                return unless column && config._columns_hash[column]
          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 call has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def call(mapper, options = {})
                  options = @defaults.merge(options)
                  actions = get_actions(ACTIVE_SCAFFOLD_CORE_ROUTING, options)
          
                  mapper.collection do
          Severity: Minor
          Found in lib/active_scaffold/extensions/routing_mapper.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 updated_record_with_column has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def updated_record_with_column(column, value, scope)
                record = params[:id] ? copy_attributes(find_if_allowed(params[:id], :read)) : new_model
                apply_constraints_to_record(record) unless scope || params[:id]
                create_association_with_parent record, true if nested?
                if @form_action == :field_search && value.is_a?(Array) && column.association&.singular?
          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 include_habtm_actions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def include_habtm_actions
                if nested&.habtm?
                  # Production mode is ok with adding a link everytime the scaffold is nested - we are not ok with that.
                  unless active_scaffold_config.action_links['new_existing']
                    active_scaffold_config.action_links.add('new_existing', :label => :add_existing, :type => :collection, :security_method => :add_existing_authorized?)
          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 render has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                  def render(options = {}, locals = {}, &block)
                    case options
                    when Hash
                      in_rendering_context(options) do |_|
                        # previously set view paths and lookup context are lost here
          Severity: Minor
          Found in lib/active_scaffold/extensions/action_view_rendering.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 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 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

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

                def inplace_edit_data(column)
                  data = {}
                  data[:ie_url] = url_for(params_for(:action => 'update_column', :column => column.name, :id => '__id__'))
                  data[:ie_cancel_text] = column.options[:cancel_text] || as_(:cancel)
                  data[:ie_loading_text] = column.options[:loading_text] || as_(:loading)
          Severity: Minor
          Found in lib/active_scaffold/helpers/list_column_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

          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

          Severity
          Category
          Status
          Source
          Language