Commit 9de1a62

mokha <mo@mokhan.ca>
2019-04-30 19:41:16
fix linter errors using the latest brakeman
1 parent 9614c0e
lib/xml/kit/encrypted_data.rb
@@ -12,13 +12,11 @@ module Xml
       attr_reader :symmetric_cipher
       attr_reader :symmetric_cipher_value
 
-      def initialize(
-        raw_xml,
-        id: Id.generate,
-        symmetric_cipher: nil,
-        asymmetric_cipher: nil,
-        key_info: nil
-      )
+      def initialize(raw_xml,
+                     id: Id.generate,
+                     symmetric_cipher: nil,
+                     asymmetric_cipher: nil,
+                     key_info: nil)
         @id = id
         @symmetric_cipher = symmetric_cipher ||
           key_info.try(:symmetric_cipher) ||
lib/xml/kit/encrypted_key.rb
@@ -14,12 +14,10 @@ module Xml
       attr_reader :asymmetric_cipher, :symmetric_cipher
       attr_accessor :key_info
 
-      def initialize(
-        id: Id.generate,
-        asymmetric_cipher: nil,
-        symmetric_cipher: nil,
-        key_info: nil
-      )
+      def initialize(id: Id.generate,
+                     asymmetric_cipher: nil,
+                     symmetric_cipher: nil,
+                     key_info: nil)
         @id = id
         @asymmetric_cipher = asymmetric_cipher ||
           key_info.try(:asymmetric_cipher)
lib/xml/kit/encryption.rb
@@ -4,18 +4,17 @@ module Xml
   module Kit
     # @deprecated Use {#Xml::Kit::EncryptedData} class instead of this
     class Encryption < EncryptedData
+      DEFAULT_SYMMETRIC = Crypto::SymmetricCipher::DEFAULT_ALGORITHM
+      DEFAULT_ASYMMETRIC = Crypto::RsaCipher::ALGORITHM
+
       attr_reader :asymmetric_algorithm
       attr_reader :symmetric_algorithm
       attr_reader :symmetric_cipher_value
       attr_reader :key_info
 
-      def initialize(
-        raw_xml,
-        public_key,
-        symmetric_algorithm: Crypto::SymmetricCipher::DEFAULT_ALGORITHM,
-        asymmetric_algorithm: Crypto::RsaCipher::ALGORITHM,
-        key_info: nil
-      )
+      def initialize(raw_xml, public_key,
+                     symmetric_algorithm: DEFAULT_SYMMETRIC,
+                     asymmetric_algorithm: DEFAULT_ASYMMETRIC, key_info: nil)
         @symmetric_algorithm = symmetric_algorithm
         @asymmetric_algorithm = asymmetric_algorithm
         Xml::Kit.deprecate('Encryption', alternative: 'EncryptedData')
lib/xml/kit/key_pair.rb
@@ -30,12 +30,10 @@ module Xml
       # @param use [Symbol] Can be either `:signing` or `:encryption`.
       # @param passphrase [String] the passphrase to use to encrypt the private key.
       # @param algorithm [String] the symmetric algorithm to use for encrypting the private key.
-      def self.generate(
-        use:,
-        passphrase: SecureRandom.uuid,
-        algorithm: ::Xml::Kit::Crypto::SymmetricCipher::DEFAULT_ALGORITHM
-      )
-        algorithm = ::Xml::Kit::Crypto::SymmetricCipher::ALGORITHMS[algorithm]
+      def self.generate(use:,
+                        passphrase: SecureRandom.uuid,
+                        algorithm: Crypto::SymmetricCipher::DEFAULT_ALGORITHM)
+        algorithm = Crypto::SymmetricCipher::ALGORITHMS[algorithm]
         certificate, private_key = SelfSignedCertificate.new.create(
           algorithm: algorithm,
           passphrase: passphrase
lib/xml/kit/self_signed_certificate.rb
@@ -5,11 +5,9 @@ module Xml
     class SelfSignedCertificate
       SUBJECT = '/C=CA/ST=AB/L=Calgary/O=XmlKit/OU=XmlKit/CN=XmlKit'.freeze
 
-      def create(
-        algorithm: 'AES-256-CBC',
-        passphrase: nil,
-        key_pair: OpenSSL::PKey::RSA.new(2048)
-      )
+      def create(algorithm: 'AES-256-CBC',
+                 passphrase: nil,
+                 key_pair: OpenSSL::PKey::RSA.new(2048))
         certificate = certificate_for(key_pair.public_key)
         certificate.sign(key_pair, OpenSSL::Digest::SHA256.new)
         [certificate.to_pem, export(key_pair, algorithm, passphrase)]
lib/xml/kit/signature.rb
@@ -27,12 +27,10 @@ module Xml
       attr_reader :reference_id
       attr_reader :signature_method
 
-      def initialize(
-        reference_id,
-        signature_method: :SH256,
-        digest_method: :SHA256,
-        certificate:
-      )
+      def initialize(reference_id,
+                     signature_method: :SH256,
+                     digest_method: :SHA256,
+                     certificate:)
         @certificate = certificate
         @digest_method = DIGEST_METHODS[digest_method]
         @reference_id = reference_id
lib/xml/kit/signatures.rb
@@ -39,12 +39,10 @@ module Xml
       end
 
       # @!visibility private
-      def self.sign(
-        xml: ::Builder::XmlMarkup.new,
-        key_pair:,
-        signature_method: :SHA256,
-        digest_method: :SHA256
-      )
+      def self.sign(xml: ::Builder::XmlMarkup.new,
+                    key_pair:,
+                    signature_method: :SHA256,
+                    digest_method: :SHA256)
         signatures = new(
           key_pair: key_pair,
           signature_method: signature_method,
.rubocop.yml
@@ -30,7 +30,7 @@ Layout/ClassStructure:
 Layout/EndOfLine:
   EnforcedStyle: lf
 
-Layout/IndentArray:
+Layout/IndentFirstArrayElement:
   EnforcedStyle: consistent
 
 Layout/IndentHeredoc: