Skip to content

Commit 1ab14df

Browse files
committed
Refactor for ruby 3 keyword argument syntax compatibility
1 parent 7965a4a commit 1ab14df

File tree

6 files changed

+41
-18
lines changed

6 files changed

+41
-18
lines changed

.rubocop_todo.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config`
3+
# on 2024-11-15 06:22:54 UTC using RuboCop version 1.24.1.
4+
# The point is for the user to remove these configuration records
5+
# one by one as the offenses are removed from the code base.
6+
# Note that changes in the inspected code, or installation of new
7+
# versions of RuboCop, may require this file to be generated again.
8+
9+
# Offense count: 2
10+
# Cop supports --auto-correct.
11+
# Configuration parameters: EnforcedStyle.
12+
# SupportedStyles: anonymous, explicit
13+
Naming/BlockForwarding:
14+
Exclude:
15+
- 'lib/git_fame/diff.rb'
16+
17+
# Offense count: 17
18+
# Cop supports --auto-correct.
19+
# Configuration parameters: EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
20+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
21+
# SupportedShorthandSyntax: always, never
22+
Style/HashSyntax:
23+
EnforcedStyle: ruby19

lib/git_fame/collector.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Collector
99

1010
# @return [Collector]
1111
def call
12-
Result.new(contributions: contributions)
12+
Result.new(contributions:)
1313
end
1414

1515
private
@@ -36,7 +36,7 @@ def contributions
3636
files: files[email],
3737
author: {
3838
name: names[email],
39-
email: email
39+
email:
4040
}
4141
})
4242
end

lib/git_fame/command.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def run
125125
end
126126

127127
thread = spinner.run do
128-
Render.new(result: result, **options(:branch))
128+
Render.new(result:, **options(:branch))
129129
end
130130

131131
thread.value.call
@@ -150,11 +150,11 @@ def repo
150150
end
151151

152152
def collector
153-
Collector.new(filter: filter, diff: diff, **options)
153+
Collector.new(filter:, diff:, **options)
154154
end
155155

156156
def diff
157-
Diff.new(commit: commit, **options)
157+
Diff.new(commit:, **options)
158158
end
159159

160160
def options(*args)

lib/git_fame/diff.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ class Diff < Base
1111
# @yield [Hash]
1212
#
1313
# @return [void]
14-
def each(&block)
14+
def each(&)
1515
tree.walk(:preorder).each do |root, entry|
1616
case entry
1717
in { type: :blob, name: file, oid: }
18-
Rugged::Blame.new(repo, root + file, newest_commit: commit).each(&block)
18+
Rugged::Blame.new(repo, root + file, newest_commit: commit).each(&)
1919
in { type: type, name: file }
2020
say("Ignore type [%s] in for %s", type, root + file)
2121
end

lib/git_fame/render.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def call
2626
table << [c.name, c.email, c.lines.f, c.commits.count.f, c.files.count.f, c.dist(self)]
2727
end
2828

29-
print table.render(:unicode, width: width, resize: true, alignment: [:center])
29+
print table.render(:unicode, width:, resize: true, alignment: [:center])
3030
end
3131

3232
private

spec/filter_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
include: Set["test*{.rb, .js, .ts}"],
1111
extensions: Set[".rb", ".js"],
1212
exclude: Set["*_spec.rb"],
13-
before: before,
14-
after: after
13+
before:,
14+
after:
1515
})
1616
end
1717

1818
let(:now) { DateTime.now }
19-
let(:changes) { super().deep_merge(orig_path: file_path, final_signature: { time: time }) }
19+
let(:changes) { super().deep_merge(orig_path: file_path, final_signature: { time: }) }
2020
let(:file_path) { "test.rb" }
2121
let(:time) { Time.now }
2222
let(:before) { now + 1_000 }
@@ -39,9 +39,9 @@
3939
end
4040

4141
context "when the before filter is set to today" do
42-
subject(:filter) { build(:filter, before: before) }
42+
subject(:filter) { build(:filter, before:) }
4343

44-
let(:changes) { super().deep_merge(final_signature: { time: time }) }
44+
let(:changes) { super().deep_merge(final_signature: { time: }) }
4545
let(:before) { DateTime.now }
4646

4747
context "when the change is set BEFORE the [before] filter" do
@@ -62,7 +62,7 @@
6262
end
6363

6464
context "when the [exclude] filter is set to ignore [LI*ENCE]" do
65-
subject(:filter) { build(:filter, exclude: exclude) }
65+
subject(:filter) { build(:filter, exclude:) }
6666

6767
let(:changes) { super().deep_merge(orig_path: file_path) }
6868
let(:exclude) { Set["LI*ENCE"] }
@@ -85,7 +85,7 @@
8585
end
8686

8787
context "when the [include] filter is set to include [*_spec.rb]" do
88-
subject(:filter) { build(:filter, include: include) }
88+
subject(:filter) { build(:filter, include:) }
8989

9090
let(:changes) { super().deep_merge(orig_path: file_path) }
9191
let(:include) { Set["*_spec.rb"] }
@@ -108,7 +108,7 @@
108108
end
109109

110110
context "when the [extensions] filter is set to ignore [.rb]" do
111-
subject(:filter) { build(:filter, extensions: extensions) }
111+
subject(:filter) { build(:filter, extensions:) }
112112

113113
let(:changes) { super().deep_merge(orig_path: file_path) }
114114
let(:extensions) { Set[".rb"] }
@@ -131,9 +131,9 @@
131131
end
132132

133133
context "when the after filter is set to today" do
134-
subject(:filter) { build(:filter, after: after) }
134+
subject(:filter) { build(:filter, after:) }
135135

136-
let(:changes) { super().deep_merge(final_signature: { time: time }) }
136+
let(:changes) { super().deep_merge(final_signature: { time: }) }
137137
let(:after) { DateTime.now }
138138

139139
context "when the change is set BEFORE the after filter" do

0 commit comments

Comments
 (0)