Regex is probably the only time I get serious about unit tests.
That’s why you should plan the hard parts together, so by the time that’s in review you already know what it’s supposed to be. Then the review is just double checking.
I've 100% been in that situation more times than I'd like. The actual code that does things, ignored. The name of a variable or the precise wording of a comment... That's what's really important....
Regex be like: @$^>\\!-$~/¥*| “lol stole your computer”
“I know const foo” -Neo
That is true. If something is too complex most of the times it never gets analyzed enough. They check if the tests working. That is why test coverage on PRs are so fckn important 😅
Eventually, I'll be able to tune into one of these videos and understand what's happening. Maybe not today, but someday.
No, what happens is you comment on the regular expression, then the team says "Oh, you're good at regular expressions? Can you fix it?" Then you fix it and have to explain in the pull request what each piece of the regular expression means. Also, I'm one who prefers to use [0-9] over \d, [0-9] is more intuitive than \d.
Hopefully soon we'll have AI code reviewers testing AI written code.
I'm a cost estimator and once worked in an office where we had a new CFO who had no experience with preparing or reviewing cost estimates or with the types of systems we were deploying, but required that all estimates get reviewed and signed by her. Previously they'd just get signed by the program managers after they checked that we accurately described the requirements. So what happened was we'd get feedback asking us to change how things were worded or the colors we used in our charts; never addressing the requirements or our methodologies. There'd be multiple rounds of this with every estimate, and she'd ask us to word something one way with one estimate and then complain about that phrasing in the next. The only time the actual estimate was addressed in feedback was when a $14M estimate had a $100K travel line. Eventually, the senior estimator realized that she just wanted to be seen as having an impact and directed the team to start misspelling a word or two in our reports. Suddenly the feedback was just to fix the spelling and nothing else.
time to name variables with regex
Every time I see a new regex I always reject with a "needs unit tests" comment, because no one ever unit tests their regexes. Next review request almost always has the regex removed or at least rewritten.
One trick I used to use to work with my regexes was assigning each part of the regex to constants with descriptive names, and then just interpolate them into the final pattern string. It was a mess, but somehow I understood it... 😅
I would have done the opposite, focused on the complex regex and missed the foo line that had a typo in it lol
awesome term, thanks for commenting this
as someone who understands regex probably too well, I'm ready for this review
Regex is like drugs, never start it or else it will be stuck forever
I have been there so many times… In this situation I requested the author to add comment about regex to explain how it works. They they would write some bullshit comment like „this regex is used to find patterns in text”. Then conflict starts…
i always try to avoid regex where ever possible. in the cases where it isnt, i make sure it is documented so anyone could understand and in code reviews i make sure to understand the regex before approving
@erifetim