# Ruby Style Guide

Follow the community-driven [Ruby Style Guide](https://github.com/bbatsov/ruby-style-guide), automatically enforced by [RuboCop](https://github.com/bbatsov/rubocop).

For our Cucumber tests, we override a few of the defaults with a custom [.rubocop.yml](https://github.com/theorchard/orchard/blob/master/tests/cucumber/.rubocop.yml), because step definitions are matchers for Business Readable [Gherkin](https://github.com/cucumber/cucumber/wiki/Gherkin) \(resulting in some unavoidable verbosity\).

Unless there is an extremely compelling reason otherwise, **use RuboCop with all its defaults** to ensure code is stylistically consistent and to guard against a variety of code smells.

## Auto-correct

Rubocop has an auto-correct flag. After submitting a PR, if RuboCop fails the PR build due to minor style issues, you can fix them all at once by running:

```text
$ rubocop -a
```

## Faster feedback

You can integrate RuboCop directly into [many IDEs](https://github.com/bbatsov/rubocop#editor-integration), or alternatively use [Guard](https://github.com/guard/guard) with [guard-rubocop](https://github.com/yujinakayama/guard-rubocop), which will continuously watch your filesystem for changes in a directory you specify, and automatically run RuboCop on changed files.

