railties/lib/rails/generators/app_base.rb

Summary

Maintainability
F
3 days
Test Coverage

Class AppBase has 72 methods (exceeds 20 allowed). Consider refactoring.
Open

    class AppBase < Base # :nodoc:
      include Database
      include Devcontainer
      include AppName

Severity: Major
Found in railties/lib/rails/generators/app_base.rb - About 1 day to fix

    File app_base.rb has 565 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "fileutils"
    require "digest/md5"
    require "rails/version" unless defined?(Rails::VERSION)
    require "open-uri"
    require "tsort"
    Severity: Major
    Found in railties/lib/rails/generators/app_base.rb - About 1 day to fix

      Method add_shared_options_for has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def self.add_shared_options_for(name)
              class_option :name,                type: :string, aliases: "-n",
                                                 desc: "Name of the app"
      
              class_option :template,            type: :string, aliases: "-m",
      Severity: Major
      Found in railties/lib/rails/generators/app_base.rb - About 2 hrs to fix

        Method deduce_implied_options has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def deduce_implied_options(options, option_reasons, meta_options)
                active = options.transform_values { |value| [] if value }.compact
                irrevocable = (active.keys - meta_options).to_set
        
                deduction_order = TSort.tsort(
        Severity: Minor
        Found in railties/lib/rails/generators/app_base.rb - About 1 hr 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 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                def initialize(name, version, comment, options = {}, commented_out = false)
        Severity: Minor
        Found in railties/lib/rails/generators/app_base.rb - About 35 mins to fix

          Method css_gemfile_entry has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def css_gemfile_entry
                  return if options[:api]
                  return unless options[:css]
          
                  if !using_js_runtime? && options[:css] == "tailwind"
          Severity: Minor
          Found in railties/lib/rails/generators/app_base.rb - About 35 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 run_css has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def run_css
                  return if !options[:css] || !bundle_install?
          
                  if !using_js_runtime? && options[:css] == "tailwind"
                    rails_command "tailwindcss:install"
          Severity: Minor
          Found in railties/lib/rails/generators/app_base.rb - About 25 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

          There are no issues that match your filters.

          Category
          Status