Delete deprecated functions in Config.util, and associated tests.#845
Delete deprecated functions in Config.util, and associated tests.#845jdmarshall merged 3 commits intonode-config:masterfrom
Conversation
|
@markstos anything else you’d like to put into a 4.1 release? |
|
@jdmarshall Nothing else, thanks. |
markstos
left a comment
There was a problem hiding this comment.
Approved as a natural progression after 4.0 deprecation warning.
This function has a number of bugs, and lodash does it better. closes node-config#814
WalkthroughRemoved 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
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 unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Rebased on master. |
There was a problem hiding this comment.
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 stateLoad.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 testLoad 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-nullUsing 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.
📒 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.cloneDeeporconfig.util.makeHiddenremain.- 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.
There was a problem hiding this comment.
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.
📒 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)
|
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 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. |
This finishes the deprecation warnings introduced in 4.0
This should sit a while.
Summary by CodeRabbit
Refactor
Tests
Chores