diff options
author | Prem Sichanugrist <s@sikac.hu> | 2018-08-15 15:05:10 +0900 |
---|---|---|
committer | Prem Sichanugrist <s@sikac.hu> | 2018-08-15 15:45:08 +0900 |
commit | cdabcc2bd530af4184c2592619ea3fe0ddb2d9af (patch) | |
tree | 05b2b22fe48e489d137f3ac319f6761666c37147 /guides | |
parent | 7e3a0a947faeecee03d2714789084addbcf7e414 (diff) | |
download | rails-cdabcc2bd530af4184c2592619ea3fe0ddb2d9af.tar.gz rails-cdabcc2bd530af4184c2592619ea3fe0ddb2d9af.tar.bz2 rails-cdabcc2bd530af4184c2592619ea3fe0ddb2d9af.zip |
Update guide to mention code linters available
Contributors can run RuboCop locally to catch code style error in Ruby
code and npm lint task for `rails-ujs` CoffeeScript and JavaScript code.
[skip ci]
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/contributing_to_ruby_on_rails.md | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md index 3147b00f3b..b5e40aa40f 100644 --- a/guides/source/contributing_to_ruby_on_rails.md +++ b/guides/source/contributing_to_ruby_on_rails.md @@ -239,7 +239,6 @@ Now get busy and add/edit code. You're on your branch now, so you can write what * Include tests that fail without your code, and pass with it. * Update the (surrounding) documentation, examples elsewhere, and the guides: whatever is affected by your contribution. - TIP: Changes that are cosmetic in nature and do not add anything substantial to the stability, functionality, or testability of Rails will generally not be accepted (read more about [our rationales behind this decision](https://github.com/rails/rails/pull/13771#issuecomment-32746700)). #### Follow the Coding Conventions @@ -254,12 +253,24 @@ Rails follows a simple set of coding style conventions: * Prefer class << self over self.method for class methods. * Use `my_method(my_arg)` not `my_method( my_arg )` or `my_method my_arg`. * Use `a = b` and not `a=b`. -* Use assert_not methods instead of refute. +* Use assert\_not methods instead of refute. * Prefer `method { do_stuff }` instead of `method{do_stuff}` for single-line blocks. * Follow the conventions in the source you see used already. The above are guidelines - please use your best judgment in using them. +Additionally, we have [RuboCop](https://www.rubocop.org/) rules defined to codify some of our coding conventions. You can run RuboCop locally against the file that you have modified before submitting a pull request: + +```bash +$ rubocop actionpack/lib/action_controller/metal/strong_parameters.rb +Inspecting 1 file +. + +1 file inspected, no offenses detected +``` + +For `rails-ujs` CoffeeScript and JavaScript files, you can run `npm run lint` in `actionview` folder. + ### Benchmark Your Code For changes that might have an impact on performance, please benchmark your |