What about Rubocop rules?

The first offense I don’t get. the shebang used is recommended and my .rb script executes

The second one I don’t get at all. what is Rubcop’s issue here ?

The next three I get, but should I fix them or can I edit a Rubocop config file so these offences won’t be offences anymore.

The first one might be a windows/linux issue: on linux, you can chmod +x a script to make it executable, but that flag may not exist on windows.

The second one is a recommendation - it’s recommending you to use frozen strings, as that may become a default in future. See: https://rubydoc.info/gems/rubocop/RuboCop/Cop/Style/FrozenStringLiteralComment

There’s a config file: in the gems folder “/rubocop-0.82.0/config/default.yml” where you can edit out the things you don’t want checked.

e.g.find Style/StringLiterals and change the Enabled line to false.

(I think I got too set in my ways, as I don’t like most of the suggestions rubocop makes!)

I fixed them all. thanks.
So, the default Rubocop rules are too strict ?

The rules are, I think, based on this style guide: https://rubystyle.guide/

A lot of them are ‘down to taste’, and I have different preferences in many places:

  • I like having explicit returns from multi-line methods
  • I never liked the alternate literal hash syntax (why have a different syntax for a different data type?).
  • Double-quoted strings are more natural to me, from other languages, and you don’t have to change them when you later decide to do some interpolation.

etc.

But then I write ruby code for myself!

Lets see if I can find that Rubocop config file and take a look around.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs