summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColby Swandale <colby@taplaboratories.com>2017-04-17 14:44:00 +1000
committerColby Swandale <colby@taplaboratories.com>2017-04-17 14:44:51 +1000
commitf8dc54bf3dcd1a7aafc5589a887ce2ffc4e98c49 (patch)
treef72e02bd9dfc9c29ed4d3a1de422ca67d1f0164e
parent51a9e064f5e17454f7a1d5a97e43033b83081c6f (diff)
downloadbundler-f8dc54bf3dcd1a7aafc5589a887ce2ffc4e98c49.tar.gz
use guard clause instead of big conditional if expression
-rw-r--r--lib/bundler/dsl.rb28
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index e46c7035ba..15799c3fc2 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -391,19 +391,19 @@ module Bundler
raise GemfileError, %(The `branch` option for `#{command}` is not allowed. Only gems with a git source can specify a branch)
end
- if invalid_keys.any?
- message = String.new
- message << "You passed #{invalid_keys.map {|k| ":" + k }.join(", ")} "
- message << if invalid_keys.size > 1
- "as options for #{command}, but they are invalid."
- else
- "as an option for #{command}, but it is invalid."
- end
-
- message << " Valid options are: #{valid_keys.join(", ")}."
- message << " You may be able to resolve this by upgrading Bundler to the newest version."
- raise InvalidOption, message
- end
+ return true unless invalid_keys.any?
+
+ message = String.new
+ message << "You passed #{invalid_keys.map {|k| ":" + k }.join(", ")} "
+ message << if invalid_keys.size > 1
+ "as options for #{command}, but they are invalid."
+ else
+ "as an option for #{command}, but it is invalid."
+ end
+
+ message << " Valid options are: #{valid_keys.join(", ")}."
+ message << " You may be able to resolve this by upgrading Bundler to the newest version."
+ raise InvalidOption, message
end
def normalize_source(source)
@@ -531,7 +531,7 @@ The :#{name} git source is deprecated, and will be removed in Bundler 2.0. Add t
lines = contents.lines.to_a
indent = " # "
indicator = indent.tr("#", ">")
- first_line = (line_numer.zero?)
+ first_line = line_numer.zero?
last_line = (line_numer == (lines.count - 1))
m << "\n"