Repository: rails/rails
File: railties/lib/rails/code_statistics.rb (Ruby)

Code before:
      %w(Mailbox\ tests     test/mailboxes),
      %w(Channel\ tests     test/channels),
      %w(Integration\ tests test/integration),
      %w(System\ tests      test/system),
    ]

    TEST_TYPES = ["Controller tests",
                  "Helper tests",
                  "Model tests",
                  "Mailer tests",
                  "Mailbox tests",
                  "Channel tests",
                  "Job tests",
                  "Integration tests",
                  "System tests"]

    HEADERS = { lines: " Lines", code_lines: "   LOC", classes: "Classes", methods: "Methods" }

    EXTENSIONS = ["rb",
                  "js",
                  "ts",
                  "css",
                  "scss",
                  "coffee",
                  "rake",
                  "erb"]

    PATTERN = /^(?!\.).*?\.(#{EXTENSIONS.join("|")})$/

    class_attribute :directories, default: DIRECTORIES
    class_attribute :test_types, default: TEST_TYPES
    class_attribute :extensions, default: EXTENSIONS
    class_attribute :pattern, default: PATTERN

    # Add directories to the output of the <tt>bin/rails stats</tt> command.
    #
    #   Rails::CodeStatistics.register_directory("My Directory", "path/to/dir")
    #
    # For directories that contain test code, set the <tt>test_directory</tt> argument to true.
    #
    #   Rails::CodeStatistics.register_directory("Model specs", "spec/models", test_directory: true)
    def self.register_directory(label, path, test_directory: false)
      self.directories << [label, path]
      self.test_types << label if test_directory
    end

    # Add extensions to the output of the <tt>bin/rails stats</tt> command.
    #
    #   Rails::CodeStatistics.register_extension("txt")
    def self.register_extension(extension)
      self.extensions << extension

Review comment (suggestion):
```suggestion
    EXTENSIONS = %w[rb js ts css scss coffee rake erb]
```

Code after:
      %w(Mailbox\ tests     test/mailboxes),
      %w(Channel\ tests     test/channels),
      %w(Integration\ tests test/integration),
      %w(System\ tests      test/system),
    ]

    TEST_TYPES = ["Controller tests",
                  "Helper tests",
                  "Model tests",
                  "Mailer tests",
                  "Mailbox tests",
                  "Channel tests",
                  "Job tests",
                  "Integration tests",
                  "System tests"]

    HEADERS = { lines: " Lines", code_lines: "   LOC", classes: "Classes", methods: "Methods" }

    EXTENSIONS = %w[rb js ts css scss coffee rake erb]

    PATTERN = /^(?!\.).*?\.(#{EXTENSIONS.join("|")})$/

    class_attribute :directories, default: DIRECTORIES
    class_attribute :test_types, default: TEST_TYPES
    class_attribute :extensions, default: EXTENSIONS
    class_attribute :pattern, default: PATTERN

    # Add directories to the output of the <tt>bin/rails stats</tt> command.
    #
    #   Rails::CodeStatistics.register_directory("My Directory", "path/to/dir")
    #
    # For directories that contain test code, set the <tt>test_directory</tt> argument to true.
    #
    #   Rails::CodeStatistics.register_directory("Model specs", "spec/models", test_directory: true)
    def self.register_directory(label, path, test_directory: false)
      self.directories << [label, path]
      self.test_types << label if test_directory
    end

    # Add extensions to the output of the <tt>bin/rails stats</tt> command.
    #
    #   Rails::CodeStatistics.register_extension("txt")
    def self.register_extension(extension)
      self.extensions += [extension]
      self.pattern = /^(?!\.).*?\.(#{Regexp.union(extensions.map { |e| Regexp.escape(e) })})$/
    end

    def initialize(*pairs)
      @pairs      = pairs
      @statistics = calculate_statistics
      @total      = calculate_total if pairs.length > 1