Skip to content

Commit

Permalink
Merge pull request #256 from mynameisrufus/rubocop-fix/trailing-comma
Browse files Browse the repository at this point in the history
fix trailing commas
  • Loading branch information
jch committed Jan 13, 2016
2 parents 15049c5 + 9d62403 commit f1659c5
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 56 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ Lint/AssignmentInCondition:

Style/ParallelAssignment:
Enabled: false

Style/TrailingComma:
EnforcedStyleForMultiline: comma
14 changes: 0 additions & 14 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -592,20 +592,6 @@ Style/SymbolProc:
- 'test/test_ldif.rb'
- 'testserver/ldapserver.rb'

# Offense count: 12
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
Style/TrailingComma:
Exclude:
- 'lib/net/ldap.rb'
- 'lib/net/ldap/dn.rb'
- 'lib/net/snmp.rb'
- 'test/ber/test_ber.rb'
- 'test/test_dn.rb'
- 'test/test_filter.rb'
- 'test/test_ldap_connection.rb'
- 'testserver/ldapserver.rb'

# Offense count: 5
# Cop supports --auto-correct.
Style/UnneededPercentQ:
Expand Down
2 changes: 1 addition & 1 deletion lib/net/ber/ber_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Net::BER::BERParser
}
constructed = {
16 => :array,
17 => :array
17 => :array,
}
universal = { :primitive => primitive, :constructed => constructed }

Expand Down
16 changes: 8 additions & 8 deletions lib/net/ldap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ class Net::LDAP

universal = {
constructed: {
107 => :array #ExtendedResponse (PasswdModifyResponseValue)
}
107 => :array, #ExtendedResponse (PasswdModifyResponseValue)
},
}

AsnSyntax = Net::BER.compile_syntax(:application => application,
Expand Down Expand Up @@ -389,14 +389,14 @@ class Net::LDAP
ResultCodeCompareFalse,
ResultCodeCompareTrue,
ResultCodeReferral,
ResultCodeSaslBindInProgress
ResultCodeSaslBindInProgress,
]

# nonstandard list of "successful" result codes for searches
ResultCodesSearchSuccess = [
ResultCodeSuccess,
ResultCodeTimeLimitExceeded,
ResultCodeSizeLimitExceeded
ResultCodeSizeLimitExceeded,
]

# map of result code to human message
Expand Down Expand Up @@ -438,7 +438,7 @@ class Net::LDAP
ResultCodeEntryAlreadyExists => "Entry Already Exists",
ResultCodeObjectClassModsProhibited => "ObjectClass Modifications Prohibited",
ResultCodeAffectsMultipleDSAs => "Affects Multiple DSAs",
ResultCodeOther => "Other"
ResultCodeOther => "Other",
}

module LDAPControls
Expand Down Expand Up @@ -591,7 +591,7 @@ def authenticate(username, password)
@auth = {
:method => :simple,
:username => username,
:password => password
:password => password,
}
end
alias_method :auth, :authenticate
Expand Down Expand Up @@ -1208,7 +1208,7 @@ def search_root_dse
:supportedExtension,
:supportedFeatures,
:supportedLdapVersion,
:supportedSASLMechanisms
:supportedSASLMechanisms,
])
(rs and rs.first) or Net::LDAP::Entry.new
end
Expand Down Expand Up @@ -1319,7 +1319,7 @@ def new_connection
rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT, Net::LDAP::ConnectionRefusedError => e
@result = {
:resultCode => 52,
:errorMessage => ResultStrings[ResultCodeUnavailable]
:errorMessage => ResultStrings[ResultCodeUnavailable],
}
raise e
end
Expand Down
14 changes: 7 additions & 7 deletions lib/net/ldap/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def open_connection(server)
encryption = server[:encryption]

socket_opts = {
connect_timeout: server[:connect_timeout] || DefaultConnectTimeout
connect_timeout: server[:connect_timeout] || DefaultConnectTimeout,
}

errors = []
Expand Down Expand Up @@ -133,7 +133,7 @@ def setup_encryption(args)
when :start_tls
message_id = next_msgid
request = [
Net::LDAP::StartTlsOid.to_ber_contextspecific(0)
Net::LDAP::StartTlsOid.to_ber_contextspecific(0),
].to_ber_appsequence(Net::LDAP::PDU::ExtendedRequest)

write(request, nil, message_id)
Expand Down Expand Up @@ -283,7 +283,7 @@ def encode_sort_controls(sort_definitions)
sort_control = [
Net::LDAP::LDAPControls::SORT_REQUEST.to_ber,
false.to_ber,
sort_control_values.to_ber_sequence.to_s.to_ber
sort_control_values.to_ber_sequence.to_s.to_ber,
].to_ber_sequence
end

