activescaffold/active_scaffold

View on GitHub
lib/active_scaffold/tableless.rb

Summary

Maintainability
B
6 hrs
Test Coverage
B
85%

Class Tableless has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/ApplicationRecord
  class AssociationScope < ActiveRecord::Associations::AssociationScope
    INSTANCE = create
    def self.scope(association, connection)
      INSTANCE.scope association, connection
Severity: Minor
Found in lib/active_scaffold/tableless.rb - About 3 hrs to fix

    Method target_scope has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def target_scope
          super.tap do |scope|
            if klass < ActiveScaffold::Tableless
              class << scope; include RelationExtension; end
              assoc_conditions = scope.proxy_association&.send(:association_scope)&.conditions
    Severity: Minor
    Found in lib/active_scaffold/tableless.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 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def initialize(name, default, sql_type = nil, null = true, **)
    Severity: Minor
    Found in lib/active_scaffold/tableless.rb - About 35 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 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

      There are no issues that match your filters.

      Category
      Status