Skip to content

Commit bf9c251

Browse files
jchmynameisrufus
authored andcommitted
fix symbol proc
2 parents 15049c5 + 9d62403 commit bf9c251

20 files changed

+54
-79
lines changed

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ Lint/AssignmentInCondition:
1212

1313
Style/ParallelAssignment:
1414
Enabled: false
15+
16+
Style/TrailingComma:
17+
EnforcedStyleForMultiline: comma

.rubocop_todo.yml

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -578,34 +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-
595-
# Offense count: 12
596-
# Cop supports --auto-correct.
597-
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
598-
Style/TrailingComma:
599-
Exclude:
600-
- 'lib/net/ldap.rb'
601-
- 'lib/net/ldap/dn.rb'
602-
- 'lib/net/snmp.rb'
603-
- 'test/ber/test_ber.rb'
604-
- 'test/test_dn.rb'
605-
- 'test/test_filter.rb'
606-
- 'test/test_ldap_connection.rb'
607-
- 'testserver/ldapserver.rb'
608-
609581
# Offense count: 5
610582
# Cop supports --auto-correct.
611583
Style/UnneededPercentQ:

lib/net/ber.rb

Lines changed: 1 addition & 1 deletion
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/ber_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module Net::BER::BERParser
1414
}
1515
constructed = {
1616
16 => :array,
17-
17 => :array
17+
17 => :array,
1818
}
1919
universal = { :primitive => primitive, :constructed => constructed }
2020

lib/net/ber/core_ext/array.rb

Lines changed: 1 addition & 1 deletion
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.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ class Net::LDAP
325325

326326
universal = {
327327
constructed: {
328-
107 => :array #ExtendedResponse (PasswdModifyResponseValue)
329-
}
328+
107 => :array, #ExtendedResponse (PasswdModifyResponseValue)
329+
},
330330
}
331331

332332
AsnSyntax = Net::BER.compile_syntax(:application => application,
@@ -389,14 +389,14 @@ class Net::LDAP
389389
ResultCodeCompareFalse,
390390
ResultCodeCompareTrue,
391391
ResultCodeReferral,
392-
ResultCodeSaslBindInProgress
392+
ResultCodeSaslBindInProgress,
393393
]
394394

395395
# nonstandard list of "successful" result codes for searches
396396
ResultCodesSearchSuccess = [
397397
ResultCodeSuccess,
398398
ResultCodeTimeLimitExceeded,
399-
ResultCodeSizeLimitExceeded
399+
ResultCodeSizeLimitExceeded,
400400
]
401401

402402
# map of result code to human message
@@ -438,7 +438,7 @@ class Net::LDAP
438438
ResultCodeEntryAlreadyExists => "Entry Already Exists",
439439
ResultCodeObjectClassModsProhibited => "ObjectClass Modifications Prohibited",
440440
ResultCodeAffectsMultipleDSAs => "Affects Multiple DSAs",
441-
ResultCodeOther => "Other"
441+
ResultCodeOther => "Other",
442442
}
443443

444444
module LDAPControls
@@ -591,7 +591,7 @@ def authenticate(username, password)
591591
@auth = {
592592
:method => :simple,
593593
:username => username,
594-
:password => password
594+
:password => password,
595595
}
596596
end
597597
alias_method :auth, :authenticate
@@ -1208,7 +1208,7 @@ def search_root_dse
12081208
:supportedExtension,
12091209
:supportedFeatures,
12101210
:supportedLdapVersion,
1211-
:supportedSASLMechanisms
1211+
:supportedSASLMechanisms,
12121212
])
12131213
(rs and rs.first) or Net::LDAP::Entry.new
12141214
end
@@ -1319,7 +1319,7 @@ def new_connection
13191319
rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT, Net::LDAP::ConnectionRefusedError => e
13201320
@result = {
13211321
:resultCode => 52,
1322-
:errorMessage => ResultStrings[ResultCodeUnavailable]
1322+
:errorMessage => ResultStrings[ResultCodeUnavailable],
13231323
}
13241324
raise e
13251325
end

lib/net/ldap/connection.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def open_connection(server)
4444
encryption = server[:encryption]
4545

4646
socket_opts = {
47-
connect_timeout: server[:connect_timeout] || DefaultConnectTimeout
47+
connect_timeout: server[:connect_timeout] || DefaultConnectTimeout,
4848
}
4949

5050
errors = []
@@ -133,7 +133,7 @@ def setup_encryption(args)
133133
when :start_tls
134134
message_id = next_msgid
135135
request = [
136-
Net::LDAP::StartTlsOid.to_ber_contextspecific(0)
136+
Net::LDAP::StartTlsOid.to_ber_contextspecific(0),
137137
].to_ber_appsequence(Net::LDAP::PDU::ExtendedRequest)
138138

139139
write(request, nil, message_id)
@@ -283,7 +283,7 @@ def encode_sort_controls(sort_definitions)
283283
sort_control = [
284284
Net::LDAP::LDAPControls::SORT_REQUEST.to_ber,
285285
false.to_ber,
286-
sort_control_values.to_ber_sequence.to_s.to_ber
286+
sort_control_values.to_ber_sequence.to_s.to_ber,
287287
].to_ber_sequence
288288
end
289289

@@ -396,7 +396,7 @@ def search(args = nil)
396396
time.to_ber,
397397
attrs_only.to_ber,
398398
filter.to_ber,
399-
ber_attrs.to_ber_sequence
399+
ber_attrs.to_ber_sequence,
400400
].to_ber_appsequence(Net::LDAP::PDU::SearchRequest)
401401

402402
# rfc2696_cookie sometimes contains binary data from Microsoft Active Directory
@@ -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)
@@ -503,7 +503,7 @@ def search(args = nil)
503503
MODIFY_OPERATIONS = { #:nodoc:
504504
:add => 0,
505505
:delete => 1,
506-
:replace => 2
506+
:replace => 2,
507507
}
508508

509509
def self.modify_ops(operations)
@@ -535,7 +535,7 @@ def modify(args)
535535
message_id = next_msgid
536536
request = [
537537
modify_dn.to_ber,
538-
ops.to_ber_sequence
538+
ops.to_ber_sequence,
539539
].to_ber_appsequence(Net::LDAP::PDU::ModifyRequest)
540540

541541
write(request, nil, message_id)
@@ -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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

lib/net/ldap/pdu.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def parse_ldap_result(sequence)
175175
@ldap_result = {
176176
:resultCode => sequence[0],
177177
:matchedDN => sequence[1],
178-
:errorMessage => sequence[2]
178+
:errorMessage => sequence[2],
179179
}
180180
parse_search_referral(sequence[3]) if @ldap_result[:resultCode] == Net::LDAP::ResultCodeReferral
181181
end
@@ -198,7 +198,7 @@ def parse_extended_response(sequence)
198198
@ldap_result = {
199199
:resultCode => sequence[0],
200200
:matchedDN => sequence[1],
201-
:errorMessage => sequence[2]
201+
:errorMessage => sequence[2],
202202
}
203203
@extended_response = sequence[3]
204204
end

0 commit comments

Comments
 (0)