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

Update file_name rule to match fully-qualified names of nested types #5841

Merged

Conversation

fraioli
Copy link
Contributor

@fraioli fraioli commented Oct 28, 2024

This PR is aimed to address Issue #5840. It does the following:

  1. Allows the file_name rule to match nested types when using fully-qualified names, meaning naming the following file Nested.MyType.swift is no longer a violation:
// Nested.MyType.swift

enum Nested {
    struct MyType {
    }
}
  1. Introduces a new option fully_qualified to have the file_name rule enforce using fully-qualified names, meaning naming the above file MyType.swift instead of Nested.MyType.swift would become a violation where it wasn't before (naming the file Nested.swift would still not be a violation).

@@ -21,6 +22,8 @@ final class FileNameRuleTests: SwiftLintTestCase {
rule = try FileNameRule(configuration: ["suffix_pattern": suffixPattern])
} else if let nestedTypeSeparator {
rule = try FileNameRule(configuration: ["nested_type_separator": nestedTypeSeparator])
} else if let fullyQualified {
rule = try FileNameRule(configuration: ["fully_qualified": fullyQualified])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open to other names here such as require_fully_qualified, require_fully_qualified_names, etc.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the last one most.

@SwiftLintBot
Copy link

SwiftLintBot commented Oct 28, 2024

37 Messages
📖 Linting Aerial with this PR took 0.93s vs 0.93s on main (0% slower)
📖 Linting Alamofire with this PR took 1.27s vs 1.28s on main (0% faster)
📖 Linting Brave with this PR took 7.22s vs 7.23s on main (0% faster)
📖 Linting DuckDuckGo with this PR took 5.21s vs 5.19s on main (0% slower)
📖 Linting Firefox with this PR took 10.77s vs 10.78s on main (0% faster)
📖 Linting Kickstarter with this PR took 10.01s vs 10.04s on main (0% faster)
📖 Linting Moya with this PR took 0.53s vs 0.54s on main (1% faster)
📖 Linting NetNewsWire with this PR took 2.93s vs 2.92s on main (0% slower)
📖 Linting Nimble with this PR took 0.78s vs 0.78s on main (0% slower)
📖 Linting PocketCasts with this PR took 8.68s vs 8.71s on main (0% faster)
📖 Linting Quick with this PR took 0.44s vs 0.45s on main (2% faster)
📖 Linting Realm with this PR took 4.52s vs 4.54s on main (0% faster)
📖 Linting Sourcery with this PR took 2.32s vs 2.31s on main (0% slower)
📖 Linting Swift with this PR took 4.55s vs 4.54s on main (0% slower)
📖 Linting VLC with this PR took 1.25s vs 1.27s on main (1% faster)
📖 Linting Wire with this PR took 17.85s vs 17.83s on main (0% slower)
📖 Linting WordPress with this PR took 11.41s vs 11.49s on main (0% faster)
📖 This PR fixed a violation in Wire: /wire-ios-data-model/Source/Model/FeatureConfig/AppLock/AppLockController.Config.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)
📖 This PR fixed a violation in Wire: /wire-ios-data-model/Source/Model/FeatureConfig/AppLock/AppLockController.PasscodeKeychainItem.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)
📖 This PR fixed a violation in Wire: /wire-ios-data-model/Source/Model/FeatureConfig/AppLock/AppLockController.State.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)
📖 This PR fixed a violation in Wire: /wire-ios-data-model/Source/Model/FeatureConfig/AppLock/Feature.AppLock.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)
📖 This PR fixed a violation in Wire: /wire-ios-data-model/Source/Model/FeatureConfig/ConferenceCalling/Feature.ConferenceCalling.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)
📖 This PR fixed a violation in Wire: /wire-ios-data-model/Source/Model/FeatureConfig/ConversationGuestLinks/Feature.ConversationGuestLinks.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)
📖 This PR fixed a violation in Wire: /wire-ios-data-model/Source/Model/FeatureConfig/FileSharing/Feature.FileSharing.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)
📖 This PR fixed a violation in Wire: /wire-ios-data-model/Source/Model/FeatureConfig/MLS/Feature.MLS.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)
📖 This PR fixed a violation in Wire: /wire-ios-data-model/Source/Model/FeatureConfig/MLS/Feature.MLSMigration.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)
📖 This PR fixed a violation in Wire: /wire-ios-data-model/Source/Model/FeatureConfig/SelfDeletingMessages/Feature.SelfDeletingMessages.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)
📖 This PR fixed a violation in Wire: /wire-ios-data-model/Source/Notifications/NotificationDispatcher.OperationMode.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)
📖 This PR fixed a violation in Wire: /wire-ios-sync-engine/Source/UserSession/ZMUserSession/ZMUserSession.Configuration.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)
📖 This PR fixed a violation in Wire: /wire-ios/Tests/Mocks/AppLock/AppLockModule.MockApplicationStateProvider.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)
📖 This PR fixed a violation in Wire: /wire-ios/Tests/Mocks/AppLock/AppLockModule.MockAuthenticationTypeDetector.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)
📖 This PR fixed a violation in Wire: /wire-ios/Tests/Mocks/AppLock/AppLockModule.MockInteractor.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)
📖 This PR fixed a violation in Wire: /wire-ios/Tests/Mocks/AppLock/AppLockModule.MockPresenter.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)
📖 This PR fixed a violation in Wire: /wire-ios/Tests/Mocks/AppLock/AppLockModule.MockRouter.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)
📖 This PR fixed a violation in Wire: /wire-ios/Tests/Mocks/AppLock/AppLockModule.MockSession.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)
📖 This PR fixed a violation in Wire: /wire-ios/Tests/Mocks/AppLock/AppLockModule.MockView.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)
📖 This PR fixed a violation in Wire: /wire-ios/Wire-iOS/Sources/UserInterface/App Lock/AppLockModule.View.LockView.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)

Generated by 🚫 Danger

This PR is aimed to address Issue realm#5840. It does the following:

1. Allows the `file_name` rule to match nested types when using fully-qualified names, meaning naming the following file `Nested.MyType.swift` is no longer a violation:

```
// Nested.MyType.swift

enum Nested {
    struct MyType {
    }
}
```

2. Introduces a new option `fully_qualified` to have the `file_name` rule enforce using fully-qualified names, meaning naming the above file `MyType.swift` instead of `Nested.MyType.swift` would become a violation where it wasn't before (naming the file `Nested.swift` would still not be a violation).
@fraioli fraioli force-pushed the File-Name-Rule-Violations-With-Nested-Types branch from 9399bc9 to 904bad2 Compare October 29, 2024 22:03
Copy link
Collaborator

@SimplyDanny SimplyDanny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the extension of the rule. Thanks for the contribution!

Please find a few remarks as separate inline comment.

CHANGELOG.md Outdated Show resolved Hide resolved
Tests/SwiftLintFrameworkTests/FileNameRuleTests.swift Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@SimplyDanny SimplyDanny merged commit b9d33e4 into realm:main Nov 26, 2024
14 checks passed
@SimplyDanny
Copy link
Collaborator

Thank you again for your work, @fraioli!

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

Successfully merging this pull request may close these issues.

3 participants