This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the dumb-mistakes-and-gotchas category.
Last Updated: 2024-11-21
I ran some vim macros to rename tutor_discipline_availabilities
to
law_discipline_offerings
across my project.
Now for a bit of Ruby context: ruby has both normal unadorned variable
names/functions - e.g. tutor_discipline_availabilities
and symbols (a bit like
singleton value strings - :tutor_discipline_availabilities
)
Now, my regex worked for normal functions, but when it acted on symbols (i.e.
:tutor_discipline_availabilities
), it did not preserve the colon in front. I
committed this error and it sneaked up on me later.
When searching and replacing project-wide in future I should
enumerate the possible entities that might be changed and check that at least
one example of each one was done correctly. In the case of Ruby, that means
looking at symbols :foo
and instance variables @foo
.
proof-read the commit generated, training myself to look for indenting mismatches in the diffs. E.g.
-- Tutor.joins(:tutor_discipline_availabilities)
++ Tutor.joins(tutor_discipline_availabilities)