Showing 1,828 of 1,828 total issues

Method translate has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

      def translate(key, **options)
        return key.map { |k| translate(k, **options) } if key.is_a?(Array)
        key = key&.to_s unless key.is_a?(Symbol)

        alternatives = if options.key?(:default)
Severity: Minor
Found in actionview/lib/action_view/helpers/translation_helper.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

Class Attribute has 30 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Attribute # :nodoc:
    class << self
      def from_database(name, value_before_type_cast, type, value = nil)
        FromDatabase.new(name, value_before_type_cast, type, nil, value)
      end
Severity: Minor
Found in activemodel/lib/active_model/attribute.rb - About 3 hrs to fix

    Class RedisCacheStore has 30 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class RedisCacheStore < Store
          # Keys are truncated with the Active Support digest if they exceed 1kB
          MAX_KEY_BYTESIZE = 1024
    
          DEFAULT_REDIS_OPTIONS = {
    Severity: Minor
    Found in activesupport/lib/active_support/cache/redis_cache_store.rb - About 3 hrs to fix

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

          class Base
            include Identification
            include InternalChannel
            include Authorization
            include Callbacks
      Severity: Minor
      Found in actioncable/lib/action_cable/connection/base.rb - About 3 hrs to fix

        Method tokenize has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.tokenize(source) # :nodoc:
              require "strscan"
              source = StringScanner.new(source.chomp)
              tokens = []
        
        
        Severity: Minor
        Found in activesupport/lib/active_support/core_ext/erb/util.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

        Method parse! has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

              def parse!
                while !finished?
                  case mode
                  when :start
                    if scan(SIGN_MARKER)
        Severity: Minor
        Found in activesupport/lib/active_support/duration/iso8601_parser.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 engine.rb has 313 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require "rails/railtie"
        require "rails/engine/railties"
        require "active_support/callbacks"
        require "active_support/core_ext/module/delegation"
        require "active_support/core_ext/object/try"
        Severity: Minor
        Found in railties/lib/rails/engine.rb - About 3 hrs to fix

          Method save_belongs_to_association has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

                def save_belongs_to_association(reflection)
                  association = association_instance_get(reflection.name)
                  return unless association && association.loaded? && !association.stale_target?
          
                  record = association.load_target
          Severity: Minor
          Found in activerecord/lib/active_record/autosave_association.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

          Method generate has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

                def generate(name, options, path_parameters)
                  original_options = options.dup
                  path_params = options.delete(:path_params) || {}
                  options = path_params.merge(options)
                  constraints = path_parameters.merge(options)
          Severity: Minor
          Found in actionpack/lib/action_dispatch/journey/formatter.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

          Method select_datetime has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

                def select_datetime
                  order = date_order.dup
                  order -= [:hour, :minute, :second]
                  @options[:discard_year]   ||= true unless order.include?(:year)
                  @options[:discard_month]  ||= true unless order.include?(:month)
          Severity: Minor
          Found in actionview/lib/action_view/helpers/date_helper.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

          Method stylesheet_link_tag has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

                def stylesheet_link_tag(*sources)
                  options = sources.extract_options!.stringify_keys
                  path_options = options.extract!("protocol", "extname", "host", "skip_pipeline").symbolize_keys
                  use_preload_links_header = options["preload_links_header"].nil? ? preload_links_header : options.delete("preload_links_header")
                  preload_links = []
          Severity: Minor
          Found in actionview/lib/action_view/helpers/asset_tag_helper.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

          Method javascript_include_tag has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

                def javascript_include_tag(*sources)
                  options = sources.extract_options!.stringify_keys
                  path_options = options.extract!("protocol", "extname", "host", "skip_pipeline").symbolize_keys
                  preload_links = []
                  use_preload_links_header = options["preload_links_header"].nil? ? preload_links_header : options.delete("preload_links_header")
          Severity: Minor
          Found in actionview/lib/action_view/helpers/asset_tag_helper.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

          Method find_in has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              def find_in(dir)
                results = {}
          
                Dir.glob("#{dir}/*") do |item|
                  next if File.basename(item).start_with?(".")
          Severity: Minor
          Found in railties/lib/rails/source_annotation_extractor.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

          Method database_configuration has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

                def database_configuration
                  path = paths["config/database"].existent.first
                  yaml = Pathname.new(path) if path
          
                  config = if yaml&.exist?
          Severity: Minor
          Found in railties/lib/rails/application/configuration.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

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

          var enableFormElement = function(element) {
            const originalText = getData(element, "ujs:enable-with");
            if (originalText != null) {
              if (matches(element, "button")) {
                element.innerHTML = originalText;
          Severity: Major
          Found in actionview/app/assets/javascripts/rails-ujs.esm.js and 1 other location - About 3 hrs to fix
          actionview/app/assets/javascripts/rails-ujs.js on lines 376..388

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

          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

          (function (global, factory) {
            typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
            typeof define === 'function' && define.amd ? define(factory) :
            (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Trix = factory());
          })(this, (function () { 'use strict';
          Severity: Major
          Found in actiontext/app/assets/javascripts/trix.js and 1 other location - About 3 hrs to fix
          actionview/app/assets/javascripts/rails-ujs.js on lines 6..630

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

          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

          (function(global, factory) {
            typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, 
            global.Rails = factory());
          })(this, (function() {
            "use strict";
          Severity: Major
          Found in actionview/app/assets/javascripts/rails-ujs.js and 1 other location - About 3 hrs to fix
          actiontext/app/assets/javascripts/trix.js on lines 5..12103

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

          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 enableFormElement = function(element) {
              const originalText = getData(element, "ujs:enable-with");
              if (originalText != null) {
                if (matches(element, "button")) {
                  element.innerHTML = originalText;
          Severity: Major
          Found in actionview/app/assets/javascripts/rails-ujs.js and 1 other location - About 3 hrs to fix
          actionview/app/assets/javascripts/rails-ujs.esm.js on lines 422..434

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

          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 Template has 28 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class Template
              extend ActiveSupport::Autoload
          
              STRICT_LOCALS_REGEX = /\#\s+locals:\s+\((.*)\)/
          
          
          Severity: Minor
          Found in actionview/lib/action_view/template.rb - About 3 hrs to fix

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

            (function(global, factory) {
              typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define([ "exports" ], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, 
              factory(global.ActiveStorage = {}));
            })(this, (function(exports) {
              "use strict";
            Severity: Major
            Found in activestorage/app/assets/javascripts/activestorage.js and 3 other locations - About 3 hrs to fix
            actioncable/app/assets/javascripts/action_cable.js on lines 1..511
            actioncable/app/assets/javascripts/actioncable.js on lines 1..510
            guides/assets/javascripts/@hotwired--turbo.js on lines 5..3938

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

            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

            Severity
            Category
            Status
            Source
            Language