Skip to content

Commit 2673ba8

Browse files
yahondaclaude
andcommitted
Bump RuboCop to latest and autocorrect offenses
Remove version pin on rubocop gem. Update .rubocop.yml for renamed cops (Layout/Tab -> Layout/IndentationStyle) and target Ruby 3.2. Autocorrect all 66 Layout/LeadingCommentSpace and Layout/SpaceAroundOperators offenses. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a0cb553 commit 2673ba8

16 files changed

Lines changed: 70 additions & 73 deletions

.rubocop.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
# rubocop 0.51.0 requires Ruby 2.1
2-
# We should not use cops only available for Ruby 2.1 or later
3-
# since ruby-plsql itself supports Ruby 1.9.3
41
AllCops:
5-
TargetRubyVersion: 2.3
2+
TargetRubyVersion: 3.2
63
DisabledByDefault: true
4+
NewCops: disable
75

86
# Prefer &&/|| over and/or.
97
Style/AndOr:
@@ -112,7 +110,7 @@ Style/StringLiterals:
112110
EnforcedStyle: double_quotes
113111

114112
# Detect hard tabs, no hard tabs.
115-
Layout/Tab:
113+
Layout/IndentationStyle:
116114
Enabled: true
117115

118116
# Blank lines should not have any spaces.
@@ -132,7 +130,6 @@ Style/RedundantPercentQ:
132130
Layout/EndAlignment:
133131
Enabled: true
134132
EnforcedStyleAlignWith: variable
135-
AutoCorrect: true
136133

137134
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
138135
Lint/RequireParentheses:

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source "http://rubygems.org"
33
group :development do
44
gem "juwelier", "~> 2.0"
55
gem "rspec_junit_formatter"
6-
gem "rubocop", "0.81", require: false
6+
gem "rubocop", require: false
77
gem "rubocop-performance", require: false
88
gem "rubocop-rails", require: false
99
end

lib/plsql/connection.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ class Connection
33
attr_reader :raw_driver
44
attr_reader :activerecord_class
55

6-
def initialize(raw_conn, ar_class = nil) #:nodoc:
6+
def initialize(raw_conn, ar_class = nil) # :nodoc:
77
@raw_driver = self.class.driver_type
88
@raw_connection = raw_conn
99
@activerecord_class = ar_class
1010
end
1111

12-
def self.create(raw_conn, ar_class = nil) #:nodoc:
12+
def self.create(raw_conn, ar_class = nil) # :nodoc:
1313
if ar_class && !(defined?(::ActiveRecord) && ar_class.ancestors.include?(::ActiveRecord::Base))
1414
raise ArgumentError, "Wrong ActiveRecord class"
1515
end
@@ -23,7 +23,7 @@ def self.create(raw_conn, ar_class = nil) #:nodoc:
2323
end
2424
end
2525

26-
def self.create_new(params) #:nodoc:
26+
def self.create_new(params) # :nodoc:
2727
conn = case driver_type
2828
when :oci
2929
OCIConnection.create_raw(params)
@@ -36,7 +36,7 @@ def self.create_new(params) #:nodoc:
3636
conn
3737
end
3838