Expand Down Expand Up @@ -396,7 +396,7 @@ def search(args = nil)
time.to_ber,
attrs_only.to_ber,
filter.to_ber,
ber_attrs.to_ber_sequence
ber_attrs.to_ber_sequence,
].to_ber_appsequence(Net::LDAP::PDU::SearchRequest)

# rfc2696_cookie sometimes contains binary data from Microsoft Active Directory
Expand All @@ -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{ |v| v.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)
Expand Down Expand Up @@ -503,7 +503,7 @@ def search(args = nil)
MODIFY_OPERATIONS = { #:nodoc:
:add => 0,
:delete => 1,
:replace => 2
:replace => 2,
}

def self.modify_ops(operations)
Expand Down Expand Up @@ -535,7 +535,7 @@ def modify(args)
message_id = next_msgid
request = [
modify_dn.to_ber,
ops.to_ber_sequence
ops.to_ber_sequence,
].to_ber_appsequence(Net::LDAP::PDU::ModifyRequest)

write(request, nil, message_id)
Expand Down
4 changes: 2 additions & 2 deletions lib/net/ldap/pdu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def parse_ldap_result(sequence)
@ldap_result = {
:resultCode => sequence[0],
:matchedDN => sequence[1],
:errorMessage => sequence[2]
:errorMessage => sequence[2],
}
parse_search_referral(sequence[3]) if @ldap_result[:resultCode] == Net::LDAP::ResultCodeReferral
end
Expand All @@ -198,7 +198,7 @@ def parse_extended_response(sequence)
@ldap_result = {
:resultCode => sequence[0],
:matchedDN => sequence[1],
:errorMessage => sequence[2]
:errorMessage => sequence[2],
}
@extended_response = sequence[3]
end
Expand Down
22 changes: 11 additions & 11 deletions lib/net/snmp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ class SNMP
2 => :integer, # Gauge32 or Unsigned32, (RFC2578 sec 2)
3 => :integer # TimeTicks32, (RFC2578 sec 2)
},
:constructed => {}
:constructed => {},
},
:context_specific => {
:primitive => {},
:constructed => {
0 => :array, # GetRequest PDU (RFC1157 pgh 4.1.2)
1 => :array, # GetNextRequest PDU (RFC1157 pgh 4.1.3)
2 => :array # GetResponse PDU (RFC1157 pgh 4.1.4)
}
}
},
},
})

# SNMP 32-bit counter.
Expand Down Expand Up @@ -70,15 +70,15 @@ class Error < StandardError; end
:get_next_request,
:get_response,
:set_request,
:trap
:trap,
]
ErrorStatusCodes = { # Per RFC1157, pgh 4.1.1
0 => "noError",
1 => "tooBig",
2 => "noSuchName",
3 => "badValue",
4 => "readOnly",
5 => "genErr"
5 => "genErr",
}

class << self
Expand Down Expand Up @@ -229,8 +229,8 @@ def pdu_to_ber_string
[
@variables.map do|n, v|
[n.to_ber_oid, Net::BER::BerIdentifiedNull.new.to_ber].to_ber_sequence
end
].to_ber_sequence
end,
].to_ber_sequence,
].to_ber_contextspecific(0)
when :get_next_request
[
Expand All @@ -240,8 +240,8 @@ def pdu_to_ber_string
[
@variables.map do|n, v|
[n.to_ber_oid, Net::BER::BerIdentifiedNull.new.to_ber].to_ber_sequence
end
].to_ber_sequence
end,
].to_ber_sequence,
].to_ber_contextspecific(1)
when :get_response
[
Expand All @@ -251,8 +251,8 @@ def pdu_to_ber_string
[
@variables.map do|n, v|
[n.to_ber_oid, v.to_ber].to_ber_sequence
end
].to_ber_sequence
end,
].to_ber_sequence,
].to_ber_contextspecific(2)
else
raise Error.new( "unknown pdu-type: #{pdu_type}" )
Expand Down
2 changes: 1 addition & 1 deletion test/integration/test_add.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_add
uid: "added-user1",
cn: "added-user1",
sn: "added-user1",
mail: "added-user1@rubyldap.com"
mail: "added-user1@rubyldap.com",
}

assert @ldap.add(dn: @dn, attributes: attrs), @ldap.get_operation_result.inspect
Expand Down
2 changes: 1 addition & 1 deletion test/integration/test_ber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_true_ber_encoding
filter: "(uid=user1)",
size: 1,
attributes: attrs,
attributes_only: true
attributes_only: true,
).first

