Reduce cognitive load of Rubocop style rules
Over the past year or so I feel like my pace of development has rapidly slowed down due to a lot of friction when working on GitLab. Two main contributors to this are the number of bot comments on MRs, and the number of Rubocop rules that flag up on any code I write.
Many of these rules are sensible and never crop up, but some of them are on pretty much every commit and increasingly frustrating. Some examples:
-
Layout/LineLength
- this is set to 120 characters, currently, which is not even halfway across the screen of my laptop. It also doesn't apply to HAML files, so it feels somewhat redundant, and I very frequently trigger it when refactoring old code. Resolving this usually then creates subsequent errors from other style cops, like indentation or nested conditionals. I feel we could up this to something reasonable, like 180-200 without causing too much trouble. -
Style/GuardClause
- triggers frequently in cases where guard clauses are inappropriate, e.g. !132135 (diffs, comment 1600218529) -
Style/SoleNestedConditional
- this causes problems in conjunction with theLayout/LineLength
rule, and as feature flags are temporary I feel like it should at least ignore that use-case (see above example again) -
Performance/UnfreezeString
- not a style rule but pretty close to one. The performance benefit from this is extremely marginal, and the actual result is different from.dup
too (it broke the specs in the example below). Considering how minor the performance implications of duplicating a single string are, and how confusing the+""
syntax is (I have literally never seen it before in 15 years of Ruby), this feels like a net negative. Example: !132135 (diffs)
Will update this issue with more as I bump into them, as I can't remember them all off the top of my head
/cc @splattael @dstull
Edited by Robert May