railties/lib/rails/generators/base.rb

Summary

Maintainability
C
7 hrs
Test Coverage

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

    class Base < Thor::Group
      include Thor::Actions
      include Rails::Generators::Actions

      class_option :skip_namespace, type: :boolean, default: false,
Severity: Minor
Found in railties/lib/rails/generators/base.rb - About 3 hrs to fix

    Method class_collisions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def class_collisions(*class_names)
              return unless behavior == :invoke
              return if options.skip_collision_check?
              return if options.force?
    
    
    Severity: Minor
    Found in railties/lib/rails/generators/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 hook_for has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.hook_for(*names, &block)
            options = names.extract_options!
            in_base = options.delete(:in) || base_name
            as_hook = options.delete(:as) || generator_name
    
    
    Severity: Minor
    Found in railties/lib/rails/generators/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 prepare_for_invocation has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

            def self.prepare_for_invocation(name, value) # :nodoc:
              return super unless value.is_a?(String) || value.is_a?(Symbol)
    
              if value && constants = hooks[name]
                value = name if TrueClass === value
    Severity: Minor
    Found in railties/lib/rails/generators/base.rb - About 55 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 inherited has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.inherited(base) # :nodoc:
            super
    
            # Invoke source_root so the default_source_root is set.
            base.source_root
    Severity: Minor
    Found in railties/lib/rails/generators/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

    Method default_source_root has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.default_source_root
            return unless base_name && generator_name
            return unless default_generator_root
            path = File.join(default_generator_root, "templates")
            path if File.exist?(path)
    Severity: Minor
    Found in railties/lib/rails/generators/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