Skip to content

Commit 30e4167

Browse files
committed
Enhance rubocop and tests syntax
Signed-off-by: Florian Wininger <[email protected]>
1 parent 148c045 commit 30e4167

14 files changed

+103
-179
lines changed

.rubocop_todo.yml

+16-85
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2020-01-31 16:08:44 +0100 using RuboCop version 0.49.1.
3+
# on 2020-01-31 16:17:37 +0100 using RuboCop version 0.49.1.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -14,17 +14,6 @@ Layout/AlignArray:
1414
- 'lib/net/ldap/auth_adapter/sasl.rb'
1515
- 'lib/net/ldap/connection.rb'
1616

17-
# Offense count: 12
18-
# Cop supports --auto-correct.
19-
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
20-
# SupportedStyles: with_first_parameter, with_fixed_indentation
21-
Layout/AlignParameters:
22-
Exclude:
23-
- 'test/ber/test_ber.rb'
24-
- 'test/integration/test_ber.rb'
25-
- 'test/integration/test_bind.rb'
26-
- 'test/integration/test_password_modify.rb'
27-
2817
# Offense count: 4
2918
# Cop supports --auto-correct.
3019
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentOneStep, IndentationWidth.
@@ -33,69 +22,41 @@ Layout/CaseIndentation:
3322
Exclude:
3423
- 'lib/net/ldap/filter.rb'
3524

36-
# Offense count: 19
37-
# Cop supports --auto-correct.
38-
# Configuration parameters: EnforcedStyle, SupportedStyles.
39-
# SupportedStyles: leading, trailing
40-
Layout/DotPosition:
41-
Exclude:
42-
- 'test/test_ldap_connection.rb'
43-
- 'test/test_ssl_ber.rb'
44-
4525
# Offense count: 1
4626
# Cop supports --auto-correct.
47-
Layout/ElseAlignment:
48-
Exclude:
49-
- 'testserver/ldapserver.rb'
50-
51-
# Offense count: 2
52-
# Cop supports --auto-correct.
5327
Layout/EmptyLineAfterMagicComment:
5428
Exclude:
5529
- 'net-ldap.gemspec'
56-
- 'test/test_filter_parser.rb'
5730

58-
# Offense count: 7
31+
# Offense count: 5
5932
# Cop supports --auto-correct.
6033
# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines.
6134
Layout/EmptyLineBetweenDefs:
6235
Exclude:
6336
- 'lib/net/ldap.rb'
6437
- 'lib/net/ldap/dataset.rb'
6538
- 'lib/net/snmp.rb'
66-
- 'testserver/ldapserver.rb'
6739

68-
# Offense count: 8
40+
# Offense count: 1
6941
# Cop supports --auto-correct.
7042
Layout/EmptyLines:
7143
Exclude:
7244
- 'lib/net/snmp.rb'
73-
- 'testserver/ldapserver.rb'
7445

75-
# Offense count: 3
46+
# Offense count: 1
7647
# Cop supports --auto-correct.
7748
# Configuration parameters: EnforcedStyle, SupportedStyles.
7849
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
7950
Layout/EmptyLinesAroundClassBody:
8051
Exclude:
8152
- 'lib/net/ldap.rb'
82-
- 'test/integration/test_bind.rb'
83-
- 'test/test_snmp.rb'
8453

8554
# Offense count: 1
8655
# Cop supports --auto-correct.
8756
Layout/EmptyLinesAroundExceptionHandlingKeywords:
8857
Exclude:
8958
- 'lib/net/ldap/connection.rb'
9059

91-
# Offense count: 2
92-
# Cop supports --auto-correct.
93-
# Configuration parameters: EnforcedStyle, SupportedStyles.
94-
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
95-
Layout/EmptyLinesAroundModuleBody:
96-
Exclude:
97-
- 'testserver/ldapserver.rb'
98-
9960
# Offense count: 2
10061
# Cop supports --auto-correct.
10162
# Configuration parameters: SupportedStyles, IndentationWidth.
@@ -110,16 +71,14 @@ Layout/IndentArray:
11071
Layout/IndentHash:
11172
EnforcedStyle: consistent
11273

