Showing 1,823 of 1,823 total issues

Method initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def initialize(*)
          super

          if tag_value = @options[:placeholder]
            placeholder = tag_value if tag_value.is_a?(String)
Severity: Minor
Found in actionview/lib/action_view/helpers/tags/placeholderable.rb - About 45 mins 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 _write_layout_method has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def _write_layout_method # :nodoc:
        silence_redefinition_of_method(:_layout)

        prefixes = /\blayouts/.match?(_implied_layout_name) ? [] : ["layouts"]
        default_behavior = "lookup_context.find_all('#{_implied_layout_name}', #{prefixes.inspect}, false, [], { formats: formats }).first || super"
Severity: Minor
Found in actionview/lib/action_view/layouts.rb - About 45 mins 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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def initialize(object_name, method_name, template_object, checked_value, unchecked_value, options)
Severity: Minor
Found in actionview/lib/action_view/helpers/tags/check_box.rb - About 45 mins to fix

    Method method_for_options has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def method_for_options(options)
              if options.is_a?(Array)
                method_for_options(options.last)
              elsif options.respond_to?(:persisted?)
                options.persisted? ? :patch : :post
    Severity: Minor
    Found in actionview/lib/action_view/helpers/url_helper.rb - About 45 mins 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 option_groups_from_collection_for_select has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def option_groups_from_collection_for_select(collection, group_method, group_label_method, option_key_method, option_value_method, selected_key = nil)
    Severity: Minor
    Found in actionview/lib/action_view/helpers/form_options_helper.rb - About 45 mins to fix

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

            def apply_form_for_options!(object, options) # :nodoc:
              object = convert_to_model(object)
      
              as = options[:as]
              namespace = options[:namespace]
      Severity: Minor
      Found in actionview/lib/action_view/helpers/form_helper.rb - About 45 mins 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 has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def select(object, method, choices = nil, options = {}, html_options = {}, &block)
      Severity: Minor
      Found in actionview/lib/action_view/helpers/form_options_helper.rb - About 45 mins to fix

        Method collection_select has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
        Severity: Minor
        Found in actionview/lib/action_view/helpers/form_options_helper.rb - About 45 mins to fix

          Method run_generator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def run_generator(args = default_arguments, config = {})
                    args += ["--skip-bundle"] unless args.include?("--no-skip-bundle") || args.include?("--dev")
                    args += ["--skip-bootsnap"] unless args.include?("--no-skip-bootsnap") || args.include?("--skip-bootsnap")
          
                    if ENV["RAILS_LOG_TO_STDOUT"] == "true"
          Severity: Minor
          Found in railties/lib/rails/generators/testing/behavior.rb - About 45 mins 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 log has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def log(*args) # :doc:
                    if args.size == 1
                      say args.first.to_s unless options.quiet?
                    else
                      args << (behavior == :invoke ? :green : :red)
          Severity: Minor
          Found in railties/lib/rails/generators/actions.rb - About 45 mins 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 invoke_fallbacks_for has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def invoke_fallbacks_for(name, base)
                    return nil unless base && fallbacks[base.to_sym]
                    invoked_fallbacks = []
          
                    Array(fallbacks[base.to_sym]).each do |fallback|
          Severity: Minor
          Found in railties/lib/rails/generators.rb - About 45 mins 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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def initialize(root, current, paths, options = {})
                  @paths   = paths
                  @current = current
                  @root    = root
                  @glob    = options[:glob]
          Severity: Minor
          Found in railties/lib/rails/paths.rb - About 45 mins 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

          Avoid deeply nested control flow statements.
          Open

                      render plain: part.respond_to?(:decoded) ? part.decoded : part
          Severity: Major
          Found in railties/lib/rails/mailers_controller.rb - About 45 mins to fix

            Method perform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def perform
                    set_application_directory!
                    prepare_restart
            
                    Rails::Server.new(server_options).tap do |server|
            Severity: Minor
            Found in railties/lib/rails/commands/server/server_command.rb - About 45 mins 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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def initialize
                  super
                  add_filter do |line|
                    # We may be called before Rails.root is assigned.
                    # When that happens we fallback to not truncating.
            Severity: Minor
            Found in railties/lib/rails/backtrace_cleaner.rb - About 45 mins 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 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def parse(paths, env:)
                    paths.each_with_object(Hash.new) do |path, all_secrets|
                      require "erb"
            
                      source = ERB.new(preprocess(path)).result
            Severity: Minor
            Found in railties/lib/rails/secrets.rb - About 45 mins 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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def initialize(args, *_options)
                    super
                    if plural_model_name?(name) && !options[:force_plural]
                      singular = name.singularize
                      unless ModelHelpers.skip_warn
            Severity: Minor
            Found in railties/lib/rails/generators/model_helpers.rb - About 45 mins 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 edit_compose_yaml has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                        def edit_compose_yaml
                          compose_yaml_path = File.expand_path(".devcontainer/compose.yaml", destination_root)
                          return unless File.exist?(compose_yaml_path)
            
                          compose_config = YAML.load_file(compose_yaml_path)
            Severity: Minor
            Found in railties/lib/rails/generators/rails/db/system/change/change_generator.rb - About 45 mins 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

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

                redo: {
                  test() {
                    return this.editor.canRedo();
                  },
                  perform() {
            Severity: Minor
            Found in actiontext/app/assets/javascripts/trix.js and 1 other location - About 45 mins to fix
            actiontext/app/assets/javascripts/trix.js on lines 11719..11726

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

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

                get name() {
                  var _this$inputElement2;
                  return (_this$inputElement2 = this.inputElement) === null || _this$inputElement2 === void 0 ? void 0 : _this$inputElement2.name;
                }
            Severity: Major
            Found in actiontext/app/assets/javascripts/trix.js and 3 other locations - About 45 mins to fix
            actiontext/app/assets/javascripts/trix.js on lines 11940..11943
            actiontext/app/assets/javascripts/trix.js on lines 11961..11964
            actiontext/app/assets/javascripts/trix.js on lines 11969..11972

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

            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