Skip to content

Commit cfd990e

Browse files
committed
Merge pull request #255 from mynameisrufus/rubocop-fix/symbol-proc
fix symbol proc
2 parents f1659c5 + bf9c251 commit cfd990e

File tree

8 files changed

+10
-24
lines changed

8 files changed

+10
-24
lines changed

.rubocop_todo.yml

-14
Original file line numberDiff line numberDiff line change
@@ -578,20 +578,6 @@ Style/SpecialGlobalVars:
578578
Style/StringLiterals:
579579
Enabled: false
580580

581-
# Offense count: 11
582-
# Cop supports --auto-correct.
583-
# Configuration parameters: IgnoredMethods.
584-
Style/SymbolProc:
585-
Exclude:
586-
- 'lib/net/ber.rb'
587-
- 'lib/net/ber/core_ext/array.rb'
588-
- 'lib/net/ldap/connection.rb'
589-
- 'lib/net/ldap/dataset.rb'
590-
- 'lib/net/ldap/filter.rb'
591-
- 'test/ber/test_ber.rb'
592-
- 'test/test_ldif.rb'
593-
- 'testserver/ldapserver.rb'
594-
595581
# Offense count: 5
596582
# Cop supports --auto-correct.
597583
Style/UnneededPercentQ:

lib/net/ber.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class Net::BER::BerIdentifiedOid
270270

271271
def initialize(oid)
272272
if oid.is_a?(String)
273-
oid = oid.split(/\./).map {|s| s.to_i }
273+
oid = oid.split(/\./).map(&:to_i)
274274
end
275275
@value = oid
276276
end

lib/net/ber/core_ext/array.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def to_ber_control
8989
#if our array does not contain at least one array then wrap it in an array before going forward
9090
ary = self[0].kind_of?(Array) ? self : [self]
9191
ary = ary.collect do |control_sequence|
92-
control_sequence.collect{|element| element.to_ber}.to_ber_sequence.reject_empty_ber_arrays
92+
control_sequence.collect(&:to_ber).to_ber_sequence.reject_empty_ber_arrays
9393
end
9494
ary.to_ber_sequence.reject_empty_ber_arrays
9595
end

lib/net/ldap/connection.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ def search(args = nil)
409409
Net::LDAP::LDAPControls::PAGED_RESULTS.to_ber,
410410
# Criticality MUST be false to interoperate with normal LDAPs.
411411
false.to_ber,
412-
rfc2696_cookie.map{ |v| v.to_ber}.to_ber_sequence.to_s.to_ber,
412+
rfc2696_cookie.map(&:to_ber).to_ber_sequence.to_s.to_ber,
413413
].to_ber_sequence if paged
414414
controls << ber_sort if ber_sort
415415
controls = controls.empty? ? nil : controls.to_ber_contextspecific(0)
@@ -604,7 +604,7 @@ def add(args)
604604
add_dn = args[:dn] or raise Net::LDAP::EmptyDNError, "Unable to add empty DN"
605605
add_attrs = []
606606
a = args[:attributes] and a.each do |k, v|
607-
add_attrs << [k.to_s.to_ber, Array(v).map { |m| m.to_ber}.to_ber_set].to_ber_sequence
607+
add_attrs << [k.to_s.to_ber, Array(v).map(&:to_ber).to_ber_set].to_ber_sequence
608608
end
609609

610610
message_id = next_msgid

lib/net/ldap/dataset.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def to_ldif
2929
keys.sort.each do |dn|
3030
ary << "dn: #{dn}"
3131

32-
attributes = self[dn].keys.map { |attr| attr.to_s }.sort
32+
attributes = self[dn].keys.map(&:to_s).sort
3333
attributes.each do |attr|
3434
self[dn][attr.to_sym].each do |value|
3535
if attr == "userpassword" or value_is_binary?(value)

lib/net/ldap/filter.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -550,10 +550,10 @@ def to_ber
550550
[self.class.eq(@left, @right).to_ber].to_ber_contextspecific(2)
551551
when :and
552552
ary = [@left.coalesce(:and), @right.coalesce(:and)].flatten
553-
ary.map {|a| a.to_ber}.to_ber_contextspecific(0)
553+
ary.map(&:to_ber).to_ber_contextspecific(0)
554554
when :or
555555
ary = [@left.coalesce(:or), @right.coalesce(:or)].flatten
556-
ary.map {|a| a.to_ber}.to_ber_contextspecific(1)
556+
ary.map(&:to_ber).to_ber_contextspecific(1)
557557
when :not
558558
[@left.to_ber].to_ber_contextspecific(2)
559559
end

test/ber/test_ber.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def test_empty_array
77

88
def test_array
99
ary = [1, 2, 3]
10-
encoded_ary = ary.map { |el| el.to_ber }.to_ber
10+
encoded_ary = ary.map(&:to_ber).to_ber
1111

1212
assert_equal ary, encoded_ary.read_ber
1313
end

testserver/ldapserver.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def handle_search_request pdu
119119
# pdu[1][7] is the list of requested attributes.
120120
# If it's an empty array, that means that *all* attributes were requested.
121121
requested_attrs = if pdu[1][7].length > 0
122-
pdu[1][7].map {|a| a.downcase}
122+
pdu[1][7].map(&:downcase)
123123
else
124124
:all
125125
end
@@ -138,7 +138,7 @@ def handle_search_request pdu
138138
attrs = []
139139
entry.each do |k, v|
140140
if requested_attrs == :all or requested_attrs.include?(k.downcase)
141-
attrvals = v.map {|v1| v1.to_ber}.to_ber_set
141+
attrvals = v.map(&:to_ber).to_ber_set
142142
attrs << [k.to_ber, attrvals].to_ber_sequence
143143
end
144144
end

0 commit comments

Comments
 (0)