Skip to content

Delete deprecated functions in Config.util, and associated tests.#845

Merged
jdmarshall merged 3 commits intonode-config:masterfrom
jdmarshall:deletions
Aug 15, 2025
Merged

Delete deprecated functions in Config.util, and associated tests.#845
jdmarshall merged 3 commits intonode-config:masterfrom
jdmarshall:deletions

Conversation

@jdmarshall
Copy link
Copy Markdown
Collaborator

@jdmarshall jdmarshall commented Jul 17, 2025

This finishes the deprecation warnings introduced in 4.0

This should sit a while.

Summary by CodeRabbit

  • Refactor

    • Removed a broad set of long-deprecated public utility wrappers to streamline the API; core configuration behavior and supported public APIs remain unchanged.
  • Tests

    • Pruned and reorganized test coverage for the removed utilities and environment-selection scenarios; migrated several tests to use a dedicated loader helper and updated assertions to match the current public API.
  • Chores

    • Removed obsolete documentation blocks and references to deprecated utilities.

@jdmarshall jdmarshall added this to the 4.1 milestone Jul 17, 2025
@jdmarshall jdmarshall modified the milestones: 4.1, 4.2 Jul 17, 2025
@jdmarshall
Copy link
Copy Markdown
Collaborator Author

@markstos anything else you’d like to put into a 4.1 release?

@markstos
Copy link
Copy Markdown
Collaborator

markstos commented Aug 8, 2025

@jdmarshall Nothing else, thanks.

Copy link
Copy Markdown
Collaborator

@markstos markstos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved as a natural progression after 4.0 deprecation warning.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Aug 15, 2025

Walkthrough

Removed many deprecated util wrapper functions from lib/config.js and pruned/updated tests and fixtures accordingly; several tests were refactored to use the Load utility and some assertions now expect makeImmutable instead of cloneDeep. No new runtime features added.

Changes