113-
# Offense count: 10
74+
# Offense count: 6
11475
# Cop supports --auto-correct.
11576
# Configuration parameters: Width, IgnoredPatterns.
11677
Layout/IndentationWidth:
11778
Exclude:
11879
- 'lib/net/ber.rb'
11980
- 'lib/net/ldap/password.rb'
12081
- 'lib/net/snmp.rb'
121-
- 'test/test_snmp.rb'
122-
- 'testserver/ldapserver.rb'
12382

12483
# Offense count: 3
12584
# Cop supports --auto-correct.
@@ -129,23 +88,13 @@ Layout/LeadingCommentSpace:
12988
- 'lib/net/ldap.rb'
13089
- 'lib/net/ldap/connection.rb'
13190

132-
# Offense count: 4
91+
# Offense count: 1
13392
# Cop supports --auto-correct.
13493
# Configuration parameters: EnforcedStyle, SupportedStyles.
13594
# SupportedStyles: symmetrical, new_line, same_line
13695
Layout/MultilineMethodCallBraceLayout:
13796
Exclude:
13897
- 'lib/net/ldap/filter.rb'
139-
- 'test/test_entry.rb'
140-
- 'test/test_ldap_connection.rb'
141-
142-
# Offense count: 1
143-
# Cop supports --auto-correct.
144-
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
145-
# SupportedStyles: aligned, indented, indented_relative_to_receiver
146-
Layout/MultilineMethodCallIndentation:
147-
Exclude:
148-
- 'test/test_ldap_connection.rb'
14998

15099
# Offense count: 5
151100
# Cop supports --auto-correct.
@@ -163,7 +112,7 @@ Layout/SpaceAroundKeyword:
163112
- 'lib/net/ldap/entry.rb'
164113
- 'lib/net/snmp.rb'
165114

166-
# Offense count: 9
115+
# Offense count: 7
167116
# Cop supports --auto-correct.
168117
# Configuration parameters: AllowForAlignment.
169118
Layout/SpaceAroundOperators:
@@ -172,39 +121,30 @@ Layout/SpaceAroundOperators:
172121
- 'lib/net/ldap/connection.rb'
173122
- 'lib/net/ldap/entry.rb'
174123
- 'lib/net/ldap/filter.rb'
175-
- 'test/test_entry.rb'
176-
- 'test/test_ldap_connection.rb'
177124

178-
# Offense count: 5
125+
# Offense count: 1
179126
# Cop supports --auto-correct.
180127
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces, SpaceBeforeBlockParameters.
181128
# SupportedStyles: space, no_space
182129
# SupportedStylesForEmptyBraces: space, no_space
183130
Layout/SpaceInsideBlockBraces:
184131
Exclude:
185132
- 'lib/net/ldap/dataset.rb'
186-
- 'test/test_snmp.rb'
187-
- 'testserver/ldapserver.rb'
188133

189-
# Offense count: 15
134+
# Offense count: 1
190135
# Cop supports --auto-correct.
191-
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces.
136+
# Configuration parameters: SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces.
192137
# SupportedStyles: space, no_space, compact
193138
# SupportedStylesForEmptyBraces: space, no_space
194139
Layout/SpaceInsideHashLiteralBraces:
195-
Exclude:
196-
- 'lib/net/ldap/dataset.rb'
197-
- 'test/integration/test_password_modify.rb'
198-
- 'test/test_ldap.rb'
140+
EnforcedStyle: space
199141

200-
# Offense count: 20
142+
# Offense count: 8
201143
# Cop supports --auto-correct.
202144
Layout/SpaceInsideParens:
203145
Exclude:
204146
- 'lib/net/ldap/entry.rb'
205147
- 'lib/net/snmp.rb'
206-
- 'test/test_password.rb'
207-
- 'testserver/ldapserver.rb'
208148

