simplecov 0.18.2 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -53,13 +53,8 @@ module SimpleCov
53
53
  # All results that are above the SimpleCov.merge_timeout will be
54
54
  # dropped. Returns an array of SimpleCov::Result items.
55
55
  def results
56
- results = []
57
- resultset.each do |command_name, data|
58
- result = SimpleCov::Result.from_hash(command_name => data)
59
- # Only add result if the timeout is above the configured threshold
60
- results << result if (Time.now - result.created_at) < SimpleCov.merge_timeout
61
- end
62
- results
56
+ results = Result.from_hash(resultset)
57
+ results.select { |result| result.time_since_creation < SimpleCov.merge_timeout }
63
58
  end
64
59
 
65
60
  def merge_and_store(*results)
@@ -25,7 +25,7 @@ module SimpleCov
25
25
  def src
26
26
  # We intentionally read source code lazily to
27
27
  # suppress reading unused source code.
28
- @src ||= File.open(filename, "rb", &:readlines)
28
+ @src ||= load_source
29
29
  end
30
30
  alias source src
31
31
 
@@ -175,6 +175,51 @@ module SimpleCov
175
175
  end
176
176
  end
177
177
 
178
+ def load_source
179
+ lines = []
180
+ # The default encoding is UTF-8
181
+ File.open(filename, "rb:UTF-8") do |file|
182
+ current_line = file.gets
183
+
184
+ if shebang?(current_line)
185
+ lines << current_line
186
+ current_line = file.gets
187
+ end
188
+
189
+ read_lines(file, lines, current_line)
190
+ end
191
+ end
192
+
193
+ SHEBANG_REGEX = /\A#!/.freeze
194
+ def shebang?(line)
195
+ SHEBANG_REGEX.match?(line)
196
+ end
197
+
198
+ def read_lines(file, lines, current_line)
199
+ return lines unless current_line
200
+
201
+ set_encoding_based_on_magic_comment(file, current_line)
202
+ lines.concat([current_line], ensure_remove_undefs(file.readlines))
203
+ end
204
+
205
+ RUBY_FILE_ENCODING_MAGIC_COMMENT_REGEX = /\A#\s*(?:-\*-)?\s*(?:en)?coding:\s*(\S+)\s*(?:-\*-)?\s*\z/.freeze
206
+ def set_encoding_based_on_magic_comment(file, line)
207
+ # Check for encoding magic comment
208
+ # Encoding magic comment must be placed at first line except for shebang
209
+ if (match = RUBY_FILE_ENCODING_MAGIC_COMMENT_REGEX.match(line))
210
+ file.set_encoding(match[1], "UTF-8")
211
+ end
212
+ end
213
+
214
+ def ensure_remove_undefs(file_lines)
215
+ # invalid/undef replace are technically not really necessary but nice to
216
+ # have and work around a JRuby incompatibility. Also moved here from
217
+ # simplecov-html to have encoding shenaningans in one place. See #866
218
+ # also setting these option on `file.set_encoding` doesn't seem to work
219
+ # properly so it has to be done here.
220
+ file_lines.each { |line| line.encode!("UTF-8", invalid: :replace, undef: :replace) }
221
+ end
222
+
178
223
  def build_lines
179
224
  coverage_exceeding_source_warn if coverage_data["lines"].size > src.size
180
225
  lines = src.map.with_index(1) do |src, i|
@@ -5,12 +5,14 @@ module SimpleCov
5
5
  # Select the files that related to working scope directory of SimpleCov
6
6
  #
7
7
  module UselessResultsRemover
8
- ROOT_REGX = /\A#{Regexp.escape(SimpleCov.root + File::SEPARATOR)}/io.freeze
9
-
10
8
  def self.call(coverage_result)
11
9
  coverage_result.select do |path, _coverage|
12
- path =~ ROOT_REGX
10
+ path =~ root_regx
13
11
  end
14
12
  end
13
+
14
+ def self.root_regx
15
+ @root_regx ||= /\A#{Regexp.escape(SimpleCov.root + File::SEPARATOR)}/i.freeze
16
+ end
15
17
  end
