-
Notifications
You must be signed in to change notification settings - Fork 248
Add strict flag #252
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
Add strict flag #252
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
I somewhat think that this feature would be served better by having it actually upgrade the severity of the diagnostics themselves to .error
instead of .warning
, and then the extra check wouldn't be necessary. But that would also require a significant refactoring of the way we currently create those diagnostics... and I don't think we should do that yet, because there are other changes that may be worth doing at the same time as well (like letting the severity of warnings be controlled on a case-by-case basis in the configuration file).
So what you have here seems like a reasonable approach in the meantime.
Can you rebase your change on top of the main
branch? (I know it doesn't build against a current development snapshot; unfortunately I haven't had cycles to update it based on recent syntax changes upstream, but I can try to do that soon in order to merge this in.)
4b0dcbe
to
586231c
Compare
Hey @allevato! I have rebased on top of
I agree, let me know if you want help with the subsequent refactor. Promoting warnings to errors themselves would also enable me to write tests - I am not sure if it is possible at the moment to do so as the changes are limited to |
Yes, please point the PR at
I'm always happy to discuss design proposals and review changes! Since it hasn't felt terribly urgent, I haven't given it a great deal of thought yet so I don't have a strong lean about how to best handle the change. The one immediate issue that comes to mind is that our diagnostic values are created completely context-less, and they have the severity baked in. So if we wanted to move to a model where the We also can't tie the "category" of a diagnostic 1:1 to the "rule" concept because we emit diagnostics from other places as well, such as the whitespace linter, and the frontend itself. Heck, some rules emit multiple kinds of diagnostics, and someone might want to control their severity independently (we'd have to decide if that makes sense and if we want to allow that level of granularity). Unfortunately these changes would ripple through the entire codebase—we'd probably need to re-model the I'll try to think on it some more and see where we can get with smaller incremental changes. |
586231c
to
1898488
Compare
Done!
This approach seems sensible to me - but as you said, it can create a lot of changes. But for the long run, it is probably beneficial to have a stronger control over the diagnostics. Once we'd have our own diagnostics engine layer, promoting warnings to errors (or some other modification of the severity) could be done very easily. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good now, thank you!
* Add Brewfile.lock.json file * Update dependencies Fix CommonMark version specifier * Add version-specific manifest for Swift 5.4 * Change minimum Swift version requirements to version 5.3+ * Fix failing tests
Hi!
I'd find it quite useful to be able to promote warnings to be errors when running
swift-format lint
.My use-case is that I'd like to validate on CI that no formatting is needed but we want to leave it up to the developer to fix it - this is very similar to what eg.
swiftlint
offers (andswiftformat
offers a similar functionality as well, for that matter).The solution is quite simple and more-or-less copies
if frontend.errorsWereEmitted { throw ExitCode.failure }
.This PR is only a draft to validate whether such feature would be welcome, so there are no tests (I have validated this only by running it locally).
Sorry if this is already possible and I have missed it 🙇 (I have tried to see if there's any mention of this in the repo and in the previous PRs, but have not found any)