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

Add optional_enum_case_matching rule #3002

Merged
merged 1 commit into from
Jan 3, 2020

Conversation

marcelofabri
Copy link
Collaborator

Made it opt-in because this introduces breaking changes (if violations are fixed) for projects that support compiling with earlier Swift versions - e.g. SwiftLint itself.

@marcelofabri marcelofabri force-pushed the marcelo/optional_enum_case_matching branch from 0369948 to 619439a Compare January 2, 2020 06:37
@SwiftLintBot
Copy link

SwiftLintBot commented Jan 2, 2020

19 Warnings
⚠️ This PR introduced a violation in Sourcery: /usr/local/var/buildkite-agent/builds/coastalelectricgaserver-com-1/swiftlint/swiftlint/osscheck/Sourcery/SourceryFramework/Sources/Parsing/FileParser.swift:635:18: warning: Optional Enum Case Match Violation: Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. (optional_enum_case_matching)
⚠️ This PR introduced a violation in Sourcery: /usr/local/var/buildkite-agent/builds/coastalelectricgaserver-com-1/swiftlint/swiftlint/osscheck/Sourcery/SourceryFramework/Sources/Parsing/FileParser.swift:638:24: warning: Optional Enum Case Match Violation: Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. (optional_enum_case_matching)
⚠️ This PR introduced a violation in Sourcery: /usr/local/var/buildkite-agent/builds/coastalelectricgaserver-com-1/swiftlint/swiftlint/osscheck/Sourcery/Pods/Stencil/Sources/ForTag.swift:106:19: warning: Optional Enum Case Match Violation: Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. (optional_enum_case_matching)
⚠️ This PR introduced a violation in Sourcery: /usr/local/var/buildkite-agent/builds/coastalelectricgaserver-com-1/swiftlint/swiftlint/osscheck/Sourcery/Pods/Stencil/Sources/ForTag.swift:106:28: warning: Optional Enum Case Match Violation: Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. (optional_enum_case_matching)
⚠️ This PR introduced a violation in Sourcery: /usr/local/var/buildkite-agent/builds/coastalelectricgaserver-com-1/swiftlint/swiftlint/osscheck/Sourcery/Pods/Stencil/Sources/ForTag.swift:108:18: warning: Optional Enum Case Match Violation: Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. (optional_enum_case_matching)
⚠️ This PR introduced a violation in Sourcery: /usr/local/var/buildkite-agent/builds/coastalelectricgaserver-com-1/swiftlint/swiftlint/osscheck/Sourcery/Pods/xcproj/Sources/xcproj/PBXProjObjects+Helpers.swift:178:23: warning: Optional Enum Case Match Violation: Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. (optional_enum_case_matching)
⚠️ This PR introduced a violation in Sourcery: /usr/local/var/buildkite-agent/builds/coastalelectricgaserver-com-1/swiftlint/swiftlint/osscheck/Sourcery/Pods/xcproj/Sources/xcproj/PBXProjObjects+Helpers.swift:180:25: warning: Optional Enum Case Match Violation: Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. (optional_enum_case_matching)
⚠️ This PR introduced a violation in Sourcery: /usr/local/var/buildkite-agent/builds/coastalelectricgaserver-com-1/swiftlint/swiftlint/osscheck/Sourcery/Pods/xcproj/Sources/xcproj/PBXProjObjects+Helpers.swift:182:20: warning: Optional Enum Case Match Violation: Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. (optional_enum_case_matching)
⚠️ This PR introduced a violation in Sourcery: /usr/local/var/buildkite-agent/builds/coastalelectricgaserver-com-1/swiftlint/swiftlint/osscheck/Sourcery/Pods/xcproj/Sources/xcproj/PBXProjObjects+Helpers.swift:353:24: warning: Optional Enum Case Match Violation: Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. (optional_enum_case_matching)
⚠️ This PR introduced a violation in Swift: /usr/local/var/buildkite-agent/builds/coastalelectricgaserver-com-1/swiftlint/swiftlint/osscheck/Swift/stdlib/public/core/DebuggerSupport.swift:78:19: warning: Optional Enum Case Match Violation: Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. (optional_enum_case_matching)
⚠️ This PR introduced a violation in Swift: /usr/local/var/buildkite-agent/builds/coastalelectricgaserver-com-1/swiftlint/swiftlint/osscheck/Swift/stdlib/public/core/DebuggerSupport.swift:80:19: warning: Optional Enum Case Match Violation: Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. (optional_enum_case_matching)
⚠️ This PR introduced a violation in Swift: /usr/local/var/buildkite-agent/builds/coastalelectricgaserver-com-1/swiftlint/swiftlint/osscheck/Swift/stdlib/public/core/DebuggerSupport.swift:82:21: warning: Optional Enum Case Match Violation: Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. (optional_enum_case_matching)
⚠️ This PR introduced a violation in Swift: /usr/local/var/buildkite-agent/builds/coastalelectricgaserver-com-1/swiftlint/swiftlint/osscheck/Swift/stdlib/public/core/DebuggerSupport.swift:82:35: warning: Optional Enum Case Match Violation: Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. (optional_enum_case_matching)
⚠️ This PR introduced a violation in Swift: /usr/local/var/buildkite-agent/builds/coastalelectricgaserver-com-1/swiftlint/swiftlint/osscheck/Swift/stdlib/public/core/DebuggerSupport.swift:82:42: warning: Optional Enum Case Match Violation: Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. (optional_enum_case_matching)
⚠️ This PR introduced a violation in Swift: /usr/local/var/buildkite-agent/builds/coastalelectricgaserver-com-1/swiftlint/swiftlint/osscheck/Swift/stdlib/public/core/DebuggerSupport.swift:82:51: warning: Optional Enum Case Match Violation: Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. (optional_enum_case_matching)
⚠️ This PR introduced a violation in Swift: /usr/local/var/buildkite-agent/builds/coastalelectricgaserver-com-1/swiftlint/swiftlint/osscheck/Swift/stdlib/public/core/DebuggerSupport.swift:84:19: warning: Optional Enum Case Match Violation: Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. (optional_enum_case_matching)
⚠️ This PR introduced a violation in Swift: /usr/local/var/buildkite-agent/builds/coastalelectricgaserver-com-1/swiftlint/swiftlint/osscheck/Swift/stdlib/public/core/DebuggerSupport.swift:84:29: warning: Optional Enum Case Match Violation: Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. (optional_enum_case_matching)
⚠️ This PR introduced a violation in Swift: /usr/local/var/buildkite-agent/builds/coastalelectricgaserver-com-1/swiftlint/swiftlint/osscheck/Swift/stdlib/public/core/DebuggerSupport.swift:95:18: warning: Optional Enum Case Match Violation: Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. (optional_enum_case_matching)
⚠️ This PR introduced a violation in WordPress: /usr/local/var/buildkite-agent/builds/coastalelectricgaserver-com-1/swiftlint/swiftlint/osscheck/WordPress/WordPress/Classes/Models/SharePost+UIActivityItemSource.swift:11:36: warning: Optional Enum Case Match Violation: Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. (optional_enum_case_matching)
12 Messages
📖 Linting Aerial with this PR took 1.23s vs 1.18s on master (4% slower)
📖 Linting Alamofire with this PR took 2.21s vs 2.19s on master (0% slower)
📖 Linting Firefox with this PR took 8.99s vs 8.88s on master (1% slower)
📖 Linting Kickstarter with this PR took 14.55s vs 14.42s on master (0% slower)
📖 Linting Moya with this PR took 1.17s vs 1.16s on master (0% slower)
📖 Linting Nimble with this PR took 1.38s vs 1.38s on master (0% slower)
📖 Linting Quick with this PR took 0.54s vs 0.55s on master (1% faster)
📖 Linting Realm with this PR took 2.4s vs 2.34s on master (2% slower)
📖 Linting SourceKitten with this PR took 0.99s vs 0.99s on master (0% slower)
📖 Linting Sourcery with this PR took 6.71s vs 6.7s on master (0% slower)
📖 Linting Swift with this PR took 12.19s vs 12.21s on master (0% faster)
📖 Linting WordPress with this PR took 14.63s vs 14.55s on master (0% slower)

Generated by 🚫 Danger

@marcelofabri marcelofabri force-pushed the marcelo/optional_enum_case_matching branch from 619439a to 8f128aa Compare January 3, 2020 07:54
@marcelofabri marcelofabri force-pushed the marcelo/optional_enum_case_matching branch from 8f128aa to 1309b8a Compare January 3, 2020 08:00
@marcelofabri marcelofabri merged commit 2c3411d into master Jan 3, 2020
@marcelofabri marcelofabri deleted the marcelo/optional_enum_case_matching branch January 3, 2020 08:50
public func violationRanges(in file: SwiftLintFile,
kind: StatementKind,
dictionary: SourceKittenDictionary) -> [NSRange] {
guard SwiftVersion.current >= type(of: self).description.minSwiftVersion, kind == .case else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: could've put the cheaper check before the more expensive check

@jpsim
Copy link
Collaborator

jpsim commented Jan 3, 2020

💯

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