I have a library of ruby code, and to look for defects I run
$ rubocop
And I get
$ rubocop
Inspecting 153 files
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCWCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCWCCCCCCCWWCCCCC
Offenses:
Gemfile:1:1: C: Missing magic comment # frozen_string_literal: true.
source "https://rubygems.org"
What modifications are required in my Gemfile to make rubocop not complain?
If you want to ignore it, add to your .rubocop.yml
Style/FrozenStringLiteralComment:
Enabled: false
But may be you want to know what "Magic comment" is, especially if you're using Ruby 2.x
Just add
# frozen_string_literal: true
to the first line of each Ruby file. Or run
rubocop -a
to allow Rubocop to fix all offenses automatically that it is able to fix.
Btw. I like Rubocop and use it myself, but I wouldn't call the things it finds defects. I see the list more like suggestions or reasons for a discussion with my co-workers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With