activescaffold/active_scaffold

View on GitHub
lib/active_scaffold/data_structures/column.rb

Summary

Maintainability
F
3 days
Test Coverage
B
89%

Class Column has 67 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Column
    include ActiveScaffold::Configurable
    include ActiveScaffold::OrmChecks
    NO_PARAMS = Set.new.freeze
    NO_OPTIONS = {}.freeze
Severity: Major
Found in lib/active_scaffold/data_structures/column.rb - About 1 day to fix

    File column.rb has 471 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module ActiveScaffold::DataStructures
      class Column
        include ActiveScaffold::Configurable
        include ActiveScaffold::OrmChecks
        NO_PARAMS = Set.new.freeze
    Severity: Minor
    Found in lib/active_scaffold/data_structures/column.rb - About 7 hrs to fix

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

            def set_link(action, options = {})
              if action.is_a?(ActiveScaffold::DataStructures::ActionLink) || (action.is_a? Proc)
                @link = action
              else
                options[:label] ||= label
        Severity: Minor
        Found in lib/active_scaffold/data_structures/column.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 number_to_native has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def number_to_native(value)
              return value if value.blank? || !value.is_a?(String)
              native = '.' # native ruby separator
              format = {:separator => '', :delimiter => ''}.merge! I18n.t('number.format', :default => {})
              specific =
        Severity: Minor
        Found in lib/active_scaffold/data_structures/column.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 initialize_search_sql has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize_search_sql
              self.search_sql =
                unless virtual?
                  if association.nil?
                    field.to_s unless tableless?
        Severity: Minor
        Found in lib/active_scaffold/data_structures/column.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 default_for_empty_value has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def default_for_empty_value
              return nil unless column
              if column.is_a?(ActiveModel::Attribute)
                column.value
              elsif active_record?
        Severity: Minor
        Found in lib/active_scaffold/data_structures/column.rb - About 45 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 setup_association_info has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def setup_association_info
              assoc = active_record_class.reflect_on_association(name)
              @association =
                if assoc
                  if active_record?
        Severity: Minor
        Found in lib/active_scaffold/data_structures/column.rb - About 45 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 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 estimate_weight has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def estimate_weight
              if association&.singular?
                400
              elsif association&.collection?
                500
        Severity: Minor
        Found in lib/active_scaffold/data_structures/column.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 label has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def label(record = nil, scope = nil)
              if @label.respond_to?(:call)
                if record
                  @label.call(record, self, scope)
                else
        Severity: Minor
        Found in lib/active_scaffold/data_structures/column.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 search_sql= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def search_sql=(value)
              @search_sql =
                if value
                  value == true || value.is_a?(Proc) ? value : Array(value)
                else
        Severity: Minor
        Found in lib/active_scaffold/data_structures/column.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 validator_force_required? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def validator_force_required?(val)
              return false if val.options[:if] || val.options[:unless]
              case val
              when ActiveModel::Validations::PresenceValidator
                validator_required_on(val)
        Severity: Minor
        Found in lib/active_scaffold/data_structures/column.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

        There are no issues that match your filters.

        Category
        Status