fix(strict-boolean-expressions): fix memory leak #316
Merged
+16
−16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR
Fixed a bug in the
strict-boolean-expressionsrule by making thetraversedNodesset local to each rule execution.What changed?
Moved the
traversedNodesset from a package-level variable to a local variable within the rule'sRunfunction. Updated all traversal functions to accept this set as a parameter, ensuring that each rule execution has its own isolated set of traversed nodes.How to test?
Run the linter on code with multiple files containing boolean expressions. Verify that the rule correctly identifies issues in each file independently without being affected by previously traversed nodes from other files.
Why make this change?
The previous implementation used a global
traversedNodesset, which could cause issues when linting multiple files as nodes from one file could prevent proper traversal in subsequent files. This change ensures each rule execution has its own clean state, preventing cross-file interference and potential false negatives.