]> gitweb.fluxo.info Git - puppet-sshkeys_core.git/commitdiff
Remove Rubocop Style/GuardClause violation
authorJacob Helwig <jacob@technosorcery.net>
Mon, 25 Jun 2018 18:07:12 +0000 (11:07 -0700)
committerJacob Helwig <jacob@technosorcery.net>
Mon, 25 Jun 2018 18:26:53 +0000 (11:26 -0700)
By restructuring this code to use a guard clause style, we can also get
rid of the assignment in conditional.

lib/puppet/provider/ssh_authorized_key/parsed.rb

index 45ef64931aa7c8795dd10e4b8fd3dd65dd2a0852..02a19eb143d7c96a06642ebe95fb4f2eef6927b6 100644 (file)
@@ -76,12 +76,13 @@ Puppet::Type.type(:ssh_authorized_key).provide(
     until scanner.eos?
       scanner.skip(%r{[ \t]*})
       # scan a long option
-      if (out = scanner.scan(%r{[-a-z0-9A-Z_]+=\".*?[^\\]\"})) || (out = scanner.scan(%r{[-a-z0-9A-Z_]+}))
-        result << out
-      else
-        # found an unscannable token, let's abort
-        break
-      end
+      out = scanner.scan(%r{[-a-z0-9A-Z_]+=\".*?[^\\]\"}) || scanner.scan(%r{[-a-z0-9A-Z_]+})
+
+      # found an unscannable token, let's abort
+      break unless out
+
+      result << out
+
       # eat a comma
       scanner.skip(%r{[ \t]*,[ \t]*})
     end