SwiftLint icon indicating copy to clipboard operation
SwiftLint copied to clipboard

Implement `allowed_types` option for `one-declaration-per-file` rule

Open snofla opened this issue 6 months ago • 1 comments
trafficstars

WIP: This is going to resolve #6072

snofla avatar May 19 '25 06:05 snofla

1 Warning
:warning: Big PR
18 Messages
:book: Building this branch resulted in a binary size of 25523.99 KiB vs 25491.34 KiB when built on main (0% larger).
:book: Linting Aerial with this PR took 1.05 s vs 1.06 s on main (0% faster).
:book: Linting Alamofire with this PR took 1.43 s vs 1.42 s on main (0% slower).
:book: Linting Brave with this PR took 9.6 s vs 9.6 s on main (0% slower).
:book: Linting DuckDuckGo with this PR took 26.77 s vs 26.82 s on main (0% faster).
:book: Linting Firefox with this PR took 13.96 s vs 13.95 s on main (0% slower).
:book: Linting Kickstarter with this PR took 10.77 s vs 10.72 s on main (0% slower).
:book: Linting Moya with this PR took 0.56 s vs 0.55 s on main (1% slower).
:book: Linting NetNewsWire with this PR took 3.23 s vs 3.23 s on main (0% slower).
:book: Linting Nimble with this PR took 0.85 s vs 0.85 s on main (0% slower).
:book: Linting PocketCasts with this PR took 9.43 s vs 9.39 s on main (0% slower).
:book: Linting Quick with this PR took 0.49 s vs 0.49 s on main (0% slower).
:book: Linting Realm with this PR took 4.9 s vs 4.89 s on main (0% slower).
:book: Linting Sourcery with this PR took 2.48 s vs 2.48 s on main (0% slower).
:book: Linting Swift with this PR took 5.74 s vs 5.75 s on main (0% faster).
:book: Linting VLC with this PR took 1.5 s vs 1.51 s on main (0% faster).
:book: Linting Wire with this PR took 22.79 s vs 22.74 s on main (0% slower).
:book: Linting WordPress with this PR took 13.09 s vs 13.1 s on main (0% faster).

Generated by :no_entry_sign: Danger

SwiftLintBot avatar May 19 '25 06:05 SwiftLintBot

I wonder what the meaning of this option should be. Does it mean "these types do not count at all" or is it like "files with only these types are ignored"? In other words, with allowed_types = ["struct"], would

class C {}
struct S {}

trigger or not?

SimplyDanny avatar Jul 02 '25 20:07 SimplyDanny

@SimplyDanny It would not trigger. A better name for the option would be:

additionally_allowed_types

but a another, perhaps more correct but less verbose name escapes me right now :)

snofla avatar Jul 03 '25 18:07 snofla

ignored_types, disregarded_types or skipped_types (from the rule's point of view) would be other options.

SimplyDanny avatar Jul 03 '25 19:07 SimplyDanny

Before you continue, please rebase your PR onto the most recent main branch.

SimplyDanny avatar Aug 04 '25 16:08 SimplyDanny