From cc7e640ddd28d1d122aaf705a53f50e0f8e20be2 Mon Sep 17 00:00:00 2001 From: Rishi Paranjape Date: Wed, 24 Feb 2016 16:06:18 -0800 Subject: [PATCH 1/3] add restriction on unless keyword --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 589610202..83f3c88e0 100644 --- a/README.md +++ b/README.md @@ -979,6 +979,20 @@ Translations of the guide are available in the following languages: end ``` +* + Avoid using unless conditional over multiple lines +[[link](#no-multiline-else-blocks)] + + ```Ruby + # bad + unless success? + # multi-line body omitted + end + + # good + multi_line_method unless success? + ``` + * Avoid nested modifier `if/unless/while/until` usage. Favor `&&/||` if appropriate. From 95fdff301e043d023772f53520bc6da73a64d69d Mon Sep 17 00:00:00 2001 From: Pierre Larochelle Date: Thu, 25 Feb 2016 14:25:45 -0800 Subject: [PATCH 2/3] Single-condition `unless` --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 83f3c88e0..3618b2c77 100644 --- a/README.md +++ b/README.md @@ -993,6 +993,19 @@ Translations of the guide are available in the following languages: multi_line_method unless success? ``` +* + Avoid using unless conditional over multiple conditions +[[link](#no-complex-unless)] + + ```Ruby + # bad + do_something unless a and b or !c + + # good + multi_line_method unless success? + ``` + + * Avoid nested modifier `if/unless/while/until` usage. Favor `&&/||` if appropriate. From 2d1563b7ec83ad03a66e9d45d010a96e163489ae Mon Sep 17 00:00:00 2001 From: Pierre Larochelle Date: Thu, 25 Feb 2016 15:32:58 -0800 Subject: [PATCH 3/3] Updating example method name --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3618b2c77..c3c91a42d 100644 --- a/README.md +++ b/README.md @@ -1002,7 +1002,7 @@ Translations of the guide are available in the following languages: do_something unless a and b or !c # good - multi_line_method unless success? + do_something unless success? ```