This repository was archived by the owner on Jul 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed
lib/code_climate/test_reporter Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ def format(result)
19
19
20
20
payload = to_payload ( result )
21
21
PayloadValidator . validate ( payload )
22
- if tddium? || ENV [ "TO_FILE" ]
22
+ if write_to_file?
23
23
file_path = File . join ( Dir . tmpdir , "codeclimate-test-coverage-#{ SecureRandom . uuid } .json" )
24
24
print "Coverage results saved to #{ file_path } ... "
25
25
File . open ( file_path , "w" ) { |file | file . write ( payload . to_json ) }
@@ -36,6 +36,8 @@ def format(result)
36
36
false
37
37
end
38
38
39
+ private
40
+
39
41
def partial?
40
42
tddium?
41
43
end
@@ -81,7 +83,6 @@ def to_payload(result)
81
83
}
82
84
end
83
85
84
-
85
86
def short_filename ( filename )
86
87
return filename unless ::SimpleCov . root
87
88
filename = filename . gsub ( ::SimpleCov . root , '.' ) . gsub ( /^\. \/ / , '' )
@@ -98,7 +99,10 @@ def round(numeric, precision)
98
99
Float ( numeric ) . round ( precision )
99
100
end
100
101
101
- private
102
+ def write_to_file?
103
+ warn "TO_FILE is deprecated, use CODECLIMATE_TO_FILE" if ENV [ "TO_FILE" ]
104
+ tddium? || ENV [ "CODECLIMATE_TO_FILE" ] || ENV [ "TO_FILE" ]
105
+ end
102
106
103
107
def apply_prefix filename
104
108
prefix = CodeClimate ::TestReporter . configuration . path_prefix
Original file line number Diff line number Diff line change @@ -108,8 +108,8 @@ module CodeClimate::TestReporter
108
108
109
109
describe '#short_filename' do
110
110
it 'should return the filename of the file relative to the SimpleCov root' do
111
- expect ( formatter . short_filename ( 'file1' ) ) . to eq ( 'file1' )
112
- expect ( formatter . short_filename ( "#{ ::SimpleCov . root } /file1" ) ) . to eq ( 'file1' )
111
+ expect ( formatter . send ( :short_filename , 'file1' ) ) . to eq ( 'file1' )
112
+ expect ( formatter . send ( :short_filename , "#{ ::SimpleCov . root } /file1" ) ) . to eq ( 'file1' )
113
113
end
114
114
115
115
context "with path prefix" do
@@ -126,8 +126,8 @@ module CodeClimate::TestReporter
126
126
end
127
127
128
128
it 'should include the path prefix if set' do
129
- expect ( formatter . short_filename ( 'file1' ) ) . to eq ( 'custom/file1' )
130
- expect ( formatter . short_filename ( "#{ ::SimpleCov . root } /file1" ) ) . to eq ( 'custom/file1' )
129
+ expect ( formatter . send ( :short_filename , 'file1' ) ) . to eq ( 'custom/file1' )
130
+ expect ( formatter . send ( :short_filename , "#{ ::SimpleCov . root } /file1" ) ) . to eq ( 'custom/file1' )
131
131
end
132
132
end
133
133
end
You can’t perform that action at this time.
0 commit comments