Class: RuboCop::Cop::Crystal::FileExtension
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Crystal::FileExtension
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/crystal/file_extension.rb
Overview
Non-executable ruby files commonly have an extension of ‘.rb`. The equivalent crystal files have an extension of `.cr`.
Constant Summary collapse
- MSG =
'Crystal files have `.cr` extensions, while Ruby files have `.rb` extensions.'
Instance Method Summary collapse
Instance Method Details
#on_new_investigation ⇒ Object
18 19 20 21 22 23 |
# File 'lib/rubocop/cop/crystal/file_extension.rb', line 18 def on_new_investigation return unless File.extname(processed_source.file_path) == '.rb' add_global_offense File.rename(processed_source.file_path, File.join(File.dirname(processed_source.file_path), "#{File.basename(processed_source.file_path, '.rb')}.cr")) if autocorrect_requested? end |