Showing 1,828 of 1,828 total issues

Method expand_from_hash has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

      def expand_from_hash(attributes, &block)
        return ["1=0"] if attributes.empty?

        attributes.flat_map do |key, value|
          if key.is_a?(Array)
Severity: Minor
Found in activerecord/lib/active_record/relation/predicate_builder.rb - About 7 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

class Subscription {
  constructor(consumer, params = {}, mixin) {
    this.consumer = consumer;
    this.identifier = JSON.stringify(params);
    extend(this, mixin);
Severity: Major
Found in actioncable/app/assets/javascripts/actioncable.esm.js and 2 other locations - About 7 hrs to fix
actioncable/app/assets/javascripts/action_cable.js on lines 310..330
actioncable/app/assets/javascripts/actioncable.js on lines 310..330

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

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

  class Subscription {
    constructor(consumer, params = {}, mixin) {
      this.consumer = consumer;
      this.identifier = JSON.stringify(params);
      extend(this, mixin);
Severity: Major
Found in actioncable/app/assets/javascripts/action_cable.js and 2 other locations - About 7 hrs to fix
actioncable/app/assets/javascripts/actioncable.esm.js on lines 320..340
actioncable/app/assets/javascripts/actioncable.js on lines 310..330

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

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

  class Subscription {
    constructor(consumer, params = {}, mixin) {
      this.consumer = consumer;
      this.identifier = JSON.stringify(params);
      extend(this, mixin);
Severity: Major
Found in actioncable/app/assets/javascripts/actioncable.js and 2 other locations - About 7 hrs to fix
actioncable/app/assets/javascripts/action_cable.js on lines 310..330
actioncable/app/assets/javascripts/actioncable.esm.js on lines 320..340

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

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

File date_helper.rb has 459 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "date"
require "action_view/helpers/tag_helper"
require "active_support/core_ext/array/extract_options"
require "active_support/core_ext/date/conversions"
require "active_support/core_ext/hash/slice"
Severity: Minor
Found in actionview/lib/action_view/helpers/date_helper.rb - About 7 hrs to fix

    File persistence.rb has 453 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "active_record/insert_all"
    
    module ActiveRecord
      # = Active Record \Persistence
      module Persistence
    Severity: Minor
    Found in activerecord/lib/active_record/persistence.rb - About 6 hrs to fix

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

      function handleFormSubmissionEvent(event) {
        const form = event.target
      
        if (form.hasAttribute(processingAttribute)) {
          event.preventDefault()
      Severity: Major
      Found in activestorage/app/javascript/activestorage/ujs.js and 4 other locations - About 6 hrs to fix
      actiontext/app/assets/javascripts/actiontext.esm.js on lines 790..811
      actiontext/app/assets/javascripts/actiontext.js on lines 769..790
      activestorage/app/assets/javascripts/activestorage.esm.js on lines 790..811
      activestorage/app/assets/javascripts/activestorage.js on lines 770..791

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

      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 5 locations. Consider refactoring.
      Open

        function handleFormSubmissionEvent(event) {
          const form = event.target;
          if (form.hasAttribute(processingAttribute)) {
            event.preventDefault();
            return;
      Severity: Major
      Found in activestorage/app/assets/javascripts/activestorage.js and 4 other locations - About 6 hrs to fix
      actiontext/app/assets/javascripts/actiontext.esm.js on lines 790..811
      actiontext/app/assets/javascripts/actiontext.js on lines 769..790
      activestorage/app/assets/javascripts/activestorage.esm.js on lines 790..811
      activestorage/app/javascript/activestorage/ujs.js on lines 34..58

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

      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 5 locations. Consider refactoring.
      Open

        function handleFormSubmissionEvent(event) {
          const form = event.target;
          if (form.hasAttribute(processingAttribute)) {
            event.preventDefault();
            return;
      Severity: Major
      Found in actiontext/app/assets/javascripts/actiontext.js and 4 other locations - About 6 hrs to fix
      actiontext/app/assets/javascripts/actiontext.esm.js on lines 790..811
      activestorage/app/assets/javascripts/activestorage.esm.js on lines 790..811
      activestorage/app/assets/javascripts/activestorage.js on lines 770..791
      activestorage/app/javascript/activestorage/ujs.js on lines 34..58

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

      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 5 locations. Consider refactoring.
      Open

      function handleFormSubmissionEvent(event) {
        const form = event.target;
        if (form.hasAttribute(processingAttribute)) {
          event.preventDefault();
          return;
      Severity: Major
      Found in activestorage/app/assets/javascripts/activestorage.esm.js and 4 other locations - About 6 hrs to fix
      actiontext/app/assets/javascripts/actiontext.esm.js on lines 790..811
      actiontext/app/assets/javascripts/actiontext.js on lines 769..790
      activestorage/app/assets/javascripts/activestorage.js on lines 770..791
      activestorage/app/javascript/activestorage/ujs.js on lines 34..58

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

      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 5 locations. Consider refactoring.
      Open

      function handleFormSubmissionEvent(event) {
        const form = event.target;
        if (form.hasAttribute(processingAttribute)) {
          event.preventDefault();
          return;
      Severity: Major
      Found in actiontext/app/assets/javascripts/actiontext.esm.js and 4 other locations - About 6 hrs to fix
      actiontext/app/assets/javascripts/actiontext.js on lines 769..790
      activestorage/app/assets/javascripts/activestorage.esm.js on lines 790..811
      activestorage/app/assets/javascripts/activestorage.js on lines 770..791
      activestorage/app/javascript/activestorage/ujs.js on lines 34..58

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

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

            def save_collection_association(reflection)
              if association = association_instance_get(reflection.name)
                autosave = reflection.options[:autosave]
      
                # By saving the instance variable in a local variable,
      Severity: Minor
      Found in activerecord/lib/active_record/autosave_association.rb - About 6 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 cookies.rb has 436 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require "active_support/core_ext/hash/keys"
      require "active_support/key_generator"
      require "active_support/message_verifier"
      require "active_support/json"
      require "rack/utils"
      Severity: Minor
      Found in actionpack/lib/action_dispatch/middleware/cookies.rb - About 6 hrs to fix

        Class Response has 46 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Response
            begin
              # For `Rack::Headers` (Rack 3+):
              require "rack/headers"
              Headers = ::Rack::Headers
        Severity: Minor
        Found in actionpack/lib/action_dispatch/http/response.rb - About 6 hrs to fix

          Class PluginGenerator has 46 methods (exceeds 20 allowed). Consider refactoring.
          Open

              class PluginGenerator < AppBase # :nodoc:
                add_shared_options_for "plugin"
          
                alias_method :plugin_path, :app_path
          
          
          Severity: Minor
          Found in railties/lib/rails/generators/rails/plugin/plugin_generator.rb - About 6 hrs to fix

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

            const isCrossDomain = function(url) {
              const originAnchor = document.createElement("a");
              originAnchor.href = location.href;
              const urlAnchor = document.createElement("a");
              try {
            Severity: Major
            Found in actionview/app/assets/javascripts/rails-ujs.esm.js and 1 other location - About 6 hrs to fix
            actionview/app/assets/javascripts/rails-ujs.js on lines 169..179

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

            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 isCrossDomain = function(url) {
                const originAnchor = document.createElement("a");
                originAnchor.href = location.href;
                const urlAnchor = document.createElement("a");
                try {
            Severity: Major
            Found in actionview/app/assets/javascripts/rails-ujs.js and 1 other location - About 6 hrs to fix
            actionview/app/assets/javascripts/rails-ujs.esm.js on lines 194..204

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

            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

            File form_helper.rb has 424 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require "cgi"
            require "action_view/helpers/date_helper"
            require "action_view/helpers/url_helper"
            require "action_view/helpers/form_tag_helper"
            require "action_view/helpers/active_model_helper"
            Severity: Minor
            Found in actionview/lib/action_view/helpers/form_helper.rb - About 6 hrs to fix

              Function constructor has 154 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  constructor(attachmentPiece, _element, container) {
                    let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
                    super(...arguments);
                    // Installing and uninstalling
                    _defineProperty(this, "makeElementMutable", undoable(() => {
              Severity: Major
              Found in actiontext/app/assets/javascripts/trix.js - About 6 hrs to fix

                Class Store has 44 methods (exceeds 20 allowed). Consider refactoring.
                Open

                    class Store
                      cattr_accessor :logger, instance_writer: true
                      cattr_accessor :raise_on_invalid_cache_expiration_time, default: false
                
                      attr_reader :silence, :options
                Severity: Minor
                Found in activesupport/lib/active_support/cache.rb - About 6 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language