http://www.matthewpaulmoore.com/articles/1276-ruby-on-rails-code-quality-checklist#skinny
Ruby on Rails Code Quality Checklist
- Each controller action only calls one model method other than an initial find or new.
(Make custom .new or .update methods in the model with all necessary). ... - Only one or two instance variables are shared between each controller and view. ...
- All model and variable names are both immediately obvious (to a new developer) and as short as possible without using abbreviations. ...
- All custom "finds" accessed from more than one place in the code use named_scope instead of a custom method. ...
- A .find or .find_by_ is never called in a view or view helper. ...
- There is zero custom code that duplicates functionality of a built-in function in rails. ...
- Code has been aggressively DRYed during development. ...
- All functionality used in two or more models has been turned into a library/module. ...
- All logic duplicated between two or more apps has been turned into a gemified plugin. ...
- STI is not used anywhere ...
- Every design choice should yield the most simplistic design possible for the need of users at the current time.
No guesses for future functionality were designed into the application. ... - Close to full test coverage exists at the highest level of the application: on and between controller actions.
Coverage is highest for code used by the most number of end users. ... - All tests pass before code is merged into a shared repository. ...
- Every fixed defect on a deployed product has tests added to prevent regression. ...
- Every plugin installed has been code reviewed. ...
本文提供了一份详细的Ruby on Rails代码质量检查清单,包括了控制器、视图、模型的最佳实践建议,如每个控制器动作只调用一个模型方法,避免在视图中使用find操作等。此外还强调了代码DRY原则的重要性,并提出了所有重复的功能应该被提炼成模块或gem的建议。
303

被折叠的 条评论
为什么被折叠?



