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