realm / SwiftLint

A tool to enforce Swift style and conventions.
https://realm.github.io/SwiftLint
MIT License
18.45k stars 2.2k forks source link

Ignore .build folders by default #5604

Open a7ex opened 1 month ago

a7ex commented 1 month ago

New Issue Checklist

New rule request

Since compiling with swift by default compiles into the hidden folder ".build" and there are checkouts of swift packages contained in the .build folder, wouldn't it be a good idea, if SwiftLint skips sich a .build folder by default?

We had a case, where an unexperienced user must have called swift build at some point in the - otherwise - Xcode project folder. It contained local swift packages and he wondered, why the build was failing with errors, when others could compile just fine. It turned out the errors were generated in the .build folders. Of course we found the issue and it was easily resolved, but it brought up the question to me: Should swiftlint really descend into these folders? 1.) They are most of the times "gitignored" and such can lead to different behaviour on different machines. 2.) There is no point really into descending into those "DerivedData" folders with their checkout Swift Packages, is it?

Therefore I think that rule should be opt-out.

SimplyDanny commented 3 weeks ago

While .build would be a good candidate to be ignored by default, I'm actually not inclined to hard-code certain folders into SwiftLint and maintain them. Other build tools have other working folders SwiftLint could ignore as well. On the other hand, users might use these folders as part of their projects not knowing (and not caring) that some build tools conventionally use them.

That said, it's very easy to specify explicit includes and excludes in the configuration. That would be the recommended way,