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

**URL:** <https://forum.devtalk.com/t/programming-ruby-3-2-5th-edition-b2-0-page-355-autocorrection-needs-two-passes/95532>\
**Category:** PragProg Customers\
**Tags:** suggestion, book-programming-ruby-3-2-5th-edition\
**Created:** [8 February 2023 12:51 UTC](https://forum.devtalk.com/t/programming-ruby-3-2-5th-edition-b2-0-page-355-autocorrection-needs-two-passes/95532 "2023-02-08T12:51:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BernardK](https://forum.devtalk.com/letter_avatar_proxy/v4/letter/b/a5b964/32.png) [@BernardK](https://forum.devtalk.com/u/BernardK)\
**Post date:** [8 February 2023 12:51 UTC](https://forum.devtalk.com/t/programming-ruby-3-2-5th-edition-b2-0-page-355-autocorrection-needs-two-passes/95532/1 "2023-02-08T12:51:25Z")

</div>

@noelrappin

page 355, paragraph 3, line 2 :

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

```

This seems correct looking at the report :

```auto
% 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`_ " :

```auto
% 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`

```auto
% 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`

---

<div class="post-metadata">

**Author:** ![noelrappin](https://forum.devtalk.com/user_avatar/forum.devtalk.com/noelrappin/32/481_2.png) [@noelrappin](https://forum.devtalk.com/u/noelrappin)\
**Post date:** [20 February 2023 19:44 UTC](https://forum.devtalk.com/t/programming-ruby-3-2-5th-edition-b2-0-page-355-autocorrection-needs-two-passes/95532/2 "2023-02-20T19:44:42Z")

</div>

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