BernardK

BernardK

Programming Ruby 3.2 (5th Edition): B2.0 page 355, autocorrection needs two passes

@noelrappin

page 355, paragraph 3, line 2 :

figuration or by running rubocop -a to auto correct (which will fix all but the first issue).
                                                             -----> ^^^

This seems correct looking at the report :

% rubocop              
Inspecting 13 files
..C...C......
...
13 files inspected, 4 offenses detected, 3 offenses auto-correctable

but is not fully true. In fact rubocop -a finds three new offenses in spec.metadata, corrects them but corrects only two of the three offenses declared previously as auto-correctable (aaagmnr.gemspec:5:1, 14:32, but not options.rb:11:26), saying "1 more offense can be corrected with `rubocop -A` " :

% rubocop -a           
Inspecting 13 files
..C...C......

Offenses:

aaagmnr.gemspec:5:1: C: [Corrected] Gemspec/RequireMFA: metadata['rubygems_mfa_required'] must be set to 'true'.
Gem::Specification.new do |spec| ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
aaagmnr.gemspec:14:32: C: Gemspec/RequiredRubyVersion: required_ruby_version and TargetRubyVersion (3.2, which may be specified in .rubocop.yml) should be equal.
  spec.required_ruby_version = ">= 2.6.0"
                               ^^^^^^^^^^
aaagmnr.gemspec:33:42: C: [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
  spec.add_dependency "date_by_example", '~> 0.1'
                                         ^^^^^^^^
aaagmnr.gemspec:34:1: C: [Corrected] Layout/IndentationConsistency: Inconsistent indentation detected.
spec.metadata['rubygems_mfa_required'] = 'true'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
aaagmnr.gemspec:34:15: C: [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
spec.metadata['rubygems_mfa_required'] = 'true'
              ^^^^^^^^^^^^^^^^^^^^^^^
aaagmnr.gemspec:34:42: C: [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
spec.metadata['rubygems_mfa_required'] = 'true'
                                         ^^^^^^
lib/aaagmnr/options.rb:11:26: C: [Correctable] Style/MutableConstant: Freeze mutable objects assigned to constants.
    DEFAULT_DICTIONARY = "/usr/share/dict/words"
                         ^^^^^^^^^^^^^^^^^^^^^^^

13 files inspected, 7 offenses detected, 5 offenses corrected, 1 more offense can be corrected with `rubocop -A`

A second pass with -A

% rubocop -A           
Inspecting 13 files
..C...C......

Offenses:

aaagmnr.gemspec:14:32: C: Gemspec/RequiredRubyVersion: required_ruby_version and TargetRubyVersion (3.2, which may be specified in .rubocop.yml) should be equal.
  spec.required_ruby_version = ">= 2.6.0"
                               ^^^^^^^^^^
lib/aaagmnr/options.rb:11:26: C: [Corrected] Style/MutableConstant: Freeze mutable objects assigned to constants.
    DEFAULT_DICTIONARY = "/usr/share/dict/words"
                         ^^^^^^^^^^^^^^^^^^^^^^^

13 files inspected, 2 offenses detected, 1 offense corrected

has corrected options.rb by adding freeze :

DEFAULT_DICTIONARY = "/usr/share/dict/words".freeze

First Post!

noelrappin

noelrappin

Author of Modern Front-End Development for Rails

Okay that’s true, and I’ve cleaned up the text to better reflect the reality.

Where Next?

Popular Pragmatic Bookshelf topics Top

New
brianokken
Many tasks_proj/tests directories exist in chapters 2, 3, 5 that have tests that use the custom markers smoke and get, which are not decl...
New
simonpeter
When I try the command to create a pair of migration files I get an error. user=> (create-migration "guestbook") Execution error (Ill...
New
herminiotorres
Hi @Margaret , On page VII the book tells us the example and snippets will be all using Elixir version 1.11 But on page 3 almost the en...
New
patoncrispy
I’m new to Rust and am using this book to learn more as well as to feed my interest in game dev. I’ve just finished the flappy dragon exa...
New
jgchristopher
“The ProductLive.Index template calls a helper function, live_component/3, that in turn calls on the modal component. ” Excerpt From: Br...
New
digitalbias
Title: Build a Weather Station with Elixir and Nerves: Problem connecting to Postgres with Grafana on (page 64) If you follow the defau...
New
tkhobbes
After some hassle, I was able to finally run bin/setup, now I have started the rails server but I get this error message right when I vis...
New
a.zampa
@mfazio23 I’m following the indications of the book and arriver ad chapter 10, but the app cannot be compiled due to an error in the Bas...
New
dtonhofer
@parrt In the context of Chapter 4.3, the grammar Java.g4, meant to parse Java 6 compilation units, no longer passes ANTLR (currently 4....
New

Other popular topics Top

New
AstonJ
Curious to know which languages and frameworks you’re all thinking about learning next :upside_down_face: Perhaps if there’s enough peop...
New
Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New
AstonJ
Was just curious to see if any were around, found this one: I got 51/100: Not sure if it was meant to buy I am sure at times the b...
New
New
husaindevelop
Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
New
hilfordjames
There appears to have been an update that has changed the terminology for what has previously been known as the Taskbar Overflow - this h...
New
First poster: bot
zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig. General-purpose programming language and toolchain for maintaini...
New
sir.laksmana_wenk
I’m able to do the “artistic” part of game-development; character designing/modeling, music, environment modeling, etc. However, I don’t...
New
AstonJ
This is a very quick guide, you just need to: Download LM Studio: https://lmstudio.ai/ Click on search Type DeepSeek, then select the o...
New

Sub Categories: