Closed philviso-reverb closed 2 years ago
Failed to terminate means that SwiftFormat wasn't able to reach a stable state where the file required no formatting changes after repeated rule applications. It's usually caused by a conflict between two rules where one undoes the effect of the other.
If you run with --verbose enabled, it should tell you which the last file it tried to format was before the failure. If you share that file + your config I can try to narrow down the problem.
Thanks for the tip about using --verbose
. The conflicting rules we had were maxwidth
+ wrapSingleLineComments
. There was a comment with a long URL that couldn't be wrapped.
@philviso-reverb that shouldn't cause a conflict. SwiftFormat is aware that it can't wrap URLs so it should ignore it rather than get stuck in a loop. If you could post a code sample so I can reproduce the issue that would be helpful.
Oh 😄
In that case, I'll keep investigating and post sample code / configs if I can pin down exactly what's going on here.
OK, I narrowed it down to using maxwidth
, comments that use 3 slashes ///
, and a long URL
Here's the config...
--maxwidth 120
Here's the "code" that triggers the failure. Just put this in a file on its own.
/// Link to SDK documentation - https://docs.adyen.com/checkout/3d-secure/native-3ds2/api-integration#collect-the-3d-secure-2-device-fingerprint-from-an-ios-app
If I replace the ///
with //
then it works properly.
Thanks!
@philviso-reverb fixed in 0.50.3
Hi,
I just upgraded a project to swiftformat 0.50.2, and whenever I try to format or lint our project I see the following output...
I've been able to track the error down to two separate options, but I can't tell what's wrong. The two options that are causing the error to happen are...
In the case of
--self
, it looks like the only value that's causing a problem isinit-only
. With--maxwidth
it seems like any value other thannone
causes an error.Could you provide some info about the context of when
error: Failed to terminate
happens? I looked through the code, but it doesn't give much information about what that code path actually means.Thanks!