[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-7778":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":16,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":20,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":24,"readmeContent":25,"aiSummary":26,"trendingCount":16,"starSnapshotCount":16,"syncStatus":27,"lastSyncTime":28,"discoverSource":29},7778,"rails_best_practices","flyerhzm\u002Frails_best_practices","flyerhzm","a code metric tool for rails projects","http:\u002F\u002Frails-bestpractices.com",null,"Ruby",4168,272,75,60,0,1,29.31,"MIT License",false,"main",true,[],"2026-06-12 02:01:44","# rails_best_practices\n\n[![Gem Version](https:\u002F\u002Fbadge.fury.io\u002Frb\u002Frails_best_practices.svg)](http:\u002F\u002Fbadge.fury.io\u002Frb\u002Frails_best_practices)\n[![CI](https:\u002F\u002Fgithub.com\u002Fflyerhzm\u002Frails_best_practices\u002Factions\u002Fworkflows\u002Fmain.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fflyerhzm\u002Frails_best_practices\u002Factions\u002Fworkflows\u002Fmain.yml)\n[![Coverage Status](https:\u002F\u002Fcoveralls.io\u002Frepos\u002Frailsbp\u002Frails_best_practices\u002Fbadge.svg?branch=master)](https:\u002F\u002Fcoveralls.io\u002Fr\u002Frailsbp\u002Frails_best_practices)\n[![AwesomeCode Status for flyerhzm\u002Frails_best_practices](https:\u002F\u002Fawesomecode.io\u002Fprojects\u002Fd02ecd70-e068-4ad4-b61a-7003ac24b49a\u002Fstatus)](https:\u002F\u002Fawesomecode.io\u002Frepos\u002Fflyerhzm\u002Frails_best_practices)\n\nrails_best_practices is a code metric tool to check the quality of Rails code.\n\nIt supports the following ORM\u002FODMs:\n\n* activerecord\n* mongoid\n* mongomapper\n\nAnd the following template engines:\n\n* erb\n* haml\n* slim\n* rabl\n\nrails_best_practices supports Ruby 1.9.3 or newer.\n\n## External Introduction\n\n[Ruby5 - Episode #253](http:\u002F\u002Fruby5.envylabs.com\u002Fepisodes\u002F257-episode-253-march-9th-2012\u002Fstories\u002F2253-rails_best_practices)\n\n[Railscasts - #252 Metrics Metrics Metrics](http:\u002F\u002Frailscasts.com\u002Fepisodes\u002F252-metrics-metrics-metrics)\n\n## Usage\n\nAt the root directory of a Rails app, run:\n\n    rails_best_practices .\n\nOr for HTML output:\n\n    rails_best_practices -f html .\n\nBy default rails_best_practices will parse code in the `vendor`, `spec`, `test` and `features` directories.\n\n### Excluding directories\n\nTo exclude a directory simply call it with `-e` or `--exclude`:\n\n    rails_best_practices -e \"db\u002Fmigrate\" .\n\nTo exclude multiple directories, separate them with comma:\n\n    rails_best_practices -e \"db\u002Fmigrate,vendor\" .\n\n### Other command-line options\n\nTo see the full list of command-line options, run:\n\n    $ rails_best_practices -h\n\n    Usage: rails_best_practices [options]\n        -d, --debug                      Debug mode\n        -f, --format FORMAT              output format\n            --without-color              only output plain text without color\n            --with-textmate              open file by textmate in html format\n            --with-vscode                open file by vscode in html format\n            --with-sublime               open file by sublime in html format (requires https:\u002F\u002Fgithub.com\u002Fasuth\u002Fsubl-handler)\n            --with-mvim                  open file by mvim in html format\n            --with-github GITHUB_NAME    open file on github in html format. GITHUB_NAME is like railsbp\u002Frails-bestpractices OR full URL to GitHub:FI repo\n            --with-hg                    display hg commit and username, only support html format\n            --with-git                   display git commit and username, only support html format\n            --template TEMPLATE          customize erb template\n            --output-file OUTPUT_FILE    output html file for the analyzing result\n            --silent                     silent mode\n            --vendor                     include vendor files\n            --spec                       include spec files\n            --test                       include test files\n            --features                   include features files\n        -x, --exclude PATTERNS           Don't analyze files matching a pattern\n                                         (comma-separated regexp list)\n        -o, --only PATTERNS              analyze files only matching a pattern\n                                         (comma-separated regexp list)\n        -g, --generate                   Generate configuration yaml\n        -c, --config CONFIG_PATH         configuration file location (defaults to config\u002Frails_best_practices.yml)\n        -v, --version                    Show this version\n        -h, --help                       Show this message\n\n## Resources\n\nHomepage: \u003Chttp:\u002F\u002Frails-bestpractices.com>\n\nGitHub: \u003Chttp:\u002F\u002Fgithub.com\u002Fflyerhzm\u002Frails_best_practices>\n\nTeam Blog \u003Chttp:\u002F\u002Frails-bestpractices.com>\n\nGoogle Group: \u003Chttps:\u002F\u002Fgroups.google.com\u002Fgroup\u002Frails_best_practices>\n\nWiki: \u003Chttp:\u002F\u002Fgithub.com\u002Fflyerhzm\u002Frails_best_practices\u002Fwiki>\n\nIssue Tracker: \u003Chttp:\u002F\u002Fgithub.com\u002Fflyerhzm\u002Frails_best_practices\u002Fissues>\n\n## Install\n\n    gem install rails_best_practices\n\nor add it to the Gemfile\n\n    gem \"rails_best_practices\"\n\n#### --with-sublime\n\nInstall \u003Chttps:\u002F\u002Fgithub.com\u002Fasuth\u002Fsubl-handler>\n\n## Editor Integration\n\n#### TextMate 2\n\nIf you use `TextMate 2`, you can install the [RailsBestPractices.tmbundle](https:\u002F\u002Fgithub.com\u002Fjjuliano\u002FRailsBestPractices.tmbundle) bundle.\n\n## Issues\n\nIf you install the rails_best_practices with bundler-installed GitHub-sourced gem, please use the following command instead.\n\n    bundle exec rails_best_practices .\n\nIf you encounter a NoMethodError exception, or a syntax error, you can use debug mode to discover which file is to blame:\n\n    rails_best_practices -d .\n\nThat will provide the error's stack trace and the source code of the file which is causing the error.\n\n## Custom Configuration\n\nFirst run:\n\n    rails_best_practices -g\n\nto generate `rails_best_practices.yml` file.\n\nNow you can customize this configuration file. The default configuration is as follows:\n\n    AddModelVirtualAttributeCheck: { }\n    AlwaysAddDbIndexCheck: { }\n    #CheckSaveReturnValueCheck: { }\n    #CheckDestroyReturnValueCheck: { }\n    DefaultScopeIsEvilCheck: { }\n    DryBundlerInCapistranoCheck: { }\n    #HashSyntaxCheck: { }\n    IsolateSeedDataCheck: { }\n    KeepFindersOnTheirOwnModelCheck: { }\n    LawOfDemeterCheck: { }\n    #LongLineCheck: { max_line_length: 80 }\n    MoveCodeIntoControllerCheck: { }\n    MoveCodeIntoHelperCheck: { array_count: 3 }\n    MoveCodeIntoModelCheck: { use_count: 2 }\n    MoveFinderToNamedScopeCheck: { }\n    MoveModelLogicIntoModelCheck: { use_count: 4 }\n    NeedlessDeepNestingCheck: { nested_count: 2 }\n    NotRescueExceptionCheck: { }\n    NotUseDefaultRouteCheck: { }\n    NotUseTimeAgoInWordsCheck: { }\n    OveruseRouteCustomizationsCheck: { customize_count: 3 }\n    ProtectMassAssignmentCheck: { }\n    RemoveEmptyHelpersCheck: { }\n    #RemoveTabCheck: { }\n    RemoveTrailingWhitespaceCheck: { }\n    RemoveUnusedMethodsInControllersCheck: { except_methods: [] }\n    RemoveUnusedMethodsInHelpersCheck: { except_methods: [] }\n    RemoveUnusedMethodsInModelsCheck: { except_methods: [] }\n    ReplaceComplexCreationWithFactoryMethodCheck: { attribute_assignment_count: 2 }\n    ReplaceInstanceVariableWithLocalVariableCheck: { }\n    RestrictAutoGeneratedRoutesCheck: { }\n    SimplifyRenderInControllersCheck: { }\n    SimplifyRenderInViewsCheck: { }\n    #UseBeforeFilterCheck: { customize_count: 2 }\n    UseModelAssociationCheck: { }\n    UseMultipartAlternativeAsContentTypeOfEmailCheck: { }\n    UseObserverCheck: { }\n    #UseParenthesesInMethodDefCheck: { }\n    UseQueryAttributeCheck: { }\n    UseSayWithTimeInMigrationsCheck: { }\n    UseScopeAccessCheck: { }\n    UseTurboSprocketsRails3Check: { }\n\nNow, at the root directory of a Rails app, run:\n\n    rails_best_practices . -c config\u002Frails_best_practices.yml\n\nYou can remove or comment a review to disable it, and you can change the options.\n\nYou can apply the `ignored_files` option on any rule by giving a regexp or array of regexps describing the path of the files you don't want to be checked:\n\n\tDefaultScopeIsEvilCheck: { ignored_files: 'user\\.rb' }\n\tLongLineCheck: { max_line_length: 80, ignored_files: ['db\u002Fmigrate', 'config\u002Finitializers'] }\n\n## Implementation\n\nMove code from Controller to Model\n\n1. Move finder to named_scope (rails2 only)\n2. Use model association\n3. Use scope access\n4. Add model virtual attribute\n5. Replace complex creation with factory method\n6. Move model logic into the Model\n7. Check return value of \"save!\"\n\nRESTful Conventions\n\n1. Overuse route customizations\n2. Needless deep nesting\n3. Not use default route\n4. Restrict auto-generated routes\n\nModel\n\n1. Keep finders on their own model (rails2 only)\n2. The law of demeter\n3. Use observer\n4. Use query attribute\n5. Remove unused methods in models\n6. Protect mass assignment\n7. Destroy return value (disabled by default)\n\nMailer\n\n1. Use multipart\u002Falternative as content_type of email\n\nMigration\n\n1. Isolating seed data\n2. Always add database index\n3. Use say with time in migrations\n\nController\n\n1. Use `before_filter` (disabled by default)\n2. Simplify render in controllers\n3. Remove unused methods in controllers\n\nHelper\n\n1. Remove empty helpers\n2. Remove unused methods in helpers\n\nView\n\n1. Move code into controller\n2. Move code into model\n3. Move code into helper\n4. Replace instance variable with local variable\n5. Simplify render in views\n6. Not use time_ago_in_words\n\nDeployment\n\n1. Dry bundler in Capistrano\n2. Speed up assets precompilation with turbo-sprockets-rails3\n\nOther\n\n1. Remove trailing whitespace\n2. Remove tab (disabled by default)\n3. Hash syntax (disabled by default)\n4. Use parentheses in method definition (disabled by default)\n5. Long line (disabled by default)\n6. Not rescue exception\n\n## Write Your Own Checklist\n\nIf you want to write your own checklist (some checklist only for your Rails projects), please read this first, [How to write your own check list?][1]\n\n## Contribute\n\nIf you want to add your rails best practices into the gem, please post your best practices on \u003Chttp:\u002F\u002Frails-bestpractices.com>\n\n## Contact Us\n\nWe provide Rails consulting services, you can contact us by Twitter or email.\n\nFollow us on twitter: \u003Chttp:\u002F\u002Ftwitter.com\u002Frailsbp>\n\nSend us email: \u003Cteam@railsbp.com>\n\n\nCopyright © 2009 - 2022 Richard Huang (flyerhzm@gmail.com), released under the MIT license\n\n\n[1]: https:\u002F\u002Fgithub.com\u002Fflyerhzm\u002Frails_best_practices\u002Fwiki\u002FHow-to-write-your-own-check-list\n","rails_best_practices 是一个用于检查 Rails 项目代码质量的工具。它支持多种 ORM\u002FODM（如 activerecord、mongoid 和 mongomapper）以及模板引擎（如 erb、haml、slim 和 rabl），能够帮助开发者识别和改进不符合最佳实践的代码。该工具提供多种输出格式，包括文本和 HTML，并允许用户通过命令行选项自定义分析范围和行为，例如排除特定目录或使用不同的编辑器打开结果文件。适用于需要提高 Rails 应用程序代码质量和可维护性的开发场景。",2,"2026-06-11 03:14:21","top_language"]