rails_best_practices

rails_best_practices是一个自动检查违背最佳实践代码的Gem,它会根据ihower在Kungfu Rails大会上的Rails最佳实践的演讲内容,检查Rails应用程序文件的质量。它是一个静态代码解析工具。

 

rails_best_practices的安装和使用都非常方便,只需简单两条命令就能知道代码中何处需要修改:

 

sudo gem install rails_best_practices --source http://gemcutter.org
rails_best_practices .

 

最新的0.3.21版本中,rails_best_practices已经完成了大部分最佳实践,使用者可以自行配置要检测的内容,目前支持的最佳实践有:

 

*************************************************

 

* Lesson 1. Move code from Controller to Model
## [-Move finder to named_scope-]
## [-Use model association-]
## [-Use scope access-]
## [-Add model virtual attribute-]
## Use model callback
## [-Replace Complex Creation with Factory Method-]
## [-Move Model Logic into the Model-]
## model.collection_model_ids (many-to-many)
## Nested Model Forms (one-to-one)
## Nested Model Forms (one-to-many)

 

* Lesson 2. RESTful Conventions
## [-Overuse route customizations-]
## [-Needless deep nesting-]
## [-Not use default route-]

 

* Lesson 3. Model
## [-Keep Finders on Their Own Model-]
## [-Love named_scope-] # same as Move finder to named_scope
## [-the Law of Demeter-]
## DRY: metaprogramming
## Extract into Module
## Extract to composed class
## [-Use Observer-]

 

* Lesson 4. Migration
## [-Isolating Seed Data-]
## [-Always add DB index-]

 

* Lesson 5. Controller
## [-Use before_filter-]
## [-DRY Controller-] # not implement, use http://github.com/josevalim/inherited_resources

 

* Lesson 6. View
## [-Move code into controller-]
## [-Move code into model-]
## [-Move code into helper-]
## [-Replace instance variable with local variable-]
## [-Use Form Builder-] # not implement, use http://github.com/justinfrench/formtastic
## [-Organize Helper files-] # not implement, it's rails default behaviour

 

*************************************************

 

相信随着rails_best_practices的日益完善,会有更多的人投来关注的目光。

你可能感兴趣的:(Access,Rails)