diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 13e5ac59..8acc029e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -578,20 +578,6 @@ Style/SpecialGlobalVars: Style/StringLiterals: Enabled: false -# Offense count: 11 -# Cop supports --auto-correct. -# Configuration parameters: IgnoredMethods. -Style/SymbolProc: - Exclude: - - 'lib/net/ber.rb' - - 'lib/net/ber/core_ext/array.rb' - - 'lib/net/ldap/connection.rb' - - 'lib/net/ldap/dataset.rb' - - 'lib/net/ldap/filter.rb' - - 'test/ber/test_ber.rb' - - 'test/test_ldif.rb' - - 'testserver/ldapserver.rb' - # Offense count: 5 # Cop supports --auto-correct. Style/UnneededPercentQ: diff --git a/lib/net/ber.rb b/lib/net/ber.rb index baf08e14..88f8862e 100644 --- a/lib/net/ber.rb +++ b/lib/net/ber.rb @@ -270,7 +270,7 @@ class Net::BER::BerIdentifiedOid def initialize(oid) if oid.is_a?(String) - oid = oid.split(/\./).map {|s| s.to_i } + oid = oid.split(/\./).map(&:to_i) end @value = oid end diff --git a/lib/net/ber/core_ext/array.rb b/lib/net/ber/core_ext/array.rb index 250fa243..9deb4a1e 100644 --- a/lib/net/ber/core_ext/array.rb +++ b/lib/net/ber/core_ext/array.rb @@ -89,7 +89,7 @@ def to_ber_control #if our array does not contain at least one array then wrap it in an array before going forward ary = self[0].kind_of?(Array) ? self : [self] ary = ary.collect do |control_sequence| - control_sequence.collect{|element| element.to_ber}.to_ber_sequence.reject_empty_ber_arrays + control_sequence.collect(&:to_ber).to_ber_sequence.reject_empty_ber_arrays end ary.to_ber_sequence.reject_empty_ber_arrays end diff --git a/lib/net/ldap/connection.rb b/lib/net/ldap/connection.rb index 96e735b9..f8ba0b61 100644 --- a/lib/net/ldap/connection.rb +++ b/lib/net/ldap/connection.rb @@ -409,7 +409,7 @@ def search(args = nil) Net::LDAP::LDAPControls::PAGED_RESULTS.to_ber, # Criticality MUST be false to interoperate with normal LDAPs. false.to_ber, - rfc2696_cookie.map{ |v| v.to_ber}.to_ber_sequence.to_s.to_ber, + rfc2696_cookie.map(&:to_ber).to_ber_sequence.to_s.to_ber, ].to_ber_sequence if paged controls << ber_sort if ber_sort controls = controls.empty? ? nil : controls.to_ber_contextspecific(0) @@ -604,7 +604,7 @@ def add(args) add_dn = args[:dn] or raise Net::LDAP::EmptyDNError, "Unable to add empty DN" add_attrs = [] a = args[:attributes] and a.each do |k, v| - add_attrs << [k.to_s.to_ber, Array(v).map { |m| m.to_ber}.to_ber_set].to_ber_sequence + add_attrs << [k.to_s.to_ber, Array(v).map(&:to_ber).to_ber_set].to_ber_sequence end message_id = next_msgid diff --git a/lib/net/ldap/dataset.rb b/lib/net/ldap/dataset.rb index 47810ce7..9027ed28 100644 --- a/lib/net/ldap/dataset.rb +++ b/lib/net/ldap/dataset.rb @@ -29,7 +29,7 @@ def to_ldif keys.sort.each do |dn| ary << "dn: #{dn}" - attributes = self[dn].keys.map { |attr| attr.to_s }.sort + attributes = self[dn].keys.map(&:to_s).sort attributes.each do |attr| self[dn][attr.to_sym].each do |value| if attr == "userpassword" or value_is_binary?(value) diff --git a/lib/net/ldap/filter.rb b/lib/net/ldap/filter.rb index 084b997d..7f418ae3 100644 --- a/lib/net/ldap/filter.rb +++ b/lib/net/ldap/filter.rb @@ -550,10 +550,10 @@ def to_ber [self.class.eq(@left, @right).to_ber].to_ber_contextspecific(2) when :and ary = [@left.coalesce(:and), @right.coalesce(:and)].flatten - ary.map {|a| a.to_ber}.to_ber_contextspecific(0) + ary.map(&:to_ber).to_ber_contextspecific(0) when :or ary = [@left.coalesce(:or), @right.coalesce(:or)].flatten - ary.map {|a| a.to_ber}.to_ber_contextspecific(1) + ary.map(&:to_ber).to_ber_contextspecific(1) when :not [@left.to_ber].to_ber_contextspecific(2) end diff --git a/test/ber/test_ber.rb b/test/ber/test_ber.rb index c2f5a568..5d5c1266 100644 --- a/test/ber/test_ber.rb +++ b/test/ber/test_ber.rb @@ -7,7 +7,7 @@ def test_empty_array def test_array ary = [1, 2, 3] - encoded_ary = ary.map { |el| el.to_ber }.to_ber + encoded_ary = ary.map(&:to_ber).to_ber assert_equal ary, encoded_ary.read_ber end diff --git a/testserver/ldapserver.rb b/testserver/ldapserver.rb index eb0c40d3..809f9e7e 100644 --- a/testserver/ldapserver.rb +++ b/testserver/ldapserver.rb @@ -119,7 +119,7 @@ def handle_search_request pdu # pdu[1][7] is the list of requested attributes. # If it's an empty array, that means that *all* attributes were requested. requested_attrs = if pdu[1][7].length > 0 - pdu[1][7].map {|a| a.downcase} + pdu[1][7].map(&:downcase) else :all end @@ -138,7 +138,7 @@ def handle_search_request pdu attrs = [] entry.each do |k, v| if requested_attrs == :all or requested_attrs.include?(k.downcase) - attrvals = v.map {|v1| v1.to_ber}.to_ber_set + attrvals = v.map(&:to_ber).to_ber_set attrs << [k.to_ber, attrvals].to_ber_sequence end end