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

Turn off all code-affecting rules by default #1705

Open
dankinsoid opened this issue May 21, 2024 · 3 comments
Open

Turn off all code-affecting rules by default #1705

dankinsoid opened this issue May 21, 2024 · 3 comments

Comments

@dankinsoid
Copy link

I've spent the whole day debugging a bug and finally figured out that my app delegate function signatures look like this:

public func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool

because of the unusedArguments rule that is enabled by default.

There are some absolutely harmless formatting rules like indentation and many rules that can affect code functionality like unusedArguments. I believe that by default, only harmless rules should be enabled. Or, at least, some default rule presets should exist, so I could choose a safe preset as a base and then configure it in my .swiftformat file.

@nicklockwood
Copy link
Owner

What was the bug?

@dankinsoid
Copy link
Author

@nicklockwood it was my fault, incorrect protocol implementation, I was in a hurry to create an issue. However, I also had a problem: swiftformat replaced writer.forEach with for item in writer, but writer was not a Collection, it just had a forEach method. I know that I can avoid such problems with //swiftformat:disable, but I would like to have some default safe rules preset to ensure that nothing in my project can be broken by the formatter, especially when using swiftformat for the first time on a large project.

@nicklockwood
Copy link
Owner

@dankinsoid understood. The safest option for now is to use --disable all and then manually enable just the rules that you would like.

But I think the safe ruleset option is a good idea and I will investigate adding that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants