Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added a new rule about using parentheses around an if condition
  • Loading branch information
bbatsov committed Oct 11, 2011
1 parent 3cf3389 commit 2f54da0
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions README.md
Expand Up @@ -367,21 +367,35 @@ wkhtmltopdf can be installed in one of two methods
* Never use `unless` with `else`. Rewrite these with the positive case first.

```Ruby
#bad
# bad
unless success?
puts 'failure'
else
puts 'success'
end

#good
# good
if success?
puts 'success'
else
puts 'failure'
end
```

* Don't use parentheses around the condition of an `if/unless/while`.

```Ruby
# bad
if (x > 10)
# body omitted
end

# good
if x > 10
# body omitted
end
```

* Omit parentheses around parameters for methods that are part of an
internal DSL (e.g. Rake, Rails, RSpec), methods that are with
"keyword" status in Ruby (e.g. `attr_reader`, `puts`) and attribute
Expand Down

0 comments on commit 2f54da0

Please sign in to comment.