39-
def self.driver_type #:nodoc:
39+
def self.driver_type # :nodoc:
4040
# MRI 1.8.6 or YARV 1.9.1 or TruffleRuby
4141
@driver_type ||= if (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby" || RUBY_ENGINE == "truffleruby") && defined?(OCI8)
4242
:oci
@@ -67,18 +67,18 @@ def jdbc?
6767
@raw_driver == :jdbc
6868
end
6969

70-
def logoff #:nodoc:
70+
def logoff # :nodoc:
7171
# Rollback any uncommited transactions
7272
rollback
7373
# Common cleanup activities before logoff, should be called from particular driver method
7474
drop_session_ruby_temporary_tables
7575
end
7676

77-
def commit #:nodoc:
77+
def commit # :nodoc:
7878
raise NoMethodError, "Not implemented for this raw driver"
7979
end
8080

81-
def rollback #:nodoc:
81+
def rollback # :nodoc:
8282
raise NoMethodError, "Not implemented for this raw driver"
8383
end
8484

@@ -98,21 +98,21 @@ def prefetch_rows=(value)
9898
raise NoMethodError, "Not implemented for this raw driver"
9999
end
100100

101-
def select_first(sql, *bindvars) #:nodoc:
101+
def select_first(sql, *bindvars) # :nodoc:
102102
cursor = cursor_from_query(sql, bindvars, prefetch_rows: 1)
103103
cursor.fetch
104104
ensure
105105
cursor.close rescue nil
106106
end
107107

108-
def select_hash_first(sql, *bindvars) #:nodoc:
108+
def select_hash_first(sql, *bindvars) # :nodoc:
109109
cursor = cursor_from_query(sql, bindvars, prefetch_rows: 1)
110110
cursor.fetch_hash
111111
ensure
112112
cursor.close rescue nil
113113
end
114114

115-
def select_all(sql, *bindvars, &block) #:nodoc:
115+
def select_all(sql, *bindvars, &block) # :nodoc:
116116
cursor = cursor_from_query(sql, bindvars)
117117
results = []
118118
row_count = 0
@@ -129,7 +129,7 @@ def select_all(sql, *bindvars, &block) #:nodoc:
129129
cursor.close rescue nil
130130
end
131131

132-
def select_hash_all(sql, *bindvars, &block) #:nodoc:
132+
def select_hash_all(sql, *bindvars, &block) # :nodoc:
133133
cursor = cursor_from_query(sql, bindvars)
134134
results = []
135135
row_count = 0
@@ -146,11 +146,11 @@ def select_hash_all(sql, *bindvars, &block) #:nodoc:
146146
cursor.close rescue nil
147147
end
148148

149-
def exec(sql, *bindvars) #:nodoc:
149+
def exec(sql, *bindvars) # :nodoc:
150150
raise NoMethodError, "Not implemented for this raw driver"
151151
end
152152

153-
def parse(sql) #:nodoc:
153+
def parse(sql) # :nodoc:
154154
raise NoMethodError, "Not implemented for this raw driver"
155155
end
156156

@@ -181,7 +181,7 @@ def fetch_hash
181181

182182
# all_synonyms view is quite slow therefore
183183
# this implementation is overriden in OCI connection with faster native OCI method
184-
def describe_synonym(schema_name, synonym_name) #:nodoc:
184+
def describe_synonym(schema_name, synonym_name) # :nodoc:
185185
select_first(
186186
"SELECT table_owner, table_name FROM all_synonyms WHERE owner = :owner AND synonym_name = :synonym_name",
187187
schema_name.to_s.upcase, synonym_name.to_s.upcase)

lib/plsql/helpers.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
module PLSQL #:nodoc:
2-
module ArrayHelpers #:nodoc:
3-
def self.to_hash(keys, values) #:nodoc:
1+
module PLSQL # :nodoc:
2+
module ArrayHelpers # :nodoc:
3+
def self.to_hash(keys, values) # :nodoc:
44
(0...keys.size).inject({}) { |hash, i| hash[keys[i]] = values[i]; hash }
55
end
66
end

lib/plsql/jdbc_connection.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
end
4747

4848
module PLSQL
49-
class JDBCConnection < Connection #:nodoc:
49+
class JDBCConnection < Connection # :nodoc:
5050
def self.create_raw(params)
5151
database = params[:database]
5252
url = if ENV["TNS_ADMIN"] && database && !params[:host] && !params[:url]
@@ -98,7 +98,7 @@ def exec(sql, *bindvars)
9898
cs.close rescue nil
9999
end
100100

101-
class CallableStatement #:nodoc:
101+
class CallableStatement # :nodoc:
102102
def initialize(conn, sql)
103103
@sql = sql
104104
@connection = conn
@@ -145,7 +145,7 @@ def bind_param_index(key)
145145
end
146146
end
147147

148-
class Cursor #:nodoc:
148+
class Cursor # :nodoc:
149149
include Connection::CursorCommon
150150

151151
attr_reader :result_set

lib/plsql/oci_connection.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
end
2525

2626
module PLSQL
27-
class OCIConnection < Connection #:nodoc:
27+
class OCIConnection < Connection # :nodoc:
2828
def self.create_raw(params)
2929
connection_string = if params[:host]
3030
"//#{params[:host]}:#{params[:port] || 1521}/#{params[:database]}"
@@ -64,7 +64,7 @@ def exec(sql, *bindvars)
6464
true
6565
end
6666

67-
class Cursor #:nodoc:
67+
class Cursor # :nodoc:
6868
include Connection::CursorCommon
6969

7070
attr_reader :raw_cursor

lib/plsql/package.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module PLSQL
2-
module PackageClassMethods #:nodoc:
2+
module PackageClassMethods # :nodoc:
33
def find(schema, package)
44
package_name = package.to_s.upcase
55
find_in_schema(schema, package_name) || find_by_synonym(schema, package_name)
@@ -32,7 +32,7 @@ def find_by_synonym(schema, package_name)
3232
end
3333
end
3434

35-
class Package #:nodoc:
35+
class Package # :nodoc:
3636
extend PackageClassMethods
3737

3838
def initialize(schema, package, override_schema_name = nil)

lib/plsql/procedure.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module PLSQL
2-
module ProcedureClassMethods #:nodoc:
2+
module ProcedureClassMethods # :nodoc:
33
def find(schema, procedure, package = nil, override_schema_name = nil)
44
if package.nil?
55
if (row = schema.select_first(
@@ -53,12 +53,12 @@ def procedure_object_id_src(schema)
5353
end
5454
end
5555

56-
module ProcedureCommon #:nodoc:
56+
module ProcedureCommon # :nodoc:
5757
attr_reader :arguments, :argument_list, :out_list, :return
5858
attr_reader :schema, :schema_name, :package, :procedure
5959

6060
# return type string from metadata that can be used in DECLARE block or table definition
61-
def self.type_to_sql(metadata) #:nodoc:
61+
def self.type_to_sql(metadata) # :nodoc:
6262
case metadata[:data_type]
6363
when "NUMBER"
6464
precision, scale = metadata[:data_precision], metadata[:data_scale]
@@ -82,15 +82,15 @@ def self.type_to_sql(metadata) #:nodoc:
8282
end
8383

8484
# get procedure argument metadata from data dictionary
85-
def get_argument_metadata #:nodoc:
85+
def get_argument_metadata # :nodoc:
8686
if (@schema.connection.database_version <=> [18, 0, 0, 0]) >= 0
8787
get_argument_metadata_from_18c
8888
else
8989
get_argument_metadata_below_18c
9090
end
9191
end
9292

93-
def get_argument_metadata_below_18c #:nodoc:
93+
def get_argument_metadata_below_18c # :nodoc:
9494
@arguments = {}
9595
@argument_list = {}
9696
@out_list = {}
@@ -209,7 +209,7 @@ def get_argument_metadata_below_18c #:nodoc:
209209
end
210210

211211
# get procedure argument metadata from data dictionary
212-
def get_argument_metadata_from_18c #:nodoc:
212+
def get_argument_metadata_from_18c # :nodoc:
213213
@arguments = {}
214214
@argument_list = {}
215215
@out_list = {}
@@ -304,15 +304,15 @@ def get_argument_metadata_from_18c #:nodoc:
304304
construct_argument_list_for_overloads
305305
end
306306

307-
def construct_argument_list_for_overloads #:nodoc:
307+
def construct_argument_list_for_overloads # :nodoc:
308308
@overloads = @arguments.keys.sort
309309
@overloads.each do |overload|
310310
@argument_list[overload] = @arguments[overload].keys.sort { |k1, k2| @arguments[overload][k1][:position] <=> @arguments[overload][k2][:position] }
311311
@out_list[overload] = @argument_list[overload].select { |k| @arguments[overload][k][:in_out] =~ /OUT/ }
312312
end
313313
end
314314

315-
def ensure_tmp_tables_created(overload) #:nodoc:
315+
def ensure_tmp_tables_created(overload) # :nodoc:
316316
return if @tmp_tables_created.nil? || @tmp_tables_created[overload]
317317
@tmp_table_names[overload] && @tmp_table_names[overload].each do |table_name, argument_metadata|
318318
sql = "CREATE GLOBAL TEMPORARY TABLE #{table_name} (\n"
@@ -336,7 +336,7 @@ def ensure_tmp_tables_created(overload) #:nodoc:
336336
@tmp_tables_created[overload] = true
337337
end
338338

339-
def build_sql_type_name(type_owner, type_package, type_name) #:nodoc:
339+
def build_sql_type_name(type_owner, type_package, type_name) # :nodoc:
340340
if type_owner == nil || type_owner == "PUBLIC"
341341
type_owner_res = ""
342342
else
@@ -351,7 +351,7 @@ def build_sql_type_name(type_owner, type_package, type_name) #:nodoc:
351351
type_name_res && "#{type_owner_res}#{type_name_res}"
352352
end
353353

354-
def get_field_definitions(argument_metadata) #:nodoc:
354+
def get_field_definitions(argument_metadata) # :nodoc:
355355
fields = {}
356356
case argument_metadata[:type_object_type]
357357
when "PACKAGE"
@@ -414,7 +414,7 @@ def get_field_definitions(argument_metadata) #:nodoc:
414414
fields
415415
end
416416

417-
def get_element_definition(argument_metadata) #:nodoc:
417+
def get_element_definition(argument_metadata) # :nodoc:
418418
element_metadata = {}
419419
if collection_type?(argument_metadata[:data_type])
420420
case argument_metadata[:type_object_type]
@@ -516,21 +516,21 @@ def get_composite_type(type_owner, type_name, type_package)
516516
end
517517

518518
PLSQL_COMPOSITE_TYPES = ["PL/SQL RECORD", "PL/SQL TABLE", "TABLE", "VARRAY", "REF CURSOR"].freeze
519-
def composite_type?(data_type) #:nodoc:
519+
def composite_type?(data_type) # :nodoc:
520520
PLSQL_COMPOSITE_TYPES.include? data_type
521521
end
522522

523523
PLSQL_COLLECTION_TYPES = ["PL/SQL TABLE", "TABLE", "VARRAY"].freeze
524-
def collection_type?(data_type) #:nodoc:
524+
def collection_type?(data_type) # :nodoc:
525525
PLSQL_COLLECTION_TYPES.include? data_type
526526
end
527527

528-
def overloaded? #:nodoc:
528+
def overloaded? # :nodoc:
529529
@overloaded
530530
end
531531
end
532532

533-
class Procedure #:nodoc:
533+
class Procedure # :nodoc:
534534
extend ProcedureClassMethods
535535
include ProcedureCommon
536536

lib/plsql/procedure_call.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module PLSQL
2-
class ProcedureCall #:nodoc:
2+
class ProcedureCall # :nodoc:
33
def initialize(procedure, args = [], options = {})
44
@procedure = procedure
55
@schema = @procedure.schema

lib/plsql/schema.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ class Schema
44

55
@@schemas = {}
66

7-
class <<self
8-
def find_or_new(connection_alias) #:nodoc:
7+
class << self
8+
def find_or_new(connection_alias) # :nodoc:
99
connection_alias ||= :default
1010
if @@schemas[connection_alias]
1111
@@schemas[connection_alias]
@@ -15,7 +15,7 @@ def find_or_new(connection_alias) #:nodoc:
1515
end
1616
end
1717

18-
def initialize(raw_conn = nil, schema = nil, original_schema = nil) #:nodoc:
18+
def initialize(raw_conn = nil, schema = nil, original_schema = nil) # :nodoc:
1919
self.connection = raw_conn
2020
@schema_name = schema ? schema.to_s.upcase : nil
2121
@original_schema = original_schema
@@ -25,11 +25,11 @@ def initialize(raw_conn = nil, schema = nil, original_schema = nil) #:nodoc:
2525
# Returns connection wrapper object (this is not raw OCI8 or JDBC connection!)
2626
attr_reader :connection
2727

28-
def root_schema #:nodoc:
28+
def root_schema # :nodoc:
2929
@original_schema || self
3030
end
3131

32-
def raw_connection=(raw_conn) #:nodoc:
32+
def raw_connection=(raw_conn) # :nodoc:
3333
@connection = raw_conn ? Connection.create(raw_conn) : nil
3434
reset_instance_variables
3535
end
@@ -117,7 +117,7 @@ def default_timezone=(value)
117117

118118
# Same implementation as for ActiveRecord
119119
# DateTimes aren't aware of DST rules, so use a consistent non-DST offset when creating a DateTime with an offset in the local zone
120-
def local_timezone_offset #:nodoc:
120+
def local_timezone_offset # :nodoc:
121121
::Time.local(2007).utc_offset.to_r / 86400
122122
end
123123

0 commit comments

Comments
 (0)