Rubocop: FrozenStringLiteralComment: Autocorrect not working

Created on 18 Jul 2020  路  2Comments  路  Source: rubocop-hq/rubocop

Expected behavior

Given the test file

puts 'Hello'

when using RuboCop defaults
and running

$ rubocop -a test.rb

then it should insert a frozen string literal comment.

Actual behavior

The test file is left unchanged. Output:

$ rubocop -a test.rb
Inspecting 1 file
C

Offenses:

test.rb:1:1: C: Style/FrozenStringLiteralComment: Missing frozen string literal comment.
puts 'Hello'
^

1 file inspected, 1 offense detected

RuboCop version

$ [bundle exec] rubocop -V
0.88.0 (using Parser 2.7.1.4, rubocop-ast 0.1.0, running on ruby 2.5.8 x86_64-linux)

Most helpful comment

It would be nice if the potentially correctable offenses was shown; I opened #8362

All 2 comments

The rubocop -a option behaviour has been changed from RuboCop 0.87.
https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md#changes-2

Can you use rubocop -A or rubocop --auto-correct-all instead, for Style/FrozenStringLiteralComment unsafe cop?
https://docs.rubocop.org/rubocop/0.88/usage/auto_correct.html

Thank you.

It would be nice if the potentially correctable offenses was shown; I opened #8362

Was this page helpful?
0 / 5 - 0 ratings