Class: Lintress::MagicCommentResolution
- Inherits:
-
Resolution
- Object
- Resolution
- Lintress::MagicCommentResolution
- Defined in:
- lib/lintress/magic_comment_resolution.rb
Instance Method Summary collapse
Methods inherited from Resolution
Constructor Details
This class inherits a constructor from Lintress::Resolution
Instance Method Details
#transform ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/lintress/magic_comment_resolution.rb', line 5 def transform tmp_file = Dir.pwd + '/tmp.txt' offender = Dir.pwd + '/' + @offense.ofile # prepend "# frozen_string_literal: true\n\n" to file magic_comment = "# frozen_string_literal: true\n\n" # write out the file File.open tmp_file, 'w' do |f| f << magic_comment f << File.read(offender) end File.rename tmp_file, offender end |