Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2300b17

Browse files
fix: avoid emitting warnings when ruby is run with -w (#1)
I've also turned on warnings for this gem's tests, to make it more obvious when this is happening in the future. Without this fix, users will see repeated messages like this: > source_file_formatter.rb:20: warning: instance variable @line_coverage not initialized
1 parent 76cc7b4 commit 2300b17

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

‎.rspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--warnings

‎lib/simplecov_json_formatter/source_file_formatter.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module SimpleCovJSONFormatter
44
class SourceFileFormatter
55
def initialize(source_file)
66
@source_file = source_file
7+
@line_coverage = nil
78
end
89

910
def format
@@ -17,7 +18,7 @@ def format
1718
private
1819

1920
def line_coverage
20-
@line_coverage || {
21+
@line_coverage ||= {
2122
lines: lines
2223
}
2324
end

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /