Usage of `exclude` with force_unwrapping
opt_in_rules:
- force_unwrapping
force_unwrapping:
severity: error
excluded:
- ".*Tests\\.swift"
Seels like excluded is not working to my expectations.
I want to exclude force_unwrapping from certain files that belong in the following folders pattern ⏬
📁Folders
Modules/PAM/Foo1/Tests
Modules/PAM/Foo2/Tests
Modules/PAM/Foo3/Tests
Modules/PAM/Foo4/Tests
Modules/PAM/Foo5/Tests
Modules/PAM/TwoFactorAuthentication/Tests
Modules/PAM/Wallet/Tests
Modules/PLATFORM/Analytics/Tests
Modules/PLATFORM/AppSecurity/Tests
Modules/PLATFORM/Core/Tests
Modules/PLATFORM/Debug/Tests
Modules/PLATFORM/Deeplinks/Tests
Modules/PLATFORM/DomainResolver/Tests
Modules/PLATFORM/ExecutableTask/Tests
I've come up with following questions
- Is
excludedsupported on non-custom rules? - Is there a guide on what excluded supports and what not? If someone can point me to a source code to take a look (is it a regex? a glob pattern?)
- What would be the solution for this usecase, if exists 🤔
I hope all your tests are located in one folder. Then you can just create a child swiftlint.yml in this folder with the rule disabled.
Ah I see you have many modules. But anyway, having nested configuration files seems to be a good practice.
@kapitoshka438 I guess it is a common practice each module to contain the tests, isn't it?
I guess to understand better I will have to take a look at internal implementation as it seems that the excluded is not working as expected 🤔
You also could try to have two configs in the root folder: a parent and a child. The parent disables the rule. The child enables in for everything but tests. (Read "Child/Parent Configs (Locally)" in the README)
Sure, I will take a look at this as plan_B as I am currently using swiftlint as Xcode build plugin so need to check if is supported there, anyways thank you @kapitoshka438 🙌
The main issue is that excluded is not a property of rules but of the whole configuration. Thus, your configuration should actually look more like:
excluded:
- ".*Tests\\.swift"
force_unwrapping:
severity: error
This issue has been marked as stale because it has not seen any activity in the last 4 months. It is going to be closed soon if it stays inactive.
This issue is being closed due to inactivity. Please feel free to reopen if you have more information.