Showing 1,298 of 1,828 total issues

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

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

      def distance_of_time_in_words(from_time, to_time = 0, options = {})
        options = {
          scope: :'datetime.distance_in_words'
        }.merge!(options)

Severity: Minor
Found in actionview/lib/action_view/helpers/date_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

File fanout.rb has 350 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "concurrent/map"
require "set"
require "active_support/core_ext/object/try"

module ActiveSupport
Severity: Minor
Found in activesupport/lib/active_support/notifications/fanout.rb - About 4 hrs to fix

    File response.rb has 350 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "active_support/core_ext/module/attribute_accessors"
    require "action_dispatch/http/filter_redirect"
    require "action_dispatch/http/cache"
    require "monitor"
    
    
    Severity: Minor
    Found in actionpack/lib/action_dispatch/http/response.rb - About 4 hrs to fix

      Class Engine has 34 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Engine < Railtie
          autoload :Configuration, "rails/engine/configuration"
      
          class << self
            attr_accessor :called_from, :isolated
      Severity: Minor
      Found in railties/lib/rails/engine.rb - About 4 hrs to fix

        Method compute_asset_host has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

              def compute_asset_host(source = "", options = {})
                request = self.request if respond_to?(:request)
                host = options[:host]
                host ||= config.asset_host if defined? config.asset_host
        
        
        Severity: Minor
        Found in actionview/lib/action_view/helpers/asset_url_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 RouteSet has 33 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class RouteSet
              # Since the router holds references to many parts of the system like engines,
              # controllers and the application itself, inspecting the route set can actually
              # be really slow, therefore we default alias inspect to to_s.
              alias inspect to_s
        Severity: Minor
        Found in actionpack/lib/action_dispatch/routing/route_set.rb - About 4 hrs to fix

          Method to_tag has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

              def to_tag(key, value, options)
                type_name = options.delete(:type)
                merged_options = options.merge(root: key, skip_instruct: true)
          
                if value.is_a?(::Method) || value.is_a?(::Proc)
          Severity: Minor
          Found in activesupport/lib/active_support/xml_mini.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 jobs_with has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

                def jobs_with(jobs, only: nil, except: nil, queue: nil, at: nil)
                  validate_option(only: only, except: except)
          
                  jobs.dup.select do |job|
                    job_class = job.fetch(:job)
          Severity: Minor
          Found in activejob/lib/active_job/test_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

          Method type_to_sql has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

                def type_to_sql(type, limit: nil, precision: nil, scale: nil, **) # :nodoc:
                  type = type.to_sym if type
                  if native = native_database_types[type]
                    column_type_sql = (native.is_a?(Hash) ? native[:name] : native).dup
          
          

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

                def _enum(name, values, prefix: nil, suffix: nil, scopes: true, instance_methods: true, validate: false, **options)
                  assert_valid_enum_definition_values(values)
                  # statuses = { }
                  enum_values = ActiveSupport::HashWithIndifferentAccess.new
                  name = name.to_s
          Severity: Minor
          Found in activerecord/lib/active_record/enum.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 merge_and_normalize_cache_control! has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

                  def merge_and_normalize_cache_control!(cache_control)
                    control = cache_control_headers
          
                    return if control.empty? && cache_control.empty?  # Let middleware handle default behavior
          
          
          Severity: Minor
          Found in actionpack/lib/action_dispatch/http/cache.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 associations.rb has 334 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module ActiveRecord
            class AssociationNotFoundError < ConfigurationError # :nodoc:
              attr_reader :record, :association_name
          
              def initialize(record = nil, association_name = nil)
          Severity: Minor
          Found in activerecord/lib/active_record/associations.rb - About 4 hrs to fix

            Method generate has 100 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def generate(owner, methods, location: nil, to: nil, prefix: nil, allow_nil: nil, nilable: true, private: nil, as: nil, signature: nil)
                    unless to
                      raise ArgumentError, "Delegation needs a target. Supply a keyword argument 'to' (e.g. delegate :hello, to: :greeter)."
                    end
            
            
            Severity: Major
            Found in activesupport/lib/active_support/delegation.rb - About 4 hrs to fix

              File active_storage.rb has 331 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require "active_record"
              require "active_support"
              require "active_support/rails"
              require "active_support/core_ext/numeric/time"
              
              
              Severity: Minor
              Found in activestorage/lib/active_storage.rb - About 3 hrs to fix

                Function handleRemoteWithRails has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                Open

                const handleRemoteWithRails = rails => function(e) {
                  let data, method, url;
                  const element = this;
                  if (!isRemote(element)) {
                    return true;
                Severity: Minor
                Found in actionview/app/assets/javascripts/rails-ujs.esm.js - About 3 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 read has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                Open

                      def read(name, options = nil)
                        options = merged_options(options)
                        key     = normalize_key(name, options)
                        version = normalize_version(name, options)
                
                
                Severity: Minor
                Found in activesupport/lib/active_support/cache.rb - About 3 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 finder_methods.rb has 329 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                require "active_support/core_ext/string/filters"
                
                module ActiveRecord
                  module FinderMethods
                    ONE_AS_ONE = "1 AS one"
                Severity: Minor
                Found in activerecord/lib/active_record/relation/finder_methods.rb - About 3 hrs to fix

                  File railtie.rb has 328 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require "active_record"
                  require "rails"
                  require "active_support/core_ext/object/try"
                  require "active_model/railtie"
                  
                  
                  Severity: Minor
                  Found in activerecord/lib/active_record/railtie.rb - About 3 hrs to fix

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

                    class Time
                      include DateAndTime::Calculations
                    
                      COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
                    
                    
                    Severity: Minor
                    Found in activesupport/lib/active_support/core_ext/time/calculations.rb - About 3 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language