foundry: classify dependencies relative to the project root#691
Open
rootminus0x1 wants to merge 1 commit into
Open
foundry: classify dependencies relative to the project root#691rootminus0x1 wants to merge 1 commit into
rootminus0x1 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Foundry.is_dependencyclassifies a file as a dependency by checking forlib/node_modulescomponents anywhere in its absolute path. When a Foundry project is checked out under a parent directory namedlib— the normal layout when it's a git submodule (<repo>/lib/<project>) — every source file's absolute path contains alibcomponent, so all of the project's own sources are wrongly flagged as dependencies.Dependency-aware consumers then silently skip the whole project. With Slither, the dead-code detector (and other dependency-respecting detectors) report nothing for a project nested under
lib/, while the same project analyzed as a standalone checkout (e.g. in CI) reports findings — a confusing local-vs-CI divergence with no error.Fixes #690.
Change
is_dependencynow classifies the path relative to the project root (self._project_root, already on theFoundryinstance) before the component check, so onlylib/node_modules/ configured-libs directories within the project count. Paths outside the project tree fall back to the previous behaviour.Test
Adds
tests/test_is_dependency.py: a Foundry project created under a parentlib/directory, asserting itssrc/is not a dependency while its ownlib/contracts still are. Fails onmaster, passes with the fix.Notes
ruff check,ruff format --check, andty checkall pass.Related: #279 — same family (dependency path-component detection vs. directory layout), but the opposite failure (dependencies not found when hoisted in a monorepo).