Cohort / File(s) Summary
Core util wrapper removals
lib/config.js
Removed many deprecated util wrappers (e.g., makeHidden, getOption, locateMatchingFiles, resolveDeferredConfigs, parseFile, parseString, cloneDeep, setPath, substituteDeep, getCustomEnvVars, equalsDeep, diffDeep, extendDeep, isObject, isPromise, initParam, getCmdLineArg, getEnv, getRegExpFlags). Core behavior and non-deprecated APIs unchanged.
Pruned util-related tests
test/1-protected-test.js, test/util.js
Deleted test suites covering many util functions and some attachProtoDeep cases; reduced coverage for deprecated helpers.
Env precedence tests and fixtures removed
test/12-node_env-override.js, test/13-node_env-hostname.js, test/12-config/*.json
Removed environment-precedence tests and related fixture entries (apollo.json, development.json content removed, mercury.json deleted).
SkipConfigSources tests and fixtures removed
test/18-skipConfigSources.js, test/18-config/default.json, test/18-extra-config/*
Deleted skipConfigSources tests and associated fixture files (default.json, customFile.json, etc.).
Load-based test refactors
test/19-custom-environment-variables.js, test/7-unicode-situations.js
Replaced direct parseFile usage in tests with Load.loadFile from lib/util (introduces test use of named export Load); removed getCustomEnvVars test block.
API assertion update
test/2-config-test.js
Updated tests to expect config.util.makeImmutable (replacing prior cloneDeep checks); removed makeHidden tests.

Sequence Diagram(s)

sequenceDiagram
    participant Test
    participant Load
    participant FS
    Test->>Load: LOAD.loadFile(filePath)
    Load->>FS: read file content
    FS-->>Load: file content
    Load->>Load: parse/interpret content
    Load-->>Test: returned config object
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • markstos

Poem

Thump-thump—I cleaned the old code stack,
Buried wrappers in a tidy pack.
Tests now hop to Load’s quick track,
makeImmutable keeps settings intact.
A carrot’s cheer, the burrow’s back. 🥕🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@jdmarshall
Copy link
Copy Markdown
Collaborator Author

Rebased on master.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (4)
test/19-custom-environment-variables.js (1)

7-9: Switch to Load is reasonable; consider per-test instantiation to avoid hidden state

Load.loadFile merges into the loader’s state via addConfig. Reusing a single LOAD across tests can accumulate state and subtly affect later expectations. Prefer creating a fresh loader in each beforeEach where you need to parse a file.

test/7-unicode-situations.js (3)

7-12: Good migration to Load; consider isolating loader instances per test

Load accumulates config via addConfig. Creating a new Load({}) inside each test (or beforeEach) helps avoid cross-test pollution if additional files are loaded in future assertions.


16-21: Prefer path.join and consider asserting the parsed result is non-null

Using path.join is more robust than string concatenation with path.sep.

-      let standardNoBomConfigFile = process.env.NODE_CONFIG_DIR + path.sep + 'defaultNoBOM.json';
+      const standardNoBomConfigFile = path.join(process.env.NODE_CONFIG_DIR, 'defaultNoBOM.json');
       assert.doesNotThrow(function () {
         result = LOAD.loadFile(standardNoBomConfigFile);
       }, 'standard config file with no BOM has a parse error');
+      assert.ok(result && typeof result === 'object', 'Parsed config should be an object');

25-31: Same here: build the path with path.join and assert the parse output

-      let configFileWithBom = process.env.NODE_CONFIG_DIR + path.sep + 'defaultWithUnicodeBOM.json';
+      const configFileWithBom = path.join(process.env.NODE_CONFIG_DIR, 'defaultWithUnicodeBOM.json');
       assert.doesNotThrow(function () {
         result = LOAD.loadFile(configFileWithBom);
       }, 'config file with BOM has a parse error');
+      assert.ok(result && typeof result === 'object', 'Parsed config should be an object');
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 29a7bfd and a0ad69f.

📒 Files selected for processing (15)
  • lib/config.js (0 hunks)
  • test/1-protected-test.js (0 hunks)
  • test/12-config/apollo.json (0 hunks)
  • test/12-config/development.json (0 hunks)
  • test/12-config/mercury.json (0 hunks)
  • test/12-node_env-override.js (0 hunks)
  • test/13-node_env-hostname.js (0 hunks)
  • test/18-config/default.json (0 hunks)
  • test/18-extra-config/customFile.json (0 hunks)
  • test/18-extra-config/default.json (0 hunks)
  • test/18-skipConfigSources.js (0 hunks)
  • test/19-custom-environment-variables.js (3 hunks)
  • test/2-config-test.js (2 hunks)
  • test/7-unicode-situations.js (1 hunks)
  • test/util.js (0 hunks)
💤 Files with no reviewable changes (12)
  • test/18-extra-config/customFile.json
  • test/13-node_env-hostname.js
  • test/18-config/default.json
  • test/12-config/apollo.json
  • test/util.js
  • test/12-config/mercury.json
  • test/12-config/development.json
  • test/18-extra-config/default.json
  • test/12-node_env-override.js
  • lib/config.js
  • test/18-skipConfigSources.js
  • test/1-protected-test.js
🧰 Additional context used
🧬 Code Graph Analysis (3)
test/2-config-test.js (3)
test/1-protected-test.js (3)
  • assert (5-5)
  • config (30-30)
  • assert (831-833)
lib/config.js (1)
  • config (617-617)
test/makeImmutable-shared-refs.js (2)
  • data (14-61)
  • describe (13-83)
test/19-custom-environment-variables.js (3)
lib/config.js (1)
  • require (8-8)
test/0-util.js (8)
  • Load (11-11)
  • load (527-573)
  • load (656-696)
  • load (607-615)
  • load (617-625)
  • load (581-588)
  • load (486-525)
  • load (659-661)
lib/util.js (1)
  • Load (771-1193)
test/7-unicode-situations.js (1)
lib/util.js (1)
  • Load (771-1193)
🔇 Additional comments (1)
test/2-config-test.js (1)

57-57: Deprecated util wrappers removed; makeImmutable usage verified

  • Scanned the entire codebase: no references to config.util.cloneDeep or config.util.makeHidden remain.
  • Confirmed tests in test/2-config-test.js (lines 56 and 559) assert only config.util.makeImmutable.

All deprecated wrappers are fully removed and the new API is correctly in place. Approved.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
test/19-custom-environment-variables.js (1)

7-9: Prefer per-call Load construction and OS-safe path joins; avoid misleading ALL_CAPS instance

  • Load keeps internal state (config/sources). Reusing a single global instance across test cases can accumulate state and lead to brittle tests if more files are loaded later. Instantiating per call is cheap and avoids hidden coupling.
  • Split Path.join arguments into separate segments for better cross-platform behavior.
  • Minor: Use a standard relative require and avoid ALL_CAPS for an instance.

Apply this diff:

-const { Load } = require(__dirname + '/../lib/util');
+const { Load } = require('../lib/util');

-const LOAD = new Load({});
 
-configObject = LOAD.loadFile(Path.join(__dirname, '19-config/default.js'));
+configObject = new Load({}).loadFile(Path.join(__dirname, '19-config', 'default.js'));

-configObject = LOAD.loadFile(Path.join(__dirname, '19-config/default.js'));
+configObject = new Load({}).loadFile(Path.join(__dirname, '19-config', 'default.js'));

Also applies to: 23-23, 43-43

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a0ad69f and 0f7fee6.

📒 Files selected for processing (1)
  • test/19-custom-environment-variables.js (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
test/19-custom-environment-variables.js (3)
lib/config.js (2)
  • require (8-8)
  • Path (9-9)
test/0-util.js (8)
  • Load (11-11)
  • load (656-696)
  • load (527-573)
  • load (607-615)
  • load (617-625)
  • load (486-525)
  • load (581-588)
  • load (659-661)
lib/util.js (1)
  • Load (771-1193)

@jdmarshall jdmarshall merged commit 52aa438 into node-config:master Aug 15, 2025
2 checks passed
@jdmarshall jdmarshall deleted the deletions branch January 18, 2026 20:06
@erunion
Copy link
Copy Markdown

erunion commented Jan 29, 2026

I know I am shouting into the void here but I would like to voice my displeasure at the removal of this in a minor release. Yes I am aware that the API was deprecated in v4 but APIs should be removed in major releases. It's a major release!

Anybody that is using this and has ^4.0.0 installed will see breakages if any dependency they're using has ^4.0.0 as a dependency of its own.

@jdmarshall
Copy link
Copy Markdown
Collaborator Author

4.0 should have rightly been something more like 3.5 and 4.2->4.0 but there were several deletions already stacked up.

I don't believe anything more will be removed until 5.0, although new deprecations may appear before then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants