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

jon
Some minor things in the paper edition that says “3 2020” on the title page verso, not mentioned in the book’s errata online: p. 186 But...
New
belgoros
Following the steps described in Chapter 6 of the book, I’m stuck with running the migration as described on page 84: bundle exec sequel...
New
jesse050717
Title: Web Development with Clojure, Third Edition, pg 116 Hi - I just started chapter 5 and I am stuck on page 116 while trying to star...
New
yulkin
your book suggests to use Image.toByteData() to convert image to bytes, however I get the following error: "the getter ‘toByteData’ isn’t...
New
mikecargal
Title: Hands-On Rust (Chapter 11: prefab) Just played a couple of amulet-less games. With a bit of debugging, I believe that your can_p...
New
AleksandrKudashkin
On the page xv there is an instruction to run bin/setup from the main folder. I downloaded the source code today (12/03/21) and can’t see...
New
joepstender
The generated iex result below should list products instead of product for the metadata. (page 67) iex> product = %Product{} %Pento....
New
andreheijstek
After running /bin/setup, the first error was: The foreman' command exists in these Ruby versions: That was easy to fix: gem install fore...
New
ggerico
I got this error when executing the plot files on macOS Ventura 13.0.1 with Python 3.10.8 and matplotlib 3.6.1: programming_ML/code/03_...
New
dachristenson
I just bought this book to learn about Android development, and I’m already running into a major issue in Ch. 1, p. 20: “Update activity...
New

Other popular topics Top

Devtalk
Hello Devtalk World! Please let us know a little about who you are and where you’re from :nerd_face:
New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New
AstonJ
I ended up cancelling my Moonlander order as I think it’s just going to be a bit too bulky for me. I think the Planck and the Preonic (o...
New
AstonJ
I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl: The Ser...
New
PragmaticBookshelf
Use WebRTC to build web applications that stream media and data in real time directly from one user to another, all in the browser. ...
New
Maartz
Hi folks, I don’t know if I saw this here but, here’s a new programming language, called Roc Reminds me a bit of Elm and thus Haskell. ...
New
PragmaticBookshelf
Build efficient applications that exploit the unique benefits of a pure functional language, learning from an engineer who uses Haskell t...
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
PragmaticBookshelf
Develop, deploy, and debug BEAM applications using BEAMOps: a new paradigm that focuses on scalability, fault tolerance, and owning each ...
New
PragmaticBookshelf
A concise guide to MySQL 9 database administration, covering fundamental concepts, techniques, and best practices. Neil Smyth MySQL...
New

Sub Categories: