Commit 0a9afb1

mo <mo.khan@gmail.com>
2018-03-10 18:26:05
fix reek warnings.
1 parent 52d91a2
lib/saml/kit/bindings/http_redirect.rb
@@ -84,7 +84,7 @@ module Saml
 
         def params_to_hash(value)
           return value unless value.is_a?(String)
-          Hash[URI.parse(value).query.split('&').map { |x| x.split('=', 2) }]
+          Hash[URI.parse(value).query.split('&').map { |xx| xx.split('=', 2) }]
         end
       end
     end
lib/saml/kit/builders/metadata.rb
@@ -22,14 +22,14 @@ module Saml
         end
 
         def build_service_provider
-          @service_provider = Saml::Kit::ServiceProviderMetadata.builder(configuration: configuration) do |x|
-            yield x if block_given?
+          @service_provider = Saml::Kit::ServiceProviderMetadata.builder(configuration: configuration) do |xx|
+            yield xx if block_given?
           end
         end
 
         def build_identity_provider
-          @identity_provider = Saml::Kit::IdentityProviderMetadata.builder(configuration: configuration) do |x|
-            yield x if block_given?
+          @identity_provider = Saml::Kit::IdentityProviderMetadata.builder(configuration: configuration) do |xx|
+            yield xx if block_given?
           end
         end
 
lib/saml/kit/rspec/have_query_param.rb
@@ -8,7 +8,7 @@ RSpec::Matchers.define :have_query_param do |key|
   end
 
   def query_params_from(url)
-    Hash[query_for(url).split('&').map { |x| x.split('=', 2) }]
+    Hash[query_for(url).split('&').map { |xxx| xxx.split('=', 2) }]
   end
 
   def uri_for(url)
lib/saml/kit/authentication_request.rb
@@ -54,11 +54,11 @@ module Saml
       # @param configuration [Saml::Kit::Configuration] the configuration to use to build the response.
       def response_for(user, binding:, relay_state: nil, configuration: Saml::Kit.configuration)
         response_binding = provider.assertion_consumer_service_for(binding: binding)
-        builder = Saml::Kit::Response.builder(user, self, configuration: configuration) do |x|
-          x.embed_signature = provider.want_assertions_signed
-          yield x if block_given?
+        response = Saml::Kit::Response.builder(user, self, configuration: configuration) do |builder|
+          builder.embed_signature = provider.want_assertions_signed
+          yield builder if block_given?
         end
-        response_binding.serialize(builder, relay_state: relay_state)
+        response_binding.serialize(response, relay_state: relay_state)
       end
     end
   end
lib/saml/kit/composite_metadata.rb
@@ -20,7 +20,7 @@ module Saml
       end
 
       def services(type)
-        xpath = map { |x| "//md:EntityDescriptor/md:#{x.name}/md:#{type}" }.join('|')
+        xpath = map { |xxx| "//md:EntityDescriptor/md:#{xxx.name}/md:#{type}" }.join('|')
         search(xpath).map do |item|
           binding = item.attribute('Binding').value
           location = item.attribute('Location').value
@@ -37,7 +37,7 @@ module Saml
       end
 
       def method_missing(name, *args)
-        if (target = find { |x| x.respond_to?(name) })
+        if (target = find { |xxx| xxx.respond_to?(name) })
           target.public_send(name, *args)
         else
           super
@@ -45,7 +45,7 @@ module Saml
       end
 
       def respond_to_missing?(method, *)
-        find { |x| x.respond_to?(method) }
+        find { |xxx| xxx.respond_to?(method) }
       end
     end
   end
lib/saml/kit/configuration.rb
@@ -74,7 +74,7 @@ module Saml
       #
       # @param use [Symbol] the type of key pair to return `nil`, `:signing` or `:encryption`
       def key_pairs(use: nil)
-        use.present? ? @key_pairs.find_all { |x| x.for?(use) } : @key_pairs
+        use.present? ? @key_pairs.find_all { |xxx| xxx.for?(use) } : @key_pairs
       end
 
       # Return each certificate for a specific use.
lib/saml/kit/identity_provider_metadata.rb
@@ -74,9 +74,9 @@ module Saml
       # @param configuration [Saml::Kit::Configuration] the configuration to use for generating the request.
       # @return [Array] The url and saml params encoded using the rules for the specified binding.
       def login_request_for(binding:, relay_state: nil, configuration: Saml::Kit.configuration)
-        builder = Saml::Kit::AuthenticationRequest.builder(configuration: configuration) do |x|
-          x.embed_signature = want_authn_requests_signed
-          yield x if block_given?
+        builder = Saml::Kit::AuthenticationRequest.builder(configuration: configuration) do |xxx|
+          xxx.embed_signature = want_authn_requests_signed
+          yield xxx if block_given?
         end
         request_binding = single_sign_on_service_for(binding: binding)
         request_binding.serialize(builder, relay_state: relay_state)