# matches attributes we requested
Expand Down
2 changes: 1 addition & 1 deletion test/integration/test_delete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def setup
uid: "delete-user1",
cn: "delete-user1",
sn: "delete-user1",
mail: "delete-user1@rubyldap.com"
mail: "delete-user1@rubyldap.com",
}
unless @ldap.search(base: @dn, scope: Net::LDAP::SearchScope_BaseObject)
assert @ldap.add(dn: @dn, attributes: attrs), @ldap.get_operation_result.inspect
Expand Down
2 changes: 1 addition & 1 deletion test/integration/test_open.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_nested_add_with_open
uid: "nested-open-added-user1",
cn: "nested-open-added-user1",
sn: "nested-open-added-user1",
mail: "nested-open-added-user1@rubyldap.com"
mail: "nested-open-added-user1@rubyldap.com",
}

@ldap.authenticate "cn=admin,dc=rubyldap,dc=com", "passworD1"
Expand Down
4 changes: 2 additions & 2 deletions test/integration/test_password_modify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def setup
cn: 'modify-password-user1',
sn: 'modify-password-user1',
mail: 'modify-password-user1@rubyldap.com',
userPassword: 'passworD1'
userPassword: 'passworD1',
}
unless @ldap.search(base: @dn, scope: Net::LDAP::SearchScope_BaseObject)
assert @ldap.add(dn: @dn, attributes: attrs), @ldap.get_operation_result.inspect
Expand All @@ -23,7 +23,7 @@ def setup
@auth = {
method: :simple,
username: @dn,
password: 'passworD1'
password: 'passworD1',
}
end

Expand Down
4 changes: 2 additions & 2 deletions test/test_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def test_ber_conversion
'(:dn:2.4.8.10:=Dino)',
'(cn:dn:1.2.3.4.5:=John Smith)',
'(sn:dn:2.4.6.8.10:=Barbara Jones)',
'(&(sn:dn:2.4.6.8.10:=Barbara Jones))'
'(&(sn:dn:2.4.6.8.10:=Barbara Jones))',
].each_with_index do |filter_str, index|
define_method "test_decode_filter_#{index}" do
filter = Net::LDAP::Filter.from_rfc2254(filter_str)
Expand Down Expand Up @@ -195,7 +195,7 @@ def test_well_known_ber_string
"foo" "\\2A\\5C" "bar",
"foo" "\\2a\\5c" "bar",
"foo" "\\2A\\5c" "bar",
"foo" "\\2a\\5C" "bar"
"foo" "\\2a\\5C" "bar",
].each do |escaped|
# unescapes escaped characters
filter = Net::LDAP::Filter.eq("objectclass", "#{escaped}*#{escaped}*#{escaped}")
Expand Down
6 changes: 3 additions & 3 deletions test/test_ldap_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def make_message(message_id, options = {})
app_tag: Net::LDAP::PDU::SearchResult,
code: Net::LDAP::ResultCodeSuccess,
matched_dn: "",
error_message: ""
error_message: "",
}.merge(options)
result = Net::BER::BerIdentifiedArray.new([options[:code], options[:matched_dn], options[:error_message]])
result.ber_identifier = options[:app_tag]
Expand Down Expand Up @@ -257,7 +257,7 @@ def test_queued_read_rename

assert result = conn.rename(
olddn: "uid=renamable-user1,ou=People,dc=rubyldap,dc=com",
newrdn: "uid=renamed-user1"
newrdn: "uid=renamed-user1",
)
assert result.success?
assert_equal 2, result.message_id
Expand Down Expand Up @@ -463,7 +463,7 @@ def test_search_net_ldap_connection_event
# search data
search_data_ber = Net::BER::BerIdentifiedArray.new([1, [
"uid=user1,ou=People,dc=rubyldap,dc=com",
[["uid", ["user1"]]]
[["uid", ["user1"]]],
]])
search_data_ber.ber_identifier = Net::LDAP::PDU::SearchReturnedData
search_data = [1, search_data_ber]
Expand Down
4 changes: 2 additions & 2 deletions testserver/ldapserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module LdapServer
},
:primitive => {
2 => :string, # ldapsearch sends this to unbind
}
},
},
:context_specific => {
:primitive => {
Expand All @@ -34,7 +34,7 @@ module LdapServer
:constructed => {
3 => :array # equality filter
},
}
},
}

def post_init
Expand Down

0 comments on commit f1659c5

Please sign in to comment.