railties/lib/rails/generators/generated_attribute.rb

Summary

Maintainability
B
5 hrs
Test Coverage

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

    class GeneratedAttribute # :nodoc:
      INDEX_OPTIONS = %w(index uniq)
      UNIQ_INDEX_OPTIONS = %w(uniq)
      DEFAULT_TYPES = %w(
        attachment
Severity: Minor
Found in railties/lib/rails/generators/generated_attribute.rb - About 3 hrs to fix

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

            def parse(column_definition)
              name, type, index_type = column_definition.split(":")
    
              # if user provided "name:index" instead of "name:string:index"
              # type should be set blank so GeneratedAttribute's constructor
    Severity: Minor
    Found in railties/lib/rails/generators/generated_attribute.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

    Avoid too many return statements within this method.
    Open

                  return type, {}
    Severity: Major
    Found in railties/lib/rails/generators/generated_attribute.rb - About 30 mins to fix

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

              def print_attribute_options
                if attr_options.empty?
                  ""
                elsif attr_options[:size]
                  "{#{attr_options[:size]}}"
      Severity: Minor
      Found in railties/lib/rails/generators/generated_attribute.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