Skip to content

Commit 464eacd

Browse files
Replace deprecated SimpleCov APIs with their supported equivalents (#1350)
SimpleCov 1.0.3 deprecated `# :nocov:` and a few config APIs, so every coverage-enabled run emits `[DEPRECATION]` warnings. This migrates to the supported replacements: - All `# :nocov:` toggle pairs (201 markers, 64 files) rewritten via script to `# simplecov:disable` / `# simplecov:enable`, preserving reason text. Docs/prose mentions updated too. - In `enable_simplecov.rb`: `enable_for_subprocesses` → `merge_subprocesses` and `add_filter` → `skip` (both documented same-behavior renames). One non-mechanical change: `track_files` → `cover` is not a drop-in replacement — `cover` also *restricts* the report to its matchers, which would silently drop loaded files outside the glob (e.g. `spec_support/**`) from coverage enforcement on multi-gem runs. Since only string globs drive unloaded-file backfill, adding a match-everything block matcher restores the old semantics: ```ruby cover "{#{gems_being_tested_globs.join(",")}}" cover { |_source_file| true } ``` Verified: same multi-gem spec run on `main` and this branch produces an identical coverage report file universe; single-gem run has identical coverage totals with zero deprecation warnings.
1 parent c64cb9c commit 464eacd

67 files changed

Lines changed: 226 additions & 219 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ai-memory/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ When in doubt, follow `AGENTS.md` for workflow and coding practices.
5050
- **Immutable functional style**: Prefer immutable objects and functional transformations where feasible.
5151
- **Prefer simpler approaches**: Choose simpler implementations for easier debugging and contributor onboarding.
5252
- **Avoid monkey patching**: Prevents future problems common with this Ruby technique.
53-
- **100% test coverage**: Every line and branch covered except where explicitly opted out with `:nocov:` comments.
53+
- **100% test coverage**: Every line and branch covered except where explicitly opted out with `simplecov:disable` comments.
5454
- **Validate all documentation snippets**: Code examples in documentation are validated by CI to ensure they always work.
5555

5656
## System Patterns

config/schema/teams.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,22 +180,22 @@
180180
t.field "id", "ID!"
181181
t.relates_to_many "teams", "Team", via: "country_code", dir: :in, singular: "team"
182182

183-
# :nocov: -- only one side of these conditionals is executed in our test suite (but both are covered by rake tasks)
183+
# simplecov:disable -- only one side of these conditionals is executed in our test suite (but both are covered by rake tasks)
184184
t.apollo_key fields: "id" if t.respond_to?(:apollo_key)
185-
# :nocov:
185+
# simplecov:enable
186186

187187
# Note: we use `paginated_collection_field` here in order to exercise a case with the Apollo entity resolver and
188188
# a paginated collection field, which initially yielded an exception.
189189
t.paginated_collection_field "names", "String" do |f|
190-
# :nocov: -- only one side of these conditionals is executed in our test suite (but both are covered by rake tasks)
190+
# simplecov:disable -- only one side of these conditionals is executed in our test suite (but both are covered by rake tasks)
191191
f.apollo_external if f.respond_to?(:apollo_external)
192-
# :nocov:
192+
# simplecov:enable
193193
end
194194

195195
t.field "currency", "String" do |f|
196-
# :nocov: -- only one side of these conditionals is executed in our test suite (but both are covered by rake tasks)
196+
# simplecov:disable -- only one side of these conditionals is executed in our test suite (but both are covered by rake tasks)
197197
f.apollo_external if f.respond_to?(:apollo_external)
198-
# :nocov:
198+
# simplecov:enable
199199
end
200200
end
201201

config/schema/widgets.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@
164164
i.route_with "workspace_id"
165165
i.default_sort "created_at", :desc
166166
i.has_had_multiple_sources!
167-
# :nocov: -- test suite only covers one side of the conditional
167+
# simplecov:disable -- test suite only covers one side of the conditional
168168
i.warehouse_table "widget_records" if ENV["DEMONSTRATE_WAREHOUSE_APIS"]
169-
# :nocov:
169+
# simplecov:enable
170170
end
171171

172172
t.derive_indexed_type_fields "WidgetCurrency", from_id: "cost.currency", route_with: "cost_currency_primary_continent", rollover_with: "cost_currency_introduced_on" do |derive|
@@ -236,9 +236,9 @@
236236

237237
# Exclude this internal lookup table from the data warehouse.
238238
t.index "widget_workspaces" do |i|
239-
# :nocov: -- test suite only covers one side of the conditional
239+
# simplecov:disable -- test suite only covers one side of the conditional
240240
i.exclude_from_warehouse if ENV["DEMONSTRATE_WAREHOUSE_APIS"]
241-
# :nocov:
241+
# simplecov:enable
242242
end
243243
end
244244

@@ -293,7 +293,7 @@
293293

294294
# Define some Apollo-specific schema elements when we are defining the schema for Apollo.
295295
if schema.respond_to?(:target_apollo_federation_version)
296-
# :nocov: -- this file is only exercised in a test running without `elasticgraph-apollo`.
296+
# simplecov:disable -- this file is only exercised in a test running without `elasticgraph-apollo`.
297297
t.apollo_entity_ref_field "owner", "ComponentOwner", id_field_name_in_index: "owner_id"
298298
t.apollo_entity_ref_field "owners", "[ComponentOwner!]!", id_field_name_in_index: "owner_ids"
299299
t.apollo_entity_ref_paginated_collection_field "owners_paginated", "ComponentOwner", id_field_name_in_index: "owner_ids"
@@ -302,7 +302,7 @@
302302
t.field "token", "ID"
303303
t.apollo_key fields: "token", resolvable: false
304304
end
305-
# :nocov:
305+
# simplecov:enable
306306
end
307307

308308
t.index "components" do |i|

config/site/Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ module ElasticGraph
579579
580580
Every executable line in example Ruby files must be executed during
581581
validation. If a line intentionally can't be covered, mark it with
582-
`# :nocov:` (same syntax as SimpleCov).
582+
`# simplecov:disable` / `# simplecov:enable` (same syntax as SimpleCov).
583583
EOS
584584
end
585585
end

config/site/examples/custom_resolver/validate.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
data = response.fetch("data")
1818

1919
unless (3..36).cover?(data.fetch("roll6SidedDice")) && (3..60).cover?(data.fetch("roll10SidedDice"))
20-
# :nocov: -- only executes on validation failure
20+
# simplecov:disable -- only executes on validation failure
2121
raise <<~EOS
2222
Got an unexpected response:
2323
2424
#{::JSON.pretty_generate(response)}
2525
EOS
26-
# :nocov:
26+
# simplecov:enable
2727
end

config/site/examples/music/Rakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ElasticGraph::Local::RakeTasks.new(
1717
tasks.schema_definition_extension_modules << ElasticGraph::JSONIngestion::SchemaDefinition::APIExtension
1818
end
1919

20-
# :nocov: -- only used for manual live-server query validation, not during the build
20+
# simplecov:disable -- only used for manual live-server query validation, not during the build
2121
require "graphql"
2222
require "json"
2323
require "net/http"
@@ -214,4 +214,4 @@ namespace :example_queries do
214214
end
215215
end
216216
end
217-
# :nocov:
217+
# simplecov:enable

config/site/src/guides/guiding-principles.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ These are the "north stars" that guide ElasticGraph development. They guide the
107107
we avoid it.
108108

109109
**Every line and branch of code must be covered by tests except where we intentionally opt-out.**
110-
: Our CI build enforces 100% test coverage except where we opt-out using [`:nocov:` comments](https://github.com/search?q=repo%3Ablock%2Felasticgraph%20nocov&type=code).
110+
: Our CI build enforces 100% test coverage except where we opt-out using [`simplecov:disable` comments](https://github.com/search?q=repo%3Ablock%2Felasticgraph%20%22simplecov%3Adisable%22&type=code).
111111
This high level of test coverage means that most of the time, if it passes the CI build, it works in production.
112112
It also makes it obvious at a glance which lines of code are uncovered by tests--if a line isn't wrapped with a
113-
`:nocov:` comment then you know it's covered!
113+
`simplecov:disable` comment then you know it's covered!
114114

115115
**We aim to validate all snippets and code examples at this website.**
116116
: Our documentation is so much more useful if users can trust that the code snippets we provide always work.

elasticgraph-admin/spec/integration/elastic_graph/admin/index_definition_configurator/for_index_template_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ def put_index_definition_url(index_definition_name, _subresource = nil)
4343
alias_method :put_index_template_definition_url, :put_index_definition_url
4444

4545
def make_datastore_calls_to_configure_index_def(index_name, subresource = nil)
46-
# :nocov: -- when we are building against OpenSearch, one side of this conditional is not covered
46+
# simplecov:disable -- when we are building against OpenSearch, one side of this conditional is not covered
4747
subresource = :mapping if subresource == :mappings && datastore_backend == :elasticsearch
48-
# :nocov:
48+
# simplecov:enable
4949

5050
path_for_now_index = "/#{concrete_index_name_for_now(index_name)}"
5151
path_for_now_index += "/_#{subresource}" if subresource

elasticgraph-admin/spec/integration/elastic_graph/admin/index_definition_configurator/shared_examples.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ def get_index_definition_configuration(index_definition_name)
2020

2121
def put_index_definition_url(index_definition_name, subresource = nil)
2222
url = "/#{index_definition_name}"
23-
# :nocov: -- when we are building against OpenSearch, one side of this conditional is not covered
23+
# simplecov:disable -- when we are building against OpenSearch, one side of this conditional is not covered
2424
subresource = :mapping if subresource == :mappings && datastore_backend == :elasticsearch
25-
# :nocov:
25+
# simplecov:enable
2626
subresource ? "#{url}/_#{subresource}" : url
2727
end
2828

elasticgraph-apollo/lib/elastic_graph/apollo/graphql/entities_field_resolver.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,15 @@ def adapter
294294
self
295295
end
296296

297-
# :nocov: -- these methods are not called on an adapter when `root_document_type?` returns `false`.
297+
# simplecov:disable -- these methods are not called on an adapter when `root_document_type?` returns `false`.
298298
def customize_query(query, representations)
299299
nil
300300
end
301301

302302
def index_search_hits(response)
303303
nil
304304
end
305-
# :nocov:
305+
# simplecov:enable
306306

307307
def identify_matching_hit(indexed_search_hits, representation, context:, index:)
308308
representation.representation_hash

0 commit comments

Comments
 (0)