From 9d6240317e06d728db123cbbcdb0dacce9638934 Mon Sep 17 00:00:00 2001 From: Jerry Cheung Date: Tue, 12 Jan 2016 10:16:09 -0800 Subject: [PATCH] fix trailing comma Default is to require a trailing comma. --- .rubocop.yml | 3 +++ .rubocop_todo.yml | 14 -------------- lib/net/ber/ber_parser.rb | 2 +- lib/net/ldap.rb | 16 ++++++++-------- lib/net/ldap/connection.rb | 14 +++++++------- lib/net/ldap/pdu.rb | 4 ++-- lib/net/snmp.rb | 22 +++++++++++----------- test/integration/test_add.rb | 2 +- test/integration/test_ber.rb | 2 +- test/integration/test_delete.rb | 2 +- test/integration/test_open.rb | 2 +- test/integration/test_password_modify.rb | 4 ++-- test/test_filter.rb | 4 ++-- test/test_ldap_connection.rb | 6 +++--- testserver/ldapserver.rb | 4 ++-- 15 files changed, 45 insertions(+), 56 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 084ca199..9870d13e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,3 +12,6 @@ Lint/AssignmentInCondition: Style/ParallelAssignment: Enabled: false + +Style/TrailingComma: + EnforcedStyleForMultiline: comma diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 892dfacf..13e5ac59 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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: diff --git a/lib/net/ber/ber_parser.rb b/lib/net/ber/ber_parser.rb index 09de8c82..ee69eed8 100644 --- a/lib/net/ber/ber_parser.rb +++ b/lib/net/ber/ber_parser.rb @@ -14,7 +14,7 @@ module Net::BER::BERParser } constructed = { 16 => :array, - 17 => :array + 17 => :array, } universal = { :primitive => primitive, :constructed => constructed } diff --git a/lib/net/ldap.rb b/lib/net/ldap.rb index 5f328a24..a9c843e7 100644 --- a/lib/net/ldap.rb +++ b/lib/net/ldap.rb @@ -325,8 +325,8 @@ class Net::LDAP universal = { constructed: { - 107 => :array #ExtendedResponse (PasswdModifyResponseValue) - } + 107 => :array, #ExtendedResponse (PasswdModifyResponseValue) + }, } AsnSyntax = Net::BER.compile_syntax(:application => application, @@ -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 @@ -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 @@ -591,7 +591,7 @@ def authenticate(username, password) @auth = { :method => :simple, :username => username, - :password => password + :password => password, } end alias_method :auth, :authenticate @@ -1208,7 +1208,7 @@ def search_root_dse :supportedExtension, :supportedFeatures, :supportedLdapVersion, - :supportedSASLMechanisms + :supportedSASLMechanisms, ]) (rs and rs.first) or Net::LDAP::Entry.new end @@ -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 diff --git a/lib/net/ldap/connection.rb b/lib/net/ldap/connection.rb index 1ac9dfd7..96e735b9 100644 --- a/lib/net/ldap/connection.rb +++ b/lib/net/ldap/connection.rb @@ -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 = [] @@ -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) @@ -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 @@ -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 @@ -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) @@ -503,7 +503,7 @@ def search(args = nil) MODIFY_OPERATIONS = { #:nodoc: :add => 0, :delete => 1, - :replace => 2 + :replace => 2, } def self.modify_ops(operations) @@ -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) diff --git a/lib/net/ldap/pdu.rb b/lib/net/ldap/pdu.rb index 5527c1df..382c7acb 100644 --- a/lib/net/ldap/pdu.rb +++ b/lib/net/ldap/pdu.rb @@ -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 @@ -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 diff --git a/lib/net/snmp.rb b/lib/net/snmp.rb index 0fb99baf..258e8060 100644 --- a/lib/net/snmp.rb +++ b/lib/net/snmp.rb @@ -12,7 +12,7 @@ class SNMP 2 => :integer, # Gauge32 or Unsigned32, (RFC2578 sec 2) 3 => :integer # TimeTicks32, (RFC2578 sec 2) }, - :constructed => {} + :constructed => {}, }, :context_specific => { :primitive => {}, @@ -20,8 +20,8 @@ class SNMP 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. @@ -70,7 +70,7 @@ class Error < StandardError; end :get_next_request, :get_response, :set_request, - :trap + :trap, ] ErrorStatusCodes = { # Per RFC1157, pgh 4.1.1 0 => "noError", @@ -78,7 +78,7 @@ class Error < StandardError; end 2 => "noSuchName", 3 => "badValue", 4 => "readOnly", - 5 => "genErr" + 5 => "genErr", } class << self @@ -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 [ @@ -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 [ @@ -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}" ) diff --git a/test/integration/test_add.rb b/test/integration/test_add.rb index 3cddb18a..dcac6149 100644 --- a/test/integration/test_add.rb +++ b/test/integration/test_add.rb @@ -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 diff --git a/test/integration/test_ber.rb b/test/integration/test_ber.rb index 8fb4d374..51e93334 100644 --- a/test/integration/test_ber.rb +++ b/test/integration/test_ber.rb @@ -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 diff --git a/test/integration/test_delete.rb b/test/integration/test_delete.rb index 355df7b9..0cca32a9 100644 --- a/test/integration/test_delete.rb +++ b/test/integration/test_delete.rb @@ -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 diff --git a/test/integration/test_open.rb b/test/integration/test_open.rb index 36724f5d..a7ac09da 100644 --- a/test/integration/test_open.rb +++ b/test/integration/test_open.rb @@ -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" diff --git a/test/integration/test_password_modify.rb b/test/integration/test_password_modify.rb index 12583363..1f1c72a9 100644 --- a/test/integration/test_password_modify.rb +++ b/test/integration/test_password_modify.rb @@ -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 @@ -23,7 +23,7 @@ def setup @auth = { method: :simple, username: @dn, - password: 'passworD1' + password: 'passworD1', } end diff --git a/test/test_filter.rb b/test/test_filter.rb index dd4577eb..807c86dd 100644 --- a/test/test_filter.rb +++ b/test/test_filter.rb @@ -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) @@ -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}") diff --git a/test/test_ldap_connection.rb b/test/test_ldap_connection.rb index 85411773..6bb027ac 100644 --- a/test/test_ldap_connection.rb +++ b/test/test_ldap_connection.rb @@ -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] @@ -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 @@ -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] diff --git a/testserver/ldapserver.rb b/testserver/ldapserver.rb index 25e38799..eb0c40d3 100644 --- a/testserver/ldapserver.rb +++ b/testserver/ldapserver.rb @@ -24,7 +24,7 @@ module LdapServer }, :primitive => { 2 => :string, # ldapsearch sends this to unbind - } + }, }, :context_specific => { :primitive => { @@ -34,7 +34,7 @@ module LdapServer :constructed => { 3 => :array # equality filter }, - } + }, } def post_init