Skip to content

Add good/bad examples to rules that lack them#974

Merged
bbatsov merged 17 commits intomasterfrom
add-missing-examples
Feb 14, 2026
Merged

Add good/bad examples to rules that lack them#974
bbatsov merged 17 commits intomasterfrom
add-missing-examples

Conversation

@bbatsov
Copy link
Collaborator

@bbatsov bbatsov commented Feb 14, 2026

Just backfilling a bunch of rules with no examples.

  • Add [source,ruby] code examples with # bad and # good annotations to 17 rules that previously had text-only descriptions
  • Examples follow the existing patterns used throughout the guide
  • Rules that are inherently textual (e.g., "Use UTF-8", "Write comments in English", "SOLID design") were intentionally skipped

Rules updated

  1. One-line Caseswhen x then ... compact form vs multi-line
  2. Semicolon in whenwhen x; ... vs when x then ...
  3. Multi-line Ternary Operator — multi-line ?: vs if/else
  4. BEGIN BlocksBEGIN {} vs top-level code
  5. Too Many Params — many positional params vs keyword args
  6. Private Global Methods — bare method vs Kernel private method
  7. Hash Space#comment vs # comment
  8. No Mutable Keys — mutable string key vs symbol/frozen key
  9. No Modifying Collections — mutation during iteration vs select/reject
  10. map/find/select/reduce/include?/size — Smalltalk aliases vs preferred names
  11. Time.nowTime.new vs Time.now
  12. %s%s(symbol) vs :"symbol"
  13. No Needless Metaprogramming — unnecessary define_method vs plain def/attr_reader
  14. No Monkey Patching — reopening core class vs refinements
  15. No Param Mutations — mutating param vs returning new object
  16. Three is the Number Thou Shalt Count — deeply nested blocks vs extracted methods
  17. No Optional Hash Params — hash param vs keyword args

@bbatsov
Copy link
Collaborator Author

bbatsov commented Feb 14, 2026

I've generated the examples automatically from the rules and the results are pretty good IMO.

@bbatsov bbatsov merged commit a61cad1 into master Feb 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant