-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Update file_name
rule to match fully-qualified names of nested types
#5841
Conversation
@@ -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]) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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).
9399bc9
to
904bad2
Compare
There was a problem hiding this 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.
Source/SwiftLintBuiltInRules/Rules/Idiomatic/FileNameRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Idiomatic/FileNameRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Idiomatic/FileNameRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Idiomatic/FileNameRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Idiomatic/FileNameRule.swift
Outdated
Show resolved
Hide resolved
Thank you again for your work, @fraioli! |
This PR is aimed to address Issue #5840. It does the following:
file_name
rule to match nested types when using fully-qualified names, meaning naming the following fileNested.MyType.swift
is no longer a violation:fully_qualified
to have thefile_name
rule enforce using fully-qualified names, meaning naming the above fileMyType.swift
instead ofNested.MyType.swift
would become a violation where it wasn't before (naming the fileNested.swift
would still not be a violation).