209149
# Offense count: 1
210150
Lint/AmbiguousBlockAssociation:
@@ -302,7 +242,7 @@ Metrics/ClassLength:
302242
Metrics/CyclomaticComplexity:
303243
Max: 41
304244

305-
# Offense count: 214
245+
# Offense count: 215
306246
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
307247
# URISchemes: http, https
308248
Metrics/LineLength:
@@ -316,7 +256,7 @@ Metrics/MethodLength:
316256
# Offense count: 1
317257
# Configuration parameters: CountComments.
318258
Metrics/ModuleLength:
319-
Max: 104
259+
Max: 103
320260

321261
# Offense count: 15
322262
Metrics/PerceivedComplexity:
@@ -339,7 +279,7 @@ Style/Alias:
339279
- 'lib/net/ldap/filter.rb'
340280
- 'lib/net/ldap/pdu.rb'
341281

342-
# Offense count: 37
282+
# Offense count: 33
343283
# Cop supports --auto-correct.
344284
# Configuration parameters: EnforcedStyle, SupportedStyles.
345285
# SupportedStyles: always, conditionals
@@ -351,7 +291,6 @@ Style/AndOr:
351291
- 'lib/net/ldap/dataset.rb'
352292
- 'lib/net/ldap/filter.rb'
353293
- 'lib/net/ldap/pdu.rb'
354-
- 'testserver/ldapserver.rb'
355294

356295
# Offense count: 1
357296
# Cop supports --auto-correct.
@@ -367,15 +306,14 @@ Style/BlockComments:
367306
Exclude:
368307
- 'test/test_rename.rb'
369308

370-
# Offense count: 6
309+
# Offense count: 2
371310
# Cop supports --auto-correct.
372311
# Configuration parameters: EnforcedStyle, SupportedStyles.
373312
# SupportedStyles: braces, no_braces, context_dependent
374313
Style/BracesAroundHashParameters:
375314
Exclude:
376315
- 'lib/net/ldap/auth_adapter/gss_spnego.rb'
377316
- 'lib/net/snmp.rb'
378-
- 'test/test_ldap.rb'
379317

380318
# Offense count: 4
381319
# Cop supports --auto-correct.
@@ -404,13 +342,6 @@ Style/ClassCheck:
404342
- 'lib/net/ber/core_ext/array.rb'
405343
- 'lib/net/ldap/error.rb'
406344

407-
# Offense count: 13
408-
# Cop supports --auto-correct.
409-
Style/ColonMethodCall:
410-
Exclude:
411-
- 'test/test_ldif.rb'
412-
- 'test/test_ssl_ber.rb'
413-
414345
# Offense count: 1
415346
# Cop supports --auto-correct.
416347
# Configuration parameters: Keywords.

test/ber/test_ber.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def test_utf8_encodable_strings
9595
def test_encode_binary_data
9696
# This is used for searching for GUIDs in Active Directory
9797
assert_equal "\x04\x10" + "j1\xB4\xA1*\xA2zA\xAC\xA9`?'\xDDQ\x16".b,
98-
["6a31b4a12aa27a41aca9603f27dd5116"].pack("H*").to_ber_bin
98+
["6a31b4a12aa27a41aca9603f27dd5116"].pack("H*").to_ber_bin
9999
end
100100

101101
def test_non_utf8_encodable_strings

test/integration/test_ber.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ def test_true_ber_encoding
2525
end
2626

2727
assert_includes Net::LDAP::ResultCodesSearchSuccess,
28-
@ldap.get_operation_result.code, "should be a successful search operation"
28+
@ldap.get_operation_result.code, "should be a successful search operation"
2929
end
3030
end

test/integration/test_bind.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require_relative '../test_helper'
22

33
class TestBindIntegration < LDAPIntegrationTestCase
4-
54
INTEGRATION_HOSTNAME = 'ldap.example.org'.freeze
65

