Showing 1,828 of 1,828 total issues

Method find_offset has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

        def find_offset(compiled, source_tokens, error_column)
          compiled = StringScanner.new(compiled)

          passed_tokens = []

Severity: Minor
Found in actionview/lib/action_view/template/handlers/erb.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_calls has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

      def render_calls
        queue = [Prism.parse(@code).value]
        templates = []

        while (node = queue.shift)
Severity: Minor
Found in actionview/lib/action_view/render_parser/prism_render_parser.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 distance_of_time_in_words has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

      def distance_of_time_in_words(from_time, to_time = 0, options = {})
        options = {
          scope: :'datetime.distance_in_words'
        }.merge!(options)

Severity: Minor
Found in actionview/lib/action_view/helpers/date_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

File fanout.rb has 350 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "concurrent/map"
require "set"
require "active_support/core_ext/object/try"

module ActiveSupport
Severity: Minor
Found in activesupport/lib/active_support/notifications/fanout.rb - About 4 hrs to fix

    File response.rb has 350 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "active_support/core_ext/module/attribute_accessors"
    require "action_dispatch/http/filter_redirect"
    require "action_dispatch/http/cache"
    require "monitor"
    
    
    Severity: Minor
    Found in actionpack/lib/action_dispatch/http/response.rb - About 4 hrs to fix

      Class Engine has 34 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Engine < Railtie
          autoload :Configuration, "rails/engine/configuration"
      
          class << self
            attr_accessor :called_from, :isolated
      Severity: Minor
      Found in railties/lib/rails/engine.rb - About 4 hrs to fix

        Method compute_asset_host has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

              def compute_asset_host(source = "", options = {})
                request = self.request if respond_to?(:request)
                host = options[:host]
                host ||= config.asset_host if defined? config.asset_host
        
        
        Severity: Minor
        Found in actionview/lib/action_view/helpers/asset_url_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

        Class RouteSet has 33 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class RouteSet
              # Since the router holds references to many parts of the system like engines,
              # controllers and the application itself, inspecting the route set can actually
              # be really slow, therefore we default alias inspect to to_s.
              alias inspect to_s
        Severity: Minor
        Found in actionpack/lib/action_dispatch/routing/route_set.rb - About 4 hrs to fix

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

          var allowAction = function(element, rails) {
            let callback;
            const message = element.getAttribute("data-confirm");
            if (!message) {
              return true;
          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 281..295

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

          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 allowAction = function(element, rails) {
              let callback;
              const message = element.getAttribute("data-confirm");
              if (!message) {
                return true;
          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 318..332

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

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

              def to_tag(key, value, options)
                type_name = options.delete(:type)
                merged_options = options.merge(root: key, skip_instruct: true)
          
                if value.is_a?(::Method) || value.is_a?(::Proc)
          Severity: Minor
          Found in activesupport/lib/active_support/xml_mini.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 jobs_with has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

                def jobs_with(jobs, only: nil, except: nil, queue: nil, at: nil)
                  validate_option(only: only, except: except)
          
                  jobs.dup.select do |job|
                    job_class = job.fetch(:job)
          Severity: Minor
          Found in activejob/lib/active_job/test_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

          Method type_to_sql has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

                def type_to_sql(type, limit: nil, precision: nil, scale: nil, **) # :nodoc:
                  type = type.to_sym if type
                  if native = native_database_types[type]
                    column_type_sql = (native.is_a?(Hash) ? native[:name] : native).dup
          
          

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

                def _enum(name, values, prefix: nil, suffix: nil, scopes: true, instance_methods: true, validate: false, **options)
                  assert_valid_enum_definition_values(values)
                  # statuses = { }
                  enum_values = ActiveSupport::HashWithIndifferentAccess.new
                  name = name.to_s
          Severity: Minor
          Found in activerecord/lib/active_record/enum.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 merge_and_normalize_cache_control! has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

                  def merge_and_normalize_cache_control!(cache_control)
                    control = cache_control_headers
          
                    return if control.empty? && cache_control.empty?  # Let middleware handle default behavior
          
          
          Severity: Minor
          Found in actionpack/lib/action_dispatch/http/cache.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 associations.rb has 334 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module ActiveRecord
            class AssociationNotFoundError < ConfigurationError # :nodoc:
              attr_reader :record, :association_name
          
              def initialize(record = nil, association_name = nil)
          Severity: Minor
          Found in activerecord/lib/active_record/associations.rb - About 4 hrs to fix

            Method generate has 100 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def generate(owner, methods, location: nil, to: nil, prefix: nil, allow_nil: nil, nilable: true, private: nil, as: nil, signature: nil)
                    unless to
                      raise ArgumentError, "Delegation needs a target. Supply a keyword argument 'to' (e.g. delegate :hello, to: :greeter)."
                    end
            
            
            Severity: Major
            Found in activesupport/lib/active_support/delegation.rb - About 4 hrs to fix

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

                    tab(event) {
                      var _this$responder28;
                      if ((_this$responder28 = this.responder) !== null && _this$responder28 !== void 0 && _this$responder28.canDecreaseNestingLevel()) {
                        var _this$responder29;
                        (_this$responder29 = this.responder) === null || _this$responder29 === void 0 || _this$responder29.decreaseNestingLevel();
              Severity: Major
              Found in actiontext/app/assets/javascripts/trix.js and 1 other location - About 4 hrs to fix
              actiontext/app/assets/javascripts/trix.js on lines 10167..10175

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

              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

                  tab(event) {
                    var _this$responder22;
                    if ((_this$responder22 = this.responder) !== null && _this$responder22 !== void 0 && _this$responder22.canIncreaseNestingLevel()) {
                      var _this$responder23;
                      (_this$responder23 = this.responder) === null || _this$responder23 === void 0 || _this$responder23.increaseNestingLevel();
              Severity: Major
              Found in actiontext/app/assets/javascripts/trix.js and 1 other location - About 4 hrs to fix
              actiontext/app/assets/javascripts/trix.js on lines 10219..10227

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

              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

                  ArrowLeft() {
                    var _this$responder14;
                    if ((_this$responder14 = this.responder) !== null && _this$responder14 !== void 0 && _this$responder14.shouldManageMovingCursorInDirection("backward")) {
                      var _this$responder15;
                      this.event.preventDefault();
              Severity: Major
              Found in actiontext/app/assets/javascripts/trix.js and 1 other location - About 3 hrs to fix
              actiontext/app/assets/javascripts/trix.js on lines 10663..10670

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

              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