16
18
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SimpleCov
4
- VERSION = "0.18.2"
4
+ VERSION = "0.19.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplecov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.2
4
+ version: 0.19.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christoph Olszowka
8
+ - Tobias Pfeiffer
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2020-02-12 00:00:00.000000000 Z
12
+ date: 2020-10-25 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: docile
@@ -42,6 +43,7 @@ description: Code coverage for Ruby with a powerful configuration library and au
42
43
  merging of coverage across test suites
43
44
  email:
44
45
  - christoph at olszowka de
46
+ - pragtob@gmail.com
45
47
  executables: []
46
48
  extensions: []
47
49
  extra_rdoc_files: []
@@ -55,6 +57,7 @@ files:
55
57
  - doc/alternate-formatters.md
56
58
  - doc/commercial-services.md
57
59
  - doc/editor-integration.md
60
+ - lib/minitest/simplecov_plugin.rb
58
61
  - lib/simplecov.rb
59
62
  - lib/simplecov/combine.rb
60
63
  - lib/simplecov/combine/branches_combiner.rb
@@ -66,6 +69,10 @@ files:
66
69
  - lib/simplecov/coverage_statistics.rb
67
70
  - lib/simplecov/defaults.rb
68
71
  - lib/simplecov/exit_codes.rb
72
+ - lib/simplecov/exit_codes/exit_code_handling.rb
73
+ - lib/simplecov/exit_codes/maximum_coverage_drop_check.rb
74
+ - lib/simplecov/exit_codes/minimum_coverage_by_file_check.rb
75
+ - lib/simplecov/exit_codes/minimum_overall_coverage_check.rb
69
76
  - lib/simplecov/file_list.rb
70
77
  - lib/simplecov/filter.rb
71
78
  - lib/simplecov/formatter.rb
@@ -75,6 +82,7 @@ files:
75
82
  - lib/simplecov/lines_classifier.rb
76
83
  - lib/simplecov/load_global_config.rb
77
84
  - lib/simplecov/no_defaults.rb
85
+ - lib/simplecov/process.rb
78
86
  - lib/simplecov/profiles.rb
79
87
  - lib/simplecov/profiles/bundler_filter.rb
80
88
  - lib/simplecov/profiles/hidden_filter.rb
@@ -90,15 +98,15 @@ files:
90
98
  - lib/simplecov/source_file/line.rb
91
99
  - lib/simplecov/useless_results_remover.rb
92
100
  - lib/simplecov/version.rb
93
- homepage: https://github.com/colszowka/simplecov
101
+ homepage: https://github.com/simplecov-ruby/simplecov
94
102
  licenses:
95
103
  - MIT
96
104
  metadata:
97
- bug_tracker_uri: https://github.com/colszowka/simplecov/issues
98
- changelog_uri: https://github.com/colszowka/simplecov/blob/master/CHANGELOG.md
99
- documentation_uri: https://www.rubydoc.info/gems/simplecov/0.18.2
105
+ bug_tracker_uri: https://github.com/simplecov-ruby/simplecov/issues
106
+ changelog_uri: https://github.com/simplecov-ruby/simplecov/blob/main/CHANGELOG.md
107
+ documentation_uri: https://www.rubydoc.info/gems/simplecov/0.19.1
100
108
  mailing_list_uri: https://groups.google.com/forum/#!forum/simplecov
101
- source_code_uri: https://github.com/colszowka/simplecov/tree/v0.18.2
109
+ source_code_uri: https://github.com/simplecov-ruby/simplecov/tree/v0.19.1
102
110
  post_install_message:
103
111
  rdoc_options: []
104
112
  require_paths:
@@ -107,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
115
  requirements:
108
116
  - - ">="
109
117
  - !ruby/object:Gem::Version
110
- version: 2.4.0
118
+ version: 2.5.0
111
119
  required_rubygems_version: !ruby/object:Gem::Requirement
112
120
  requirements:
113
121
  - - ">="