Commit 63a773b

mokha <mo@mokhan.ca>
2019-04-20 17:18:14
fix linter errors
1 parent cf31128
lib/xml/kit/encrypted_data.rb
@@ -20,9 +20,14 @@ module Xml
         key_info: nil
       )
         @id = id
-        @symmetric_cipher = symmetric_cipher || key_info&.symmetric_cipher || Xml::Kit::Crypto::SymmetricCipher.new
-        @symmetric_cipher_value = Base64.strict_encode64(@symmetric_cipher.encrypt(raw_xml))
-        @key_info = key_info || create_key_info_for(@symmetric_cipher, asymmetric_cipher)
+        @symmetric_cipher = symmetric_cipher ||
+          key_info.try(:symmetric_cipher) ||
+          Xml::Kit::Crypto::SymmetricCipher.new
+        @symmetric_cipher_value = Base64.strict_encode64(
+          @symmetric_cipher.encrypt(raw_xml)
+        )
+        @key_info = key_info ||
+          create_key_info_for(@symmetric_cipher, asymmetric_cipher)
       end
 
       def to_xml(xml: ::Builder::XmlMarkup.new)
lib/xml/kit/encrypted_key.rb
@@ -21,8 +21,11 @@ module Xml
         key_info: nil
       )
         @id = id
-        @asymmetric_cipher = asymmetric_cipher || key_info&.asymmetric_cipher
-        @symmetric_cipher =  symmetric_cipher || key_info&.symmetric_cipher || Xml::Kit::Crypto::SymmetricCipher.new
+        @asymmetric_cipher = asymmetric_cipher ||
+          key_info.try(:asymmetric_cipher)
+        @symmetric_cipher = symmetric_cipher ||
+          key_info.try(:symmetric_cipher) ||
+          Xml::Kit::Crypto::SymmetricCipher.new
         @key_info = key_info
       end
 
lib/xml/kit/key_info.rb
@@ -24,7 +24,14 @@ module Xml
 
       def asymmetric_cipher(algorithm: Crypto::RsaCipher::ALGORITHM)
         return encrypted_key.asymmetric_cipher if encrypted_key
-        return Crypto.cipher_for(derive_algorithm_from(x509_data.public_key), x509_data.public_key) if x509_data
+
+        if x509_data
+          return Crypto.cipher_for(
+            derive_algorithm_from(x509_data.public_key),
+            x509_data.public_key
+          )
+        end
+
         super
       end
 
.rubocop.yml
@@ -36,6 +36,9 @@ Layout/IndentArray:
 Layout/IndentHeredoc:
   EnforcedStyle: active_support
 
+Layout/MultilineOperationIndentation:
+  EnforcedStyle: indented
+
 Lint/AmbiguousBlockAssociation:
   Exclude:
     - 'spec/**/*.rb'