Skip to content

Commit 87c1e01

Browse files
committed
Adopt rubocop-performance plugin
1 parent de8b932 commit 87c1e01

6 files changed

Lines changed: 12 additions & 5 deletions

File tree

.rubocop.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins:
22
- rubocop-capybara
3+
- rubocop-performance
34
- rubocop-rake
45

56
AllCops:

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ group :development do
1414
if RUBY_VERSION > "3.2"
1515
gem "rubocop"
1616
gem "rubocop-capybara"
17+
gem "rubocop-performance"
1718
gem "rubocop-rake"
1819
end
1920
gem "test-unit"

Gemfile.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ GEM
158158
rubocop-capybara (2.23.0)
159159
lint_roller (~> 1.1)
160160
rubocop (~> 1.81)
161+
rubocop-performance (1.26.1)
162+
lint_roller (~> 1.1)
163+
rubocop (>= 1.75.0, < 2.0)
164+
rubocop-ast (>= 1.47.1, < 2.0)
161165
rubocop-rake (0.7.1)
162166
lint_roller (~> 1.1)
163167
rubocop (>= 1.72.1)
@@ -202,6 +206,7 @@ DEPENDENCIES
202206
rspec
203207
rubocop
204208
rubocop-capybara
209+
rubocop-performance
205210
rubocop-rake
206211
simplecov!
207212
test-unit

lib/simplecov/file_list.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ def missed_lines
4545
def never_lines
4646
return 0.0 if empty?
4747

48-
map { |f| f.never_lines.count }.inject(:+)
48+
sum { |f| f.never_lines.count }
4949
end
5050

5151
# Returns the count of skipped lines
5252
def skipped_lines
5353
return 0.0 if empty?
5454

55-
map { |f| f.skipped_lines.count }.inject(:+)
55+
sum { |f| f.skipped_lines.count }
5656
end
5757

5858
# Computes the coverage based upon lines covered and lines missed for each file

spec/result_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231
expect(result.size).to eq 2
232232
sorted = result.sort_by(&:command_name)
233233
expect(sorted.map(&:command_name)).to eq %w[cucumber rspec]
234-
expect(sorted.map(&:created_at).map(&:to_i)).to eq [created_at, created_at]
234+
expect(sorted.map { |r| r.created_at.to_i }).to eq [created_at, created_at]
235235
expect(sorted.map(&:original_result)).to eq [other_result, original_result]
236236
end
237237
end

spec/source_file_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@
909909
end
910910

911911
it "has 5 branches marked as skipped" do
912-
expect(subject.branches.select(&:skipped?).size).to eq 5
912+
expect(subject.branches.count(&:skipped?)).to eq 5
913913
end
914914
end
915915
end
@@ -1198,7 +1198,7 @@ def build(coverage_data, source_lines)
11981198
end
11991199

12001200
it "skips any branch whose range overlaps the disabled region" do
1201-
expect(subject.branches.select(&:skipped?).size).to eq 2
1201+
expect(subject.branches.count(&:skipped?)).to eq 2
12021202
expect(subject.total_branches).to eq []
12031203
end
12041204

0 commit comments

Comments
 (0)