Showing 1,828 of 1,828 total issues

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

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

const formSubmitButtonClick = function(e) {
  const button = this;
  const {form: form} = button;
  if (!form) {
    return;
Severity: Major
Found in actionview/app/assets/javascripts/rails-ujs.esm.js and 1 other location - About 4 hrs to fix
actionview/app/assets/javascripts/rails-ujs.js on lines 494..509

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

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

  const formSubmitButtonClick = function(e) {
    const button = this;
    const {form: form} = button;
    if (!form) {
      return;
Severity: Major
Found in actionview/app/assets/javascripts/rails-ujs.js and 1 other location - About 4 hrs to fix
actionview/app/assets/javascripts/rails-ujs.esm.js on lines 545..560

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

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 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 application.rb has 361 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "yaml"
    require "active_support/core_ext/hash/keys"
    require "active_support/core_ext/object/blank"
    require "active_support/key_generator"
    require "active_support/message_verifiers"
    Severity: Minor
    Found in railties/lib/rails/application.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

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

        const delegate = (element, selector, eventType, handler) => element.addEventListener(eventType, (function(e) {
          let {target: target} = e;
          while (!!(target instanceof Element) && !matches(target, selector)) {
            target = target.parentNode;
          }
        Severity: Major
        Found in actionview/app/assets/javascripts/rails-ujs.esm.js and 1 other location - About 4 hrs to fix
        actionview/app/assets/javascripts/rails-ujs.js on lines 217..226

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

        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

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

          const delegate = (element, selector, eventType, handler) => element.addEventListener(eventType, (function(e) {
            let {target: target} = e;
            while (!!(target instanceof Element) && !matches(target, selector)) {
              target = target.parentNode;
            }
        Severity: Major
        Found in actionview/app/assets/javascripts/rails-ujs.js and 1 other location - About 4 hrs to fix
        actionview/app/assets/javascripts/rails-ujs.esm.js on lines 248..257

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

        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

        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

            Severity
            Category
            Status
            Source
            Language