Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fmt: don't change paths when formatting imports #21148

Merged
merged 3 commits into from
Mar 30, 2024

Conversation

ttytm
Copy link
Member

@ttytm ttytm commented Mar 30, 2024

@spytheman your point made here #21134 (comment) confirms itself.

With our current module lookup there are more scenarios where it is required to keep the a src. part in the import. E.g. in v-analyzer for build.vsh (src.metadata) or in tools/project-checker.v. By removing the src. prefix vfmt would break the functionality, since the imported modules are not found anymore.
Now vfmt would not try to "outsmart" anymore. And for scenarios where an import prefixed with src. and as well as the path without src. are valid, both will be also seen as valid by vfmt.

General formatting will still happen ofc, unused import symbols will be cleared, just the path of the import won't be changed anymore.

The tests that check for the import path update were removed. All other behavior is tested due to older and recently added tests, the changes should be covered.

@ttytm
Copy link
Member Author

ttytm commented Mar 30, 2024

To further improve test coverage and to better prevent regressions, I would add formatting check over an official extensive project like v-analyzer to Vs regular CI.

@ttytm
Copy link
Member Author

ttytm commented Mar 30, 2024

CI step added isolated on a separate branch - to verify it would recognize formatting issues https://github.com/ttytm/v/actions/runs/8489249682/job/23259136533

v fmt -c .
exit_code=$?
if [[ $exit_code -ne 0 && $exit_code -ne 5 ]]; then
# Don't fail on on internal errors
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Don't fail on on internal errors
# Don't fail on internal errors

@spytheman spytheman merged commit 6f99796 into vlang:master Mar 30, 2024
42 checks passed
@ttytm ttytm deleted the fmt/fix-imports branch April 14, 2024 06:35
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.

None yet

2 participants