Showing 1,298 of 1,828 total issues

File redis_cache_store.rb has 289 lines of code (exceeds 250 allowed). Consider refactoring.
Open

begin
  gem "redis", ">= 4.0.1"
  require "redis"
  require "redis/distributed"
rescue LoadError
Severity: Minor
Found in activesupport/lib/active_support/cache/redis_cache_store.rb - About 2 hrs to fix

    Method new_time has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

              def new_time(year, mon, mday, hour, min, sec, microsec, offset = nil)
                # Treat 0000-00-00 00:00:00 as nil.
                return if year.nil? || (year == 0 && mon == 0 && mday == 0)
    
                if offset
    Severity: Minor
    Found in activemodel/lib/active_model/type/helpers/time_value.rb - About 2 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 exec_stmt_and_free has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

              def exec_stmt_and_free(sql, name, binds, cache_stmt: false, async: false)
                sql = transform_query(sql)
                check_if_write_query(sql)
    
                mark_transaction_written_if_write(sql)

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

          def determine_template(options)
            keys = options.has_key?(:locals) ? options[:locals].keys : []
    
            if options.key?(:body)
              Template::Text.new(options[:body])
    Severity: Minor
    Found in actionview/lib/action_view/renderer/template_renderer.rb - About 2 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 parse_render_from_options has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

            def parse_render_from_options(options_hash)
              renders = []
              keys = options_hash.keys
    
              if (keys & RENDER_TYPE_KEYS).size < 1
    Severity: Minor
    Found in actionview/lib/action_view/render_parser/ripper_render_parser.rb - About 2 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

    Function insertFromPaste has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        insertFromPaste() {
          var _dataTransfer$files;
          const {
            dataTransfer
          } = this.event;
    Severity: Major
    Found in actiontext/app/assets/javascripts/trix.js - About 2 hrs to fix

      Class Errors has 25 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Errors
          include Enumerable
      
          extend Forwardable
      
      
      Severity: Minor
      Found in activemodel/lib/active_model/errors.rb - About 2 hrs to fix

        Class Base has 25 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class Base
              include Callbacks
              include PeriodicTimers
              include Streams
              include Naming
        Severity: Minor
        Found in actioncable/lib/action_cable/channel/base.rb - About 2 hrs to fix

          Class FlashHash has 25 methods (exceeds 20 allowed). Consider refactoring.
          Open

              class FlashHash
                include Enumerable
          
                def self.from_session_value(value) # :nodoc:
                  case value
          Severity: Minor
          Found in actionpack/lib/action_dispatch/middleware/flash.rb - About 2 hrs to fix

            Class ContentSecurityPolicy has 25 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class ContentSecurityPolicy
                class Middleware
                  def initialize(app)
                    @app = app
                  end
            Severity: Minor
            Found in actionpack/lib/action_dispatch/http/content_security_policy.rb - About 2 hrs to fix

              Class FormBuilder has 25 methods (exceeds 20 allowed). Consider refactoring.
              Open

                  class FormBuilder
                    include ModelNaming
              
                    # The methods which wrap a form helper call.
                    class_attribute :field_helpers, default: [
              Severity: Minor
              Found in actionview/lib/action_view/helpers/form_helper.rb - About 2 hrs to fix

                File errors.rb has 282 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                module ActiveRecord
                  # = Active Record Errors
                  #
                  # Generic Active Record exception class.
                  class ActiveRecordError < StandardError
                Severity: Minor
                Found in activerecord/lib/active_record/errors.rb - About 2 hrs to fix

                  Method yield_shares has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def yield_shares(purpose: nil, compatible: [], block_share: false)
                          loose_shares = previous_wait = nil
                          synchronize do
                            if loose_shares = @sharing.delete(Thread.current)
                              if previous_wait = @waiting[Thread.current]
                  Severity: Minor
                  Found in activesupport/lib/active_support/concurrency/share_lock.rb - About 2 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 validate_each has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def validate_each(record, attr_name, value, precision: Float::DIG, scale: nil)
                          unless is_number?(value, precision, scale)
                            record.errors.add(attr_name, :not_a_number, **filtered_options(value))
                            return
                          end
                  Severity: Minor
                  Found in activemodel/lib/active_model/validations/numericality.rb - About 2 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 assign_nested_attributes_for_one_to_one_association has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def assign_nested_attributes_for_one_to_one_association(association_name, attributes)
                          if attributes.respond_to?(:permitted?)
                            attributes = attributes.to_h
                          end
                  
                  
                  Severity: Minor
                  Found in activerecord/lib/active_record/nested_attributes.rb - About 2 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 build_where_clause has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def build_where_clause(opts, rest = []) # :nodoc:
                          opts = sanitize_forbidden_attributes(opts)
                  
                          if opts.is_a?(Array)
                            opts, *rest = opts
                  Severity: Minor
                  Found in activerecord/lib/active_record/relation/query_methods.rb - About 2 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 join_constraints has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                          def join_constraints(foreign_table, foreign_klass, join_type, alias_tracker)
                            joins = []
                            chain = []
                  
                            reflection.chain.each do |reflection|

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

                    def preview
                      if params[:path] == @preview.preview_name
                        @page_title = "Action Mailer Previews for #{@preview.preview_name}"
                        render action: "mailer"
                      else
                  Severity: Minor
                  Found in railties/lib/rails/mailers_controller.rb - About 2 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 form_tag_helper.rb has 281 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require "cgi"
                  require "action_view/helpers/content_exfiltration_prevention_helper"
                  require "action_view/helpers/url_helper"
                  require "action_view/helpers/text_helper"
                  require "active_support/core_ext/string/output_safety"
                  Severity: Minor
                  Found in actionview/lib/action_view/helpers/form_tag_helper.rb - About 2 hrs to fix

                    Function handleRemoteWithRails has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      const handleRemoteWithRails = rails => function(e) {
                        let data, method, url;
                        const element = this;
                        if (!isRemote(element)) {
                          return true;
                    Severity: Major
                    Found in actionview/app/assets/javascripts/rails-ujs.js - About 2 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language