SwiftLint icon indicating copy to clipboard operation
SwiftLint copied to clipboard

NameConfiguration excluded_pattern

Open arnauddorgans opened this issue 4 years ago • 2 comments
trafficstars

What is the purpose of this PR?

The goal of this PR is to answer this issue https://github.com/realm/SwiftLint/issues/2156. It allows us to exclude regex pattern for generic_type_name, type_name and identifier_name rules.

How?

I added a new property to NameConfiguration named excluded_pattern

Testing?

Ran the three test commands stated in CONTRIBUTING.md file and all of them have passed locally.

arnauddorgans avatar Jul 13 '21 16:07 arnauddorgans

12 Messages
:book: Linting Aerial with this PR took 0.73s vs 0.74s on master (1% faster)
:book: Linting Alamofire with this PR took 0.96s vs 0.96s on master (0% slower)
:book: Linting Firefox with this PR took 3.32s vs 3.33s on master (0% faster)
:book: Linting Kickstarter with this PR took 5.47s vs 5.46s on master (0% slower)
:book: Linting Moya with this PR took 0.48s vs 0.45s on master (6% slower)
:book: Linting Nimble with this PR took 0.41s vs 0.4s on master (2% slower)
:book: Linting Quick with this PR took 0.2s vs 0.2s on master (0% slower)
:book: Linting Realm with this PR took 2.08s vs 2.08s on master (0% slower)
:book: Linting SourceKitten with this PR took 0.33s vs 0.33s on master (0% slower)
:book: Linting Sourcery with this PR took 1.95s vs 1.95s on master (0% slower)
:book: Linting Swift with this PR took 3.18s vs 3.18s on master (0% slower)
:book: Linting WordPress with this PR took 6.19s vs 6.19s on master (0% slower)

Generated by :no_entry_sign: Danger

SwiftLintBot avatar Jul 13 '21 16:07 SwiftLintBot

First of all: Thank you for the contribution and sorry for the late feedback!

I like the idea of supporting patterns for excluded names. However, the NameConfiguration already contains a few options and I would like to avoid adding a new one. The existing list of excluded names would only become a subset of the new excluded_pattern option.

What do you think about just interpreting the strings in the excluded list as regular expression that must match a whole name? If there is a list element "MyName" it would only match the name MyName but not MyName_v1. That makes sure that existing configurations work as before. With the possibility to add regular expressions to the list, one could add "^MyName_v\d+$" to match the other (versioned) name, too.

What do you (@arnauddorgans, @jpsim) think about that?

SimplyDanny avatar Apr 09 '22 09:04 SimplyDanny

Closing in favor of #4655.

SimplyDanny avatar Jan 11 '23 19:01 SimplyDanny