lib/saml/kit/logout_request.rb
@@ -51,8 +51,8 @@ module Saml
       # @param relay_state [Object] The RelayState to include in the RelayState param.
       # @return [Array] Returns an array with a url and Hash of parameters to return to the requestor.
       def response_for(binding:, relay_state: nil)
-        builder = Saml::Kit::LogoutResponse.builder(self) do |x|
-          yield x if block_given?
+        builder = Saml::Kit::LogoutResponse.builder(self) do |xxx|
+          yield xxx if block_given?
         end
         response_binding = provider.single_logout_service_for(binding: binding)
         response_binding.serialize(builder, relay_state: relay_state)
lib/saml/kit/metadata.rb
@@ -110,7 +110,7 @@ module Saml
       # @param type [Symbol] can be on the service element like `AssertionConsumerServiceURL`, `SingleSignOnService` or `SingleLogoutService`.
       def service_for(binding:, type:)
         binding = Saml::Kit::Bindings.binding_for(binding)
-        services(type).find { |x| x.binding?(binding) }
+        services(type).find { |xxx| xxx.binding?(binding) }
       end
 
       # Returns each of the SingleLogoutService bindings
@@ -132,7 +132,7 @@ module Saml
       # @param relay_state [String] the relay state to have echo'd back.
       # @return [Array] Returns an array with a url and Hash of parameters to send to the other party.
       def logout_request_for(user, binding: :http_post, relay_state: nil)
-        builder = Saml::Kit::LogoutRequest.builder(user) { |x| yield x if block_given? }
+        builder = Saml::Kit::LogoutRequest.builder(user) { |xxx| yield xxx if block_given? }
         request_binding = single_logout_service_for(binding: binding)
         request_binding.serialize(builder, relay_state: relay_state)
       end
@@ -143,7 +143,7 @@ module Saml
       # @param use [Symbol] the type of certificates to look at. Can be `:signing` or `:encryption`.
       # @return [Xml::Kit::Certificate] returns the matching `{Xml::Kit::Certificate}`
       def matches?(fingerprint, use: :signing)
-        certificates.find { |x| x.for?(use) && x.fingerprint == fingerprint }
+        certificates.find { |xxx| xxx.for?(use) && xxx.fingerprint == fingerprint }
       end
 
       # Returns the XML document converted to a Hash.
lib/saml/kit/signature.rb
@@ -37,8 +37,8 @@ module Saml
       end
 
       def expected_digest_value
-        digests = dsignature.references.map do |x|
-          Base64.encode64(x.calculate_digest_value).chomp
+        digests = dsignature.references.map do |xxx|
+          Base64.encode64(xxx.calculate_digest_value).chomp
         end
         digests.count > 1 ? digests : digests[0]
       end
spec/support/test_helpers.rb
@@ -2,7 +2,7 @@
 
 module TestHelpers
   def query_params_from(url)
-    Hash[query_for(url).split('&').map { |x| x.split('=', 2) }]
+    Hash[query_for(url).split('&').map { |xxx| xxx.split('=', 2) }]
   end
 
   def uri_for(url)
.reek
@@ -85,26 +85,7 @@ UtilityFunction:
   - Saml::Kit::Serializable#inflate
   - Saml::Kit::Serializable#unescape
 LongParameterList:
-  exclude:
-  - Saml::Kit::AuthenticationRequest#response_for
-  - Saml::Kit::Configuration#add_key_pair
-UncommunicativeVariableName:
-  exclude:
-  - Saml::Kit::AuthenticationRequest#response_for
-  - Saml::Kit::Bindings::HttpRedirect#params_to_hash
-  - Saml::Kit::Builders::Metadata#build_identity_provider
-  - Saml::Kit::Builders::Metadata#build_service_provider
-  - Saml::Kit::CompositeMetadata#method_missing
-  - Saml::Kit::CompositeMetadata#respond_to_missing?
-  - Saml::Kit::CompositeMetadata#services
-  - Saml::Kit::Configuration#key_pairs
-  - Saml::Kit::IdentityProviderMetadata#login_request_for
-  - Saml::Kit::LogoutRequest#response_for
-  - Saml::Kit::Metadata#logout_request_for
-  - Saml::Kit::Metadata#matches?
-  - Saml::Kit::Metadata#service_for
-  - query_params_from
-  - Saml::Kit::Signature#expected_digest_value
+  max_params: 4
 DuplicateMethodCall:
   exclude:
   - Saml::Kit::Bindings::Binding#saml_param_from