76
def test_bind_success
@@ -28,7 +27,7 @@ def test_bind_anonymous_fail
2827
assert_equal Net::LDAP::ResultCodeUnwillingToPerform, result.code
2928
assert_equal Net::LDAP::ResultStrings[Net::LDAP::ResultCodeUnwillingToPerform], result.message
3029
assert_equal "unauthenticated bind (DN with no password) disallowed",
31-
result.error_message
30+
result.error_message
3231
assert_equal "", result.matched_dn
3332
end
3433

test/integration/test_password_modify.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class TestPasswordModifyIntegration < LDAPIntegrationTestCase
44
def setup
55
super
6-
@admin_account = {dn: 'cn=admin,dc=example,dc=org', password: 'admin', method: :simple}
6+
@admin_account = { dn: 'cn=admin,dc=example,dc=org', password: 'admin', method: :simple }
77
@ldap.authenticate @admin_account[:dn], @admin_account[:password]
88

99
@dn = 'uid=modify-password-user1,ou=People,dc=example,dc=org'
@@ -35,13 +35,13 @@ def test_password_modify
3535
new_password: 'passworD2')
3636

3737
assert @ldap.get_operation_result.extended_response.nil?,
38-
'Should not have generated a new password'
38+
'Should not have generated a new password'
3939

4040
refute @ldap.bind(username: @dn, password: 'admin', method: :simple),
41-
'Old password should no longer be valid'
41+
'Old password should no longer be valid'
4242

4343
assert @ldap.bind(username: @dn, password: 'passworD2', method: :simple),
44-
'New password should be valid'
44+
'New password should be valid'
4545
end
4646

4747
def test_password_modify_generate
@@ -54,10 +54,10 @@ def test_password_modify_generate
5454
assert generated_password, 'Should have generated a password'
5555

5656
refute @ldap.bind(username: @dn, password: 'admin', method: :simple),
57-
'Old password should no longer be valid'
57+
'Old password should no longer be valid'
5858

5959
assert @ldap.bind(username: @dn, password: generated_password, method: :simple),
60-
'New password should be valid'
60+
'New password should be valid'
6161
end
6262

6363
def test_password_modify_generate_no_old_password
@@ -69,10 +69,10 @@ def test_password_modify_generate_no_old_password
6969
assert generated_password, 'Should have generated a password'
7070

7171
refute @ldap.bind(username: @dn, password: 'admin', method: :simple),
72-
'Old password should no longer be valid'
72+
'Old password should no longer be valid'
7373

7474
assert @ldap.bind(username: @dn, password: generated_password, method: :simple),
75-
'New password should be valid'
75+
'New password should be valid'
7676
end
7777

7878
def test_password_modify_overwrite_old_password
@@ -81,10 +81,10 @@ def test_password_modify_overwrite_old_password
8181
new_password: 'passworD3')
8282

8383
refute @ldap.bind(username: @dn, password: 'admin', method: :simple),
84-
'Old password should no longer be valid'
84+
'Old password should no longer be valid'
8585

8686
assert @ldap.bind(username: @dn, password: 'passworD3', method: :simple),
87-
'New password should be valid'
87+
'New password should be valid'
8888
end
8989

9090
def teardown

test/test_entry.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def setup
4747
%Q{dn: something
4848
foo: foo
4949
barAttribute: bar
50-
})
50+
},
51+
)
5152
end
5253

5354
def test_attribute
@@ -59,7 +60,7 @@ def test_modify_attribute
5960
@entry.foo = 'bar'
6061
assert_equal ['bar'], @entry.foo
6162

62-
@entry.fOo= 'baz'
63+
@entry.fOo = 'baz'
6364
assert_equal ['baz'], @entry.foo
6465
end
6566
end

test/test_filter_parser.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# encoding: utf-8
2+
23
require_relative 'test_helper'
34

45
class TestFilterParser < Test::Unit::TestCase

0 commit comments

Comments
 (0)