Skip to content

fix(dependency):SP-4443 scan dependencies with include all files type… - #926

Merged
agustingroh merged 1 commit into
mainfrom
fix/SP-4443-dependency-scan
Jun 9, 2026
Merged

agustingroh merged 1 commit into
mainfrom
fix/SP-4443-dependency-scan

Conversation

@agustingroh

@agustingroh agustingroh commented Jun 9, 2026 •

Copy link
Copy Markdown
Collaborator

…s option enabled

Summary by CodeRabbit

  • Bug Fixes
    • Fixed a crash that occurred when scanning projects with "Include all file types" enabled in the dependency scanner.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

DependencyTask now loads filter rules with graceful handling for missing files and passes them to BlackListDependencies via a new DependencyFilterRule contract, preventing crashes when Include all file types is enabled.

Changes

Dependency Filter Loading Refactoring

Layer / File(s) Summary
Dependency filter rule contract definition
src/main/workspace/tree/blackList/BlackListDependencies.ts
DependencyFilterRule interface is exported to describe the persisted rule shape with ftype and scope properties.
BlackListDependencies refactoring
src/main/workspace/tree/blackList/BlackListDependencies.ts
Constructor changes from loading files via a path parameter to accepting an optional rules array, and builds NameFilter instances only from rules where ftype is NAME and scope is FOLDER.
DependencyTask filter loading and integration
src/main/task/scanner/dependency/DependencyTask.ts
DependencyFilterRule is imported, a new loadDependencyFilterRules() helper checks for filter.json existence and returns an empty list if missing, and scanDependencies() constructs BlackListDependencies from the loaded rules instead of a file path.
Changelog documentation
CHANGELOG.md
Documents the fix that dependency scanning no longer crashes with Include all file types enabled.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • isasmendiagus

Poem

A rabbit hops through filters with care, 🐰
No crash when the file's simply not there,
Rules load with grace, in an array they rest,
Dependency scanning passes the test! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: fixing dependency scanning when 'include all file types' option is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/SP-4443-dependency-scan

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed: dependency version conflict. Check your lock file or package.json.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
src/main/task/scanner/dependency/DependencyTask.ts (2)

48-48: 💤 Low value

Clarify the log message.

The message mentions "all extensions enabled," but the filters being skipped are folder-name exclusions (e.g., node_modules), not file-extension filters. While the message references the "Include all file types" setting that caused filter.json to be absent, the wording could be clearer about what is actually being skipped.

💬 Suggested rewording
-      log.info('[ DependencyTask ]: filter.json not found, skipping dependency filters (all extensions enabled)');
+      log.info('[ DependencyTask ]: filter.json not found, skipping folder exclusions (Include all file types enabled)');
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/task/scanner/dependency/DependencyTask.ts` at line 48, Update the
log message in DependencyTask (the log.info call that currently reads "[
DependencyTask ]: filter.json not found, skipping dependency filters (all
extensions enabled)") to clearly state that folder-name exclusion filters are
being skipped (e.g., node_modules) rather than file-extension filters; locate
the log statement in the DependencyTask class/function and replace the wording
to reference "folder-name exclusion filters" and the "Include all file types"
setting so it's clear what is being skipped.

47-47: 💤 Low value

Prefer async file existence check for consistency.

The method uses fs.existsSync() (blocking) followed by fs.promises.readFile() (async). For consistency and to avoid blocking the event loop, consider using fs.promises.access() to check existence asynchronously, or simply attempt the read and catch ENOENT.

♻️ Async alternative
   private async loadDependencyFilterRules(): Promise<DependencyFilterRule[]> {
     const filterPath = `${this.project.metadata.getMyPath()}/filter.json`;
-    if (!fs.existsSync(filterPath)) {
-      log.info('[ DependencyTask ]: filter.json not found, skipping dependency filters (all extensions enabled)');
-      return [];
-    }
-    const raw = await fs.promises.readFile(filterPath, 'utf8');
-    return JSON.parse(raw).filters ?? [];
+    try {
+      const raw = await fs.promises.readFile(filterPath, 'utf8');
+      return JSON.parse(raw).filters ?? [];
+    } catch (err) {
+      if (err.code === 'ENOENT') {
+        log.info('[ DependencyTask ]: filter.json not found, skipping dependency filters (all extensions enabled)');
+        return [];
+      }
+      throw err;
+    }
   }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/task/scanner/dependency/DependencyTask.ts` at line 47, Replace the
blocking fs.existsSync(filterPath) check with an async existence check: either
await fs.promises.access(filterPath, fs.constants.F_OK) inside the async method
of DependencyTask (or the surrounding async function) and handle the thrown
error, or simply remove the existence check and call await
fs.promises.readFile(filterPath) inside a try/catch that specifically handles
ENOENT. Update the control flow around the existing fs.promises.readFile() usage
so you no longer block the event loop and correctly handle the missing-file
error for filterPath.
src/main/workspace/tree/blackList/BlackListDependencies.ts (1)

5-11: ⚡ Quick win

Mark scope as optional in the interface.

From the context snippets (defaultFilter.ts shows rules like { condition: 'starts', value: '.', ftype: 'NAME' } without a scope property), the persisted filter rules do not always include a scope field. The interface should reflect this runtime reality. Line 29 handles undefined scope correctly by filtering it out, but the type definition should be accurate.

📝 Suggested type refinement
 export interface DependencyFilterRule {
   ftype: string;
-  scope: string;
+  scope?: string;
   condition: string;
   value: string;
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/workspace/tree/blackList/BlackListDependencies.ts` around lines 5 -
11, The DependencyFilterRule interface incorrectly requires scope even though
persisted rules can omit it; update the interface declaration for
DependencyFilterRule to make the scope property optional (e.g., scope?: string)
so it matches runtime data (check references in BlackListDependencies and
defaultFilter.ts to ensure callers already handle undefined scope, no further
logic changes required).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/task/scanner/dependency/DependencyTask.ts`:
- Around line 45-53: The loadDependencyFilterRules function reads and parses
filter.json but returns parsed.filters without runtime validation; update
loadDependencyFilterRules to validate the parsed JSON before returning: after
JSON.parse(raw) verify parsed.filters is an Array, then ensure each element
matches the DependencyFilterRule shape (e.g., has required keys like condition
and value and correct types), filter out or reject invalid entries (log a
warning or throw a descriptive error), and finally return the validated array
(or [] on validation failure) so downstream code that expects
rule.condition/rule.value is safe.

---

Nitpick comments:
In `@src/main/task/scanner/dependency/DependencyTask.ts`:
- Line 48: Update the log message in DependencyTask (the log.info call that
currently reads "[ DependencyTask ]: filter.json not found, skipping dependency
filters (all extensions enabled)") to clearly state that folder-name exclusion
filters are being skipped (e.g., node_modules) rather than file-extension
filters; locate the log statement in the DependencyTask class/function and
replace the wording to reference "folder-name exclusion filters" and the
"Include all file types" setting so it's clear what is being skipped.
- Line 47: Replace the blocking fs.existsSync(filterPath) check with an async
existence check: either await fs.promises.access(filterPath, fs.constants.F_OK)
inside the async method of DependencyTask (or the surrounding async function)
and handle the thrown error, or simply remove the existence check and call await
fs.promises.readFile(filterPath) inside a try/catch that specifically handles
ENOENT. Update the control flow around the existing fs.promises.readFile() usage
so you no longer block the event loop and correctly handle the missing-file
error for filterPath.

In `@src/main/workspace/tree/blackList/BlackListDependencies.ts`:
- Around line 5-11: The DependencyFilterRule interface incorrectly requires
scope even though persisted rules can omit it; update the interface declaration
for DependencyFilterRule to make the scope property optional (e.g., scope?:
string) so it matches runtime data (check references in BlackListDependencies
and defaultFilter.ts to ensure callers already handle undefined scope, no
further logic changes required).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2f1dc833-2aed-4683-90f8-82b34a87ae6e

📥 Commits

Reviewing files that changed from the base of the PR and between 9f32fa8 and 0d5e381.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/main/task/scanner/dependency/DependencyTask.ts
  • src/main/workspace/tree/blackList/BlackListDependencies.ts

Comment thread src/main/task/scanner/dependency/DependencyTask.ts
@agustingroh
agustingroh merged commit aa11612 into main Jun 9, 2026
4 checks passed
@agustingroh
agustingroh deleted the fix/SP-4443-dependency-scan branch June 9, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant