Showing 1,291 of 1,823 total issues

Method run has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

        def run
          loop do
            if @stopping
              @nio.close
              break
Severity: Minor
Found in actioncable/lib/action_cable/connection/stream_event_loop.rb - About 4 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

Class CollectionAssociation has 37 methods (exceeds 20 allowed). Consider refactoring.
Open

    class CollectionAssociation < Association # :nodoc:
      # Implements the reader method, e.g. foo.items for Foo.has_many :items
      def reader
        ensure_klass_exists!

Severity: Minor
Found in activerecord/lib/active_record/associations/collection_association.rb - About 4 hrs to fix

    Class CollectionProxy has 37 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class CollectionProxy < Relation
          def initialize(klass, association, **) # :nodoc:
            @association = association
            super klass
    
    
    Severity: Minor
    Found in activerecord/lib/active_record/associations/collection_proxy.rb - About 4 hrs to fix

      Method assign_nested_attributes_for_collection_association has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

            def assign_nested_attributes_for_collection_association(association_name, attributes_collection)
              options = nested_attributes_options[association_name]
              if attributes_collection.respond_to?(:permitted?)
                attributes_collection = attributes_collection.to_h
              end
      Severity: Minor
      Found in activerecord/lib/active_record/nested_attributes.rb - About 4 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 calculate has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

          def calculate(operation, column_name)
            operation = operation.to_s.downcase
      
            if @none
              case operation
      Severity: Minor
      Found in activerecord/lib/active_record/relation/calculations.rb - About 4 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 batch_on_unloaded_relation has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

            def batch_on_unloaded_relation(relation:, start:, finish:, load:, order:, use_ranges:, remaining:, batch_limit:)
              batch_orders = build_batch_orders(order)
              relation = relation.reorder(batch_orders.to_h).limit(batch_limit)
              relation = apply_limits(relation, start, finish, batch_orders)
              relation.skip_query_cache! # Retaining the results in the query cache would undermine the point of batching
      Severity: Minor
      Found in activerecord/lib/active_record/relation/batches.rb - About 4 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 listen has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

                def listen(conn)
                  conn.without_reconnect do
                    original_client = extract_subscribed_client(conn)
      
                    conn.subscribe("_action_cable_internal") do |on|
      Severity: Minor
      Found in actioncable/lib/action_cable/subscription_adapter/redis.rb - About 4 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 render_details has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

            def render_details(req)
              threads = ActiveSupport::Dependencies.interlock.raw_state do |raw_threads|
                # The Interlock itself comes to a complete halt as long as this block is
                # executing. That gives us a more consistent picture of everything, but creates
                # a pretty strong Observer Effect.
      Severity: Minor
      Found in actionpack/lib/action_dispatch/middleware/debug_locks.rb - About 4 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 tag_options has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

              def tag_options(options, escape = true)
                return if options.blank?
                output = +""
                sep    = " "
                options.each_pair do |key, value|
      Severity: Minor
      Found in actionview/lib/action_view/helpers/tag_helper.rb - About 4 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

      Class TimeZone has 36 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class TimeZone
          # Keys are \Rails TimeZone names, values are TZInfo identifiers.
          MAPPING = {
            "International Date Line West" => "Etc/GMT+12",
            "Midway Island"                => "Pacific/Midway",
      Severity: Minor
      Found in activesupport/lib/active_support/values/time_zone.rb - About 4 hrs to fix

        File collection_association.rb has 359 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require "active_support/core_ext/enumerable"
        
        module ActiveRecord
          module Associations
            # = Active Record Association Collection
        Severity: Minor
        Found in activerecord/lib/active_record/associations/collection_association.rb - About 4 hrs to fix

          Method find_by has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
          Open

                def find_by(*args) # :nodoc:
                  return super if scope_attributes?
          
                  hash = args.first
                  return super unless Hash === hash
          Severity: Minor
          Found in activerecord/lib/active_record/core.rb - About 4 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 resolve_sti_reflections has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
          Open

                  def resolve_sti_reflections
                    # If STI is used, find the correct subclass for association reflection
                    reflection_class._reflections.each_value do |association|
                      case association.macro
                      when :belongs_to
          Severity: Minor
          Found in activerecord/lib/active_record/fixture_set/table_row.rb - About 4 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 visit_Arel_Nodes_BoundSqlLiteral has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
          Open

                  def visit_Arel_Nodes_BoundSqlLiteral(o, collector)
                    collector.retryable = false
                    bind_index = 0
          
                    new_bind = lambda do |value|
          Severity: Minor
          Found in activerecord/lib/arel/visitors/to_sql.rb - About 4 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 move has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
          Open

                  def move(t, full_string, start_index, end_index)
                    return [] if t.empty?
          
                    next_states = []
          
          
          Severity: Minor
          Found in actionpack/lib/action_dispatch/journey/gtg/transition_table.rb - About 4 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

          File tag_helper.rb has 357 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require "active_support/code_generator"
          require "active_support/core_ext/enumerable"
          require "active_support/core_ext/string/output_safety"
          require "active_support/core_ext/string/inflections"
          require "set"
          Severity: Minor
          Found in actionview/lib/action_view/helpers/tag_helper.rb - About 4 hrs to fix

            File active_record.rb has 352 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require "active_support"
            require "active_support/rails"
            require "active_support/ordered_options"
            require "active_model"
            require "arel"
            Severity: Minor
            Found in activerecord/lib/active_record.rb - About 4 hrs to fix

              Method run_callbacks has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
              Open

                  def run_callbacks(kind, type = nil)
                    callbacks = __callbacks[kind.to_sym]
              
                    if callbacks.empty?
                      yield if block_given?
              Severity: Minor
              Found in activesupport/lib/active_support/callbacks.rb - About 4 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 find_offset has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
              Open

                      def find_offset(compiled, source_tokens, error_column)
                        compiled = StringScanner.new(compiled)
              
                        passed_tokens = []
              
              
              Severity: Minor
              Found in actionview/lib/action_view/template/handlers/erb.rb - About 4 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 render_calls has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
              Open

                    def render_calls
                      queue = [Prism.parse(@code).value]
                      templates = []
              
                      while (node = queue.shift)
              Severity: Minor
              Found in actionview/lib/action_view/render_parser/prism_render_parser.rb - About 4 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

              Severity
              Category
              Status
              Source
              Language