Skip to content

Commit d7d6deb

Browse files
committed
Apply Qlty code formatting and quality improvements
- Auto-format all Ruby files with RuboCop via Qlty - Fix spacing, indentation, and string literal consistency - Remove trailing whitespace and add missing newlines - Improve code style compliance - Reduce issues from 248 to 204
1 parent 82c94fe commit d7d6deb

9 files changed

Lines changed: 37 additions & 35 deletions

File tree

Rakefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ RSpec::Core::RakeTask.new(:spec)
55

66
desc "Run manual verification"
77
task :manual do
8-
sh "ruby -I lib test_manual.rb"
8+
sh "ruby -I lib test_manual.rb"
99
end
1010

1111
task :default => :spec
12-

deprecate.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# coding: utf-8
2+
23
lib = File.expand_path('../lib', __FILE__)
34
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
45
require 'deprecate/version'

lib/deprecate.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ def reset_warnings!
2828
module Deprecatable
2929
def __deprecated_run_action__(method_name, replacement = nil)
3030
method_key = "#{self.class.name}##{method_name}"
31-
31+
3232
return if Deprecate.config[:warn_once] && Deprecate.warned_methods[method_key]
3333

3434
replacement_text = replacement ? " (use #{replacement} instead)" : ""
3535
caller_info = if Deprecate.config[:show_caller]
36-
caller_location = caller_locations(3, 1)
37-
caller_location && caller_location.first ? caller_location.first.to_s : "unknown"
38-
else
39-
"unknown"
40-
end
41-
36+
caller_location = caller_locations(3, 1)
37+
caller_location && caller_location.first ? caller_location.first.to_s : "unknown"
38+
else
39+
"unknown"
40+
end
41+
4242
message = Deprecate.config[:message_format] % {
4343
method: method_name,
4444
replacement: replacement_text,
@@ -48,7 +48,8 @@ def __deprecated_run_action__(method_name, replacement = nil)
4848
Deprecate.config[:output_stream].puts(message)
4949
Deprecate.warned_methods[method_key] = true if Deprecate.config[:warn_once]
5050
end
51-
def deprecate(sym, replacement=nil, scope=nil)
51+
52+
def deprecate(sym, replacement = nil, scope = nil)
5253
unless sym.is_a?(Symbol)
5354
raise ArgumentError, 'deprecate() requires symbols for its first argument.'
5455
end

spec/deprecate_spec.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
RSpec.describe Deprecate do
44
let(:output) { StringIO.new }
5-
5+
66
before do
77
Deprecate.reset_warnings!
88
Deprecate.configure do |config|
99
config[:output_stream] = output
1010
config[:warn_once] = false
1111
end
1212
end
13-
13+
1414
after do
1515
Deprecate.configure do |config|
1616
config[:output_stream] = $stderr
@@ -25,11 +25,11 @@
2525
def old_method
2626
"old result"
2727
end
28-
28+
2929
def new_method
3030
"new result"
3131
end
32-
32+
3333
deprecate :old_method, :new_method
3434
end
3535
end
@@ -52,7 +52,7 @@ def new_method
5252
def legacy_method
5353
"legacy result"
5454
end
55-
55+
5656
deprecate :legacy_method
5757
end
5858
end
@@ -76,7 +76,7 @@ def legacy_method
7676
def old_method(arg1, arg2)
7777
"#{arg1}-#{arg2}"
7878
end
79-
79+
8080
deprecate :old_method, :new_method
8181
end
8282
end
@@ -145,7 +145,7 @@ def call_private
145145
def old_method
146146
"result"
147147
end
148-
148+
149149
deprecate :old_method
150150
end
151151
end
@@ -154,7 +154,7 @@ def old_method
154154
obj = test_class.new
155155
obj.old_method
156156
obj.old_method
157-
157+
158158
warnings = output.string.scan(/DEPRECATION WARNING/)
159159
expect(warnings.length).to eq(1)
160160
end
@@ -173,7 +173,7 @@ def old_method
173173
def old_method
174174
"result"
175175
end
176-
176+
177177
deprecate :old_method, :new_method
178178
end
179179
end
@@ -190,22 +190,22 @@ def old_method
190190
it 'clears the warned methods hash' do
191191
# Just test that the hash gets cleared
192192
Deprecate.configure { |config| config[:warn_once] = true }
193-
193+
194194
# Add a warning to the hash
195195
test_class = Class.new do
196196
def old_method
197197
"result"
198198
end
199199
deprecate :old_method
200200
end
201-
201+
202202
obj = test_class.new
203-
obj.old_method # This should add to warned_methods hash
204-
203+
obj.old_method # This should add to warned_methods hash
204+
205205
expect(Deprecate.warned_methods).not_to be_empty
206-
206+
207207
Deprecate.reset_warnings!
208208
expect(Deprecate.warned_methods).to be_empty
209209
end
210210
end
211-
end
211+
end

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
end
1212

1313
config.shared_context_metadata_behavior = :apply_to_host_groups
14-
end
14+
end

test/test_basic.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,4 @@ def old_method
123123

124124
teardown_test
125125

126-
puts "\nAll tests passed! ✅"
126+
puts "\nAll tests passed! ✅"

test/test_deprecate.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ def new_method
3535
result = obj.old_method
3636

3737
assert_equal "old result", result
38-
assert_match(/DEPRECATION WARNING: old_method is deprecated \(use new_method instead\)/, @output.string)
38+
assert_match(/DEPRECATION WARNING: old_method is deprecated \(use new_method instead\)/,
39+
@output.string)
3940
end
4041

4142
def test_deprecate_method_without_replacement
@@ -164,4 +165,4 @@ def old_method
164165

165166
Deprecate.configure { |config| config[:message_format] = original_format }
166167
end
167-
end
168+
end

test/test_deprecate_simple.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,4 @@ def old_method
104104

105105
assert_equal 2, @output.string.scan(/DEPRECATION WARNING/).length
106106
end
107-
end
107+
end

test_manual.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ class TestClass
66
def old_method(name = "world")
77
"Hello, #{name}!"
88
end
9-
10-
def new_method(name = "world")
9+
10+
def new_method(name = "world")
1111
"Hi there, #{name}!"
1212
end
13-
13+
1414
deprecate :old_method, :new_method
1515
end
1616

@@ -35,12 +35,12 @@ class TestClass2
3535
def legacy_method
3636
"legacy"
3737
end
38-
38+
3939
deprecate :legacy_method
4040
end
4141

4242
obj2 = TestClass2.new
4343
result4 = obj2.legacy_method
4444
puts "Legacy result: #{result4}"
4545

46-
puts "\nAll tests completed successfully!"
46+
puts "\nAll tests completed successfully!"

0 commit comments

Comments
 (0)