activescaffold/active_scaffold

View on GitHub
lib/active_scaffold/actions/core.rb

Summary

Maintainability
D
2 days
Test Coverage
F
42%

File core.rb has 414 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ActiveScaffold::Actions
  module Core
    def self.included(base)
      base.class_eval do
        before_action :set_vary_accept_header
Severity: Minor
Found in lib/active_scaffold/actions/core.rb - About 5 hrs to fix

    Method process_action_link_action has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_action_link_action(render_action = :action_update, crud_type_or_security_options = nil)
          if request.get? || request.head?
            # someone has disabled javascript, we have to show confirmation form first
            @record = find_if_allowed(params[:id], :read) if params[:id]
            respond_to_action(:action_confirmation)
    Severity: Minor
    Found in lib/active_scaffold/actions/core.rb - About 2 hrs 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_parent has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def setup_parent(record)
          cfg = main_form_controller.active_scaffold_config
          association = cfg.columns[subform_child_association]&.association&.reverse_association
          return if association.nil?
    
    
    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 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

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

        def conditions_from_params
          @conditions_from_params ||= begin
            conditions = [{}]
            params.except(:controller, :action, :page, :sort, :sort_direction, :format, :id).each do |key, value|
              distinct = true if key.match?(/!$/)
    Severity: Minor
    Found in lib/active_scaffold/actions/core.rb - About 1 hr to fix

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

          def parent_sti_controller
            return unless params[:parent_sti]
            unless defined? @parent_sti_controller
              controller = look_for_parent_sti_controller
              @parent_sti_controller = controller.controller_path == params[:parent_sti] ? controller : false
      Severity: Minor
      Found in lib/active_scaffold/actions/core.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 respond_to_action has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def respond_to_action(action)
            return unless !conditional_get_support? || view_stale?
            respond_to do |type|
              action_formats.each do |format|
                type.send(format) do
      Severity: Minor
      Found in lib/active_scaffold/actions/core.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

      There are no issues that match your filters.

      Category
      Status