Showing 1,823 of 1,823 total issues

File database_statements.rb has 386 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ActiveRecord
  module ConnectionAdapters # :nodoc:
    module DatabaseStatements
      def initialize
        super

    File calculations.rb has 386 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "active_support/core_ext/enumerable"
    
    module ActiveRecord
      # = Active Record \Calculations
      module Calculations
    Severity: Minor
    Found in activerecord/lib/active_record/relation/calculations.rb - About 5 hrs to fix

      File time_zone.rb has 384 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require "tzinfo"
      require "concurrent/map"
      
      module ActiveSupport
        # = Active Support \Time Zone
      Severity: Minor
      Found in activesupport/lib/active_support/values/time_zone.rb - About 5 hrs to fix

        File compatibility.rb has 384 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        module ActiveRecord
          class Migration
            module Compatibility # :nodoc: all
              def self.find(version)
                version = version.to_s
        Severity: Minor
        Found in activerecord/lib/active_record/migration/compatibility.rb - About 5 hrs to fix

          File schema_cache.rb has 380 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require "active_support/core_ext/file/atomic"
          
          module ActiveRecord
            module ConnectionAdapters
              class SchemaReflection
          Severity: Minor
          Found in activerecord/lib/active_record/connection_adapters/schema_cache.rb - About 5 hrs to fix

            File test_case.rb has 380 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require "rack/session/abstract/id"
            require "active_support/core_ext/hash/conversions"
            require "active_support/core_ext/object/to_query"
            require "active_support/core_ext/module/anonymous"
            require "active_support/core_ext/module/redefine_method"
            Severity: Minor
            Found in actionpack/lib/action_controller/test_case.rb - About 5 hrs to fix

              Method fetch has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
              Open

                    def fetch(name, options = nil, &block)
                      if block_given?
                        options = merged_options(options)
                        key = normalize_key(name, options)
              
              
              Severity: Minor
              Found in activesupport/lib/active_support/cache.rb - About 5 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 store_accessor has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
              Open

                    def store_accessor(store_attribute, *keys, prefix: nil, suffix: nil)
                      keys = keys.flatten
              
                      accessor_prefix =
                        case prefix
              Severity: Minor
              Found in activerecord/lib/active_record/store.rb - About 5 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

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

              var disableFormElement = function(element) {
                if (getData(element, "ujs:disabled")) {
                  return;
                }
                const replacement = element.getAttribute("data-disable-with");
              Severity: Major
              Found in actionview/app/assets/javascripts/rails-ujs.esm.js and 1 other location - About 5 hrs to fix
              actionview/app/assets/javascripts/rails-ujs.js on lines 358..374

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 136.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                var disableFormElement = function(element) {
                  if (getData(element, "ujs:disabled")) {
                    return;
                  }
                  const replacement = element.getAttribute("data-disable-with");
              Severity: Major
              Found in actionview/app/assets/javascripts/rails-ujs.js and 1 other location - About 5 hrs to fix
              actionview/app/assets/javascripts/rails-ujs.esm.js on lines 402..418

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 136.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Class SelectManager has 38 methods (exceeds 20 allowed). Consider refactoring.
              Open

                class SelectManager < Arel::TreeManager
                  include Arel::Crud
              
                  STRING_OR_SYMBOL_CLASS = [Symbol, String]
              
              
              Severity: Minor
              Found in activerecord/lib/arel/select_manager.rb - About 5 hrs to fix

                File plugin_generator.rb has 375 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                require "active_support/core_ext/hash/except"
                require "rails/generators/rails/app/app_generator"
                require "date"
                
                module Rails
                Severity: Minor
                Found in railties/lib/rails/generators/rails/plugin/plugin_generator.rb - About 5 hrs to fix

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

                            def deserialize(value)
                              return value unless value.is_a?(::String)
                  
                              scanner = StringScanner.new(value)
                              hash = {}

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

                          def with_raw_connection(allow_retry: false, materialize_transactions: true)
                            @lock.synchronize do
                              connect! if @raw_connection.nil? && reconnect_can_restore_state?
                  
                              self.materialize_transactions if materialize_transactions

                  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 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

                  Identical blocks of code found in 3 locations. Consider refactoring.
                  Open

                    function createWebSocketURL(url) {
                      if (typeof url === "function") {
                        url = url();
                      }
                      if (url && !/^wss?:/i.test(url)) {
                  Severity: Major
                  Found in actioncable/app/assets/javascripts/actioncable.js and 2 other locations - About 4 hrs to fix
                  actioncable/app/assets/javascripts/action_cable.js on lines 472..485
                  actioncable/app/assets/javascripts/actioncable.esm.js on lines 486..499

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 132.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Identical blocks of code found in 3 locations. Consider refactoring.
                  Open

                    function createWebSocketURL(url) {
                      if (typeof url === "function") {
                        url = url();
                      }
                      if (url && !/^wss?:/i.test(url)) {
                  Severity: Major
                  Found in actioncable/app/assets/javascripts/action_cable.js and 2 other locations - About 4 hrs to fix
                  actioncable/app/assets/javascripts/actioncable.esm.js on lines 486..499
                  actioncable/app/assets/javascripts/actioncable.js on lines 472..485

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 132.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Identical blocks of code found in 3 locations. Consider refactoring.
                  Open

                  function createWebSocketURL(url) {
                    if (typeof url === "function") {
                      url = url();
                    }
                    if (url && !/^wss?:/i.test(url)) {
                  Severity: Major
                  Found in actioncable/app/assets/javascripts/actioncable.esm.js and 2 other locations - About 4 hrs to fix
                  actioncable/app/assets/javascripts/action_cable.js on lines 472..485
                  actioncable/app/assets/javascripts/actioncable.js on lines 472..485

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 132.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  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
                      Severity
                      Category
                      Status
                      Source
                      Language