Skip to content

Commit

Permalink
Temporarily remove all SwiftSyntax rules and support (#3107)
Browse files Browse the repository at this point in the history
The new rules introduced in 0.39.0 that depend on SwiftSyntax have been temporarily removed as we work out release packaging issues.

* `prohibited_nan_comparison`
* `return_value_from_void_function`
* `tuple_pattern`
* `void_function_in_ternary`

See #3105 for details.
  • Loading branch information
jpsim authored Feb 11, 2020
1 parent 05a8a85 commit b744cf0
Show file tree
Hide file tree
Showing 22 changed files with 23 additions and 832 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,3 @@
[submodule "Carthage/Checkouts/Yams"]
path = Carthage/Checkouts/Yams
url = https://github.com/jpsim/Yams.git
[submodule "SwiftSyntax"]
path = SwiftSyntax
url = https://github.com/apple/swift-syntax.git
4 changes: 0 additions & 4 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,26 @@ opt_in_rules:
- private_action
- private_outlet
- prohibited_interface_builder
- prohibited_nan_comparison
- prohibited_super_call
- quick_discouraged_call
- quick_discouraged_focused_test
- quick_discouraged_pending_test
- reduce_into
- redundant_nil_coalescing
- redundant_type_annotation
- return_value_from_void_function
- single_test_class
- sorted_first_last
- sorted_imports
- static_operator
- strong_iboutlet
- toggle_bool
- tuple_pattern
- unavailable_function
- unneeded_parentheses_in_closure_argument
- unowned_variable_capture
- untyped_error_in_catch
- vertical_parameter_alignment_on_call
- vertical_whitespace_closing_braces
- vertical_whitespace_opening_braces
- void_function_in_ternary
- xct_specific_matcher
- yoda_condition

Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

#### Breaking

* None.
* The new rules introduced in 0.39.0 that depend on SwiftSyntax have been
temporarily removed as we work out release packaging issues.
* `prohibited_nan_comparison`
* `return_value_from_void_function`
* `tuple_pattern`
* `void_function_in_ternary`
[JP Simard](https://github.com/jpsim)
[#3105](https://github.com/realm/SwiftLint/issues/3105)

#### Experimental

Expand Down
9 changes: 0 additions & 9 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@
"version": "0.29.0"
}
},
{
"package": "SwiftSyntax",
"repositoryURL": "https://github.com/apple/swift-syntax.git",
"state": {
"branch": null,
"revision": "3e3eb191fcdbecc6031522660c4ed6ce25282c25",
"version": "0.50100.0"
}
},
{
"package": "SwiftyTextTable",
"repositoryURL": "https://github.com/scottrhoyt/SwiftyTextTable.git",
Expand Down
15 changes: 2 additions & 13 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,8 @@ private let addCryptoSwift = false
private let addCryptoSwift = true
#endif

#if compiler(>=5.1.0)
private let addSwiftSyntax = true
#else
private let addSwiftSyntax = false
#endif

let package = Package(
name: "SwiftLint",
platforms: [
.macOS(.v10_12)
],
products: [
.executable(name: "swiftlint", targets: ["swiftlint"]),
.library(name: "SwiftLintFramework", targets: ["SwiftLintFramework"])
Expand All @@ -27,8 +18,7 @@ let package = Package(
.package(url: "https://github.com/jpsim/SourceKitten.git", .upToNextMinor(from: "0.29.0")),
.package(url: "https://github.com/jpsim/Yams.git", from: "2.0.0"),
.package(url: "https://github.com/scottrhoyt/SwiftyTextTable.git", from: "0.9.0"),
] + (addCryptoSwift ? [.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", .upToNextMinor(from: "1.0.0"))] : []) +
(addSwiftSyntax ? [.package(url: "https://github.com/apple/swift-syntax.git", .exact("0.50100.0"))] : []),
] + (addCryptoSwift ? [.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", .upToNextMinor(from: "1.0.0"))] : []),
targets: [
.target(
name: "swiftlint",
Expand All @@ -43,8 +33,7 @@ let package = Package(
dependencies: [
"SourceKittenFramework",
"Yams",
] + (addCryptoSwift ? ["CryptoSwift"] : []) +
(addSwiftSyntax ? ["SwiftSyntax"] : [])
] + (addCryptoSwift ? ["CryptoSwift"] : [])
),
.testTarget(
name: "SwiftLintFrameworkTests",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ running it.
### Compiling from source:

You can also build from source by cloning this project and running
`script/bootstrap; make install` (Xcode 11.0 or later).
`git submodule update --init --recursive; make install` (Xcode 10.2 or later).

### Known Installation Issues On MacOS Before 10.14.4

Expand Down
36 changes: 0 additions & 36 deletions Source/SwiftLintFramework/Extensions/SwiftLintFile+Cache.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import Foundation
import SourceKittenFramework
#if canImport(SwiftSyntax)
import SwiftSyntax
#endif

private typealias FileCacheKey = Int
private var responseCache = Cache({ file -> [String: SourceKitRepresentable]? in
Expand Down Expand Up @@ -33,20 +30,6 @@ private var syntaxMapCache = Cache({ file in
private var syntaxKindsByLinesCache = Cache({ file in file.syntaxKindsByLine() })
private var syntaxTokensByLinesCache = Cache({ file in file.syntaxTokensByLine() })

#if canImport(SwiftSyntax)
private var syntaxCache = Cache({ file -> SourceFileSyntax? in
do {
if let path = file.path {
return try SyntaxParser.parse(URL(fileURLWithPath: path))
}

return try SyntaxParser.parse(source: file.contents)
} catch {
return nil
}
})
#endif

internal typealias AssertHandler = () -> Void

private var assertHandlers = [FileCacheKey: AssertHandler]()
Expand Down Expand Up @@ -175,19 +158,6 @@ extension SwiftLintFile {
return syntaxMap
}

#if canImport(SwiftSyntax)
internal var syntax: SourceFileSyntax {
guard let syntax = syntaxCache.get(self) else {
if let handler = assertHandler {
handler()
return SourceFileSyntax({ _ in })
}
queuedFatalError("Never call this for file that sourcekitd fails.")
}
return syntax
}
#endif

internal var syntaxTokensByLines: [[SwiftLintSyntaxToken]] {
guard let syntaxTokensByLines = syntaxTokensByLinesCache.get(self) else {
if let handler = assertHandler {
Expand Down Expand Up @@ -219,9 +189,6 @@ extension SwiftLintFile {
syntaxMapCache.invalidate(self)
syntaxTokensByLinesCache.invalidate(self)
syntaxKindsByLinesCache.invalidate(self)
#if canImport(SwiftSyntax)
syntaxCache.invalidate(self)
#endif
}

internal static func clearCaches() {
Expand All @@ -233,8 +200,5 @@ extension SwiftLintFile {
syntaxMapCache.clear()
syntaxTokensByLinesCache.clear()
syntaxKindsByLinesCache.clear()
#if canImport(SwiftSyntax)
syntaxCache.clear()
#endif
}
}
4 changes: 0 additions & 4 deletions Source/SwiftLintFramework/Models/MasterRuleList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ public let masterRuleList = RuleList(rules: [
OverriddenSuperCallRule.self,
OverrideInExtensionRule.self,
PatternMatchingKeywordsRule.self,
PhohibitedNaNComparisonRule.self,
PreferSelfTypeOverTypeOfSelfRule.self,
PrefixedTopLevelConstantRule.self,
PrivateActionRule.self,
Expand All @@ -148,7 +147,6 @@ public let masterRuleList = RuleList(rules: [
RequiredDeinitRule.self,
RequiredEnumCaseRule.self,
ReturnArrowWhitespaceRule.self,
ReturnValueFromVoidFunctionRule.self,
ShorthandOperatorRule.self,
SingleTestClassRule.self,
SortedFirstLastRule.self,
Expand All @@ -168,7 +166,6 @@ public let masterRuleList = RuleList(rules: [
TrailingNewlineRule.self,
TrailingSemicolonRule.self,
TrailingWhitespaceRule.self,
TuplePatternRule.self,
TypeBodyLengthRule.self,
TypeContentsOrderRule.self,
TypeNameRule.self,
Expand All @@ -192,7 +189,6 @@ public let masterRuleList = RuleList(rules: [
VerticalWhitespaceClosingBracesRule.self,
VerticalWhitespaceOpeningBracesRule.self,
VerticalWhitespaceRule.self,
VoidFunctionInTernaryConditionRule.self,
VoidReturnRule.self,
WeakDelegateRule.self,
XCTFailMessageRule.self,
Expand Down
44 changes: 0 additions & 44 deletions Source/SwiftLintFramework/Protocols/SyntaxRule.swift

This file was deleted.

This file was deleted.

Loading

0 comments on commit b744cf0

Please sign in to comment.