Skip to content

feat: support multiple dependency files in config and cli#334

Closed
sdn4z wants to merge 1 commit into
elementsinteractive:mainfrom
sdn4z:multiple-dep-file-cli
Closed

feat: support multiple dependency files in config and cli#334
sdn4z wants to merge 1 commit into
elementsinteractive:mainfrom
sdn4z:multiple-dep-file-cli

Conversation

@sdn4z
Copy link
Copy Markdown
Collaborator

@sdn4z sdn4z commented Sep 16, 2025

Support multiple dependency files, either via the cli or via the config

refs #325

@sdn4z sdn4z force-pushed the multiple-dep-file-cli branch from 3d53e3b to 2d0d3cf Compare September 16, 2025 15:46
@github-actions github-actions Bot added feature and removed feature labels Sep 16, 2025
@sdn4z
Copy link
Copy Markdown
Collaborator Author

sdn4z commented Sep 16, 2025

/lgtm review

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

🦉 lgtm Review

Score: Needs Work 🔧

🔍 Summary

Thank you for adding support for multiple dependency files. This is a valuable feature.

The overall approach is good, but there are a couple of critical bugs in the current implementation that need to be fixed. Specifically, the results are only being returned for the last file processed, and parsing a single dependency file from the config is broken. There's also a performance consideration with how package sources are fetched.

Additionally, the test suite needs to be expanded to cover these new multi-file scenarios, which would have helped catch these issues.

I've left detailed comments on each point. After addressing these, the PR should be in good shape. I'm scoring it 3/5 for now.

More information
  • Id: b94f449adb294b34b8ce29c62ea7963e
  • Model: gemini-2.5-pro
  • Created at: 2025-09-16T15:50:49.412248+00:00
Usage summary
  • Request count: 2
  • Request tokens: 54,358
  • Response tokens: 22,183
  • Total tokens: 76,541

See the 📚 lgtm-ai repository for more information about lgtm.

Comment thread tests/main/test_main.py
@@ -36,21 +36,21 @@ class TestCheckDependencies:
(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🦉 🧪 Testing

Severity: MEDIUM 🟡

The PR adds support for multiple dependency files, but there are no tests to verify this new functionality end-to-end. Please add a test case where check_dependencies is called with two or more dependency files, each containing typos, and assert that the results contain typos from all provided files. Such a test would have likely caught the bug with typos_by_file being re-initialized within the loop.

More information about this comment
  • File: tests/main/test_main.py
  • Line: 1
  • Relative line: 1
  • With suggestion: No
  • Suggestion ready for replacement: No

@@ -1,7 +1,6 @@
import dataclasses
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🦉 🧪 Testing

Severity: MEDIUM 🟡

There is no test case that verifies the configuration parsing when dependency_file is a single string in the TOML file. The existing tests were updated to use a list of files, but the case of a single string value should also be covered to prevent regressions and catch issues like the one in _get_read_config. Please add a test case for this scenario.

More information about this comment
  • File: tests/config/test_config_handler.py
  • Line: 1
  • Relative line: 1
  • With suggestion: No
  • Suggestion ready for replacement: No

Comment thread src/twyn/main.py
Comment on lines +165 to +167
for dep_file in dependency_files:
dependency_managers = _get_dependency_managers_and_parsers_mapping(dep_file)
typos_by_file = TyposquatCheckResults()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🦉 🎯 Correctness

Severity: HIGH 🔴

typos_by_file = TyposquatCheckResults()

typos_by_file is re-initialized inside the for dep_file in dependency_files: loop. This will cause the function to only return the results from the last dependency file that is processed. It should be initialized before the loop.

Suggested change
for dep_file in dependency_files:
dependency_managers = _get_dependency_managers_and_parsers_mapping(dep_file)
typos_by_file = TyposquatCheckResults()
typos_by_file = TyposquatCheckResults()
for dep_file in dependency_files:
dependency_managers = _get_dependency_managers_and_parsers_mapping(dep_file)
More information about this comment
  • File: src/twyn/main.py
  • Line: 167
  • Relative line: 60
  • With suggestion: Yes
  • Suggestion ready for replacement: Yes

@elementsinteractive elementsinteractive deleted a comment from github-actions Bot Sep 17, 2025
@elementsinteractive elementsinteractive deleted a comment from github-actions Bot Sep 17, 2025
@sdn4z sdn4z closed this Sep 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant