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 dependencies, mostly for SourceKitten 0.18 #1668

Merged
merged 1 commit into from
Jul 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

##### Breaking

* None.
* Xcode 8.3 or later and Swift 3.1 or later are required to build.
[Norio Nomura](https://github.com/norio-nomura)

##### Enhancements

Expand All @@ -29,6 +30,10 @@
should be separated from other statements by a single blank line.
[Uncommon](https://github.com/Uncommon)

* Improve performance when linting and correcting on Linux, matching behavior.
[JP Simard](https://github.com/jpsim)
[#1577](https://github.com/realm/SwiftLint/issues/1577)

##### Bug Fixes

* None.
Expand Down
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "jpsim/SourceKitten" ~> 0.17
github "jpsim/SourceKitten" ~> 0.18
github "scottrhoyt/SwiftyTextTable" ~> 0.5.0
12 changes: 6 additions & 6 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github "Carthage/Commandant" "16bcee12f48564c87bb13830f5320d21257e15b8"
github "antitypical/Result" "3.2.2"
github "drmohundro/SWXMLHash" "3.1.0"
github "jpsim/SourceKitten" "0.17.6"
github "jpsim/Yams" "0.3.2"
github "jspahrsummers/xcconfigs" "2055f18efbe18e77408f7f43947f7ad92b2d4ff0"
github "Carthage/Commandant" "9bce2e76cf7e0beb6aaa7db0738c6bea6633df30"
github "antitypical/Result" "3.2.3"
github "drmohundro/SWXMLHash" "4.1.0"
github "jpsim/SourceKitten" "0.18.0"
github "jpsim/Yams" "0.3.3"
github "jspahrsummers/xcconfigs" "4ac967d12f72c2ccc7f34d163268d09296923a7c"
github "scottrhoyt/SwiftyTextTable" "0.5.0"
2 changes: 1 addition & 1 deletion Carthage/Checkouts/SourceKitten
Submodule SourceKitten updated 41 files
+15 −1 .travis.yml
+24 −0 CHANGELOG.md
+1 −1 Cartfile
+4 −4 Cartfile.resolved
+1 −1 Carthage/Checkouts/Result
+1 −1 Carthage/Checkouts/SWXMLHash
+1 −1 Carthage/Checkouts/Yams
+1 −1 Carthage/Checkouts/xcconfigs
+2 −2 Makefile
+2 −2 Package.swift
+47 −0 Package@swift-4.swift
+3 −3 README.md
+7 −3 Source/SourceKittenFramework/Clang+SourceKitten.swift
+6 −4 Source/SourceKittenFramework/File.swift
+1 −1 Source/SourceKittenFramework/Info.plist
+39 −58 Source/SourceKittenFramework/LinuxCompatibility.swift
+1 −1 Source/SourceKittenFramework/SourceDeclaration.swift
+9 −10 Source/SourceKittenFramework/String+SourceKitten.swift
+0 −12 Source/SourceKittenFramework/SyntaxMap.swift
+1 −1 Source/SourceKittenFramework/Version.swift
+1 −1 Source/sourcekitten/Info.plist
+1 −1 SourceKittenFramework.podspec
+0 −5 Tests/SourceKittenFrameworkTests/CodeCompletionTests.swift
+646 −0 Tests/SourceKittenFrameworkTests/Fixtures/Bicycle@swift-3.2.json
+729 −0 Tests/SourceKittenFrameworkTests/Fixtures/BicycleIndex@swift-3.2.json
+5,305 −0 Tests/SourceKittenFrameworkTests/Fixtures/Commandant@swift-3.2.json
+5,305 −0 Tests/SourceKittenFrameworkTests/Fixtures/CommandantSPM@swift-4.0.json
+207 −0 Tests/SourceKittenFrameworkTests/Fixtures/DocInfo@swift-3.2.json
+283 −0 Tests/SourceKittenFrameworkTests/Fixtures/Extension@swift-3.2.json
+652 −0 Tests/SourceKittenFrameworkTests/Fixtures/LinuxBicycle@swift-4.0.json
+658 −0 Tests/SourceKittenFrameworkTests/Fixtures/LinuxBicycleIndex@swift-4.0.json
+5,347 −0 Tests/SourceKittenFrameworkTests/Fixtures/LinuxCommandantSPM@swift-4.0.json
+184 −175 Tests/SourceKittenFrameworkTests/Fixtures/LinuxSimpleCodeCompletion@swift-3.2.json
+214 −0 Tests/SourceKittenFrameworkTests/Fixtures/ModuleInfo@swift-3.2.json
+5,958 −0 Tests/SourceKittenFrameworkTests/Fixtures/Realm@swift-3.2.json
+352 −0 Tests/SourceKittenFrameworkTests/Fixtures/SimpleCodeCompletion@swift-3.2.json
+54 −0 Tests/SourceKittenFrameworkTests/Fixtures/Subscript@swift-3.2.json
+1 −6 Tests/SourceKittenFrameworkTests/ModuleTests.swift
+6 −14 Tests/SourceKittenFrameworkTests/StructureTests.swift
+32 −7 Tests/SourceKittenFrameworkTests/SwiftDocsTests.swift
+7 −3 sourcekitten.xcodeproj/project.pbxproj
2 changes: 1 addition & 1 deletion Carthage/Checkouts/xcconfigs
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let package = Package(
]),
],
dependencies: [
.Package(url: "https://github.com/jpsim/SourceKitten.git", majorVersion: 0, minor: 17),
.Package(url: "https://github.com/jpsim/SourceKitten.git", majorVersion: 0, minor: 18),
.Package(url: "https://github.com/jpsim/Yams.git", majorVersion: 0, minor: 3),
.Package(url: "https://github.com/scottrhoyt/SwiftyTextTable.git", majorVersion: 0, minor: 5),
]
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ running it.
### Compiling from source:

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

## Usage

Expand Down Expand Up @@ -90,7 +90,8 @@ Alternatively, if you've installed SwiftLint via CocoaPods the script should loo
To run `swiftlint autocorrect` on save in Xcode, install the
[SwiftLintXcode](https://github.com/ypresto/SwiftLintXcode) plugin from Alcatraz.

⚠ ️This plugin will not work with Xcode 8 without disabling SIP. This is not recommended.
⚠ ️This plugin will not work with Xcode 8 or later without disabling SIP.
This is not recommended.

### AppCode

Expand Down
22 changes: 0 additions & 22 deletions Source/SwiftLintFramework/Extensions/Collection+PrefixWhile.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@
import Foundation

#if os(Linux)
#if !swift(>=3.1)
public typealias NSRegularExpression = RegularExpression
#endif
public typealias NSTextCheckingResult = TextCheckingResult
#else
#if !swift(>=4.0)
extension NSTextCheckingResult {
internal func range(at idx: Int) -> NSRange {
return rangeAt(idx)
}
}
#endif
#endif

private var regexCache = [RegexCacheKey: NSRegularExpression]()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public struct ClosureEndIndentationRule: ASTRule, OptInRule, ConfigurationProvid
let contents = file.contents.bridge()
guard let range = contents.byteRangeToNSRange(start: nameOffset, length: nameLength),
let match = newLineRegex.matches(in: file.contents, options: [],
range: range).last?.rangeAt(1),
range: range).last?.range(at: 1),
let methodByteRange = contents.NSRangeToByteRange(start: match.location,
length: match.length) else {
return nameOffset
Expand Down
6 changes: 3 additions & 3 deletions Source/SwiftLintFramework/Rules/CommaRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ public struct CommaRule: CorrectableRule, ConfigurationProviderRule {
if match.numberOfRanges != 5 { return nil } // Number of Groups in regexp

var indexStartRange = 1
if match.rangeAt(indexStartRange).location == NSNotFound {
if match.range(at: indexStartRange).location == NSNotFound {
indexStartRange += 2
}

// check first captured range
let firstRange = match.rangeAt(indexStartRange)
let firstRange = match.range(at: indexStartRange)
guard let matchByteFirstRange = nsstring
.NSRangeToByteRange(start: firstRange.location, length: firstRange.length)
else { return nil }
Expand All @@ -128,7 +128,7 @@ public struct CommaRule: CorrectableRule, ConfigurationProviderRule {
}

// check second captured range
let secondRange = match.rangeAt(indexStartRange + 1)
let secondRange = match.range(at: indexStartRange + 1)
guard let matchByteSecondRange = nsstring
.NSRangeToByteRange(start: secondRange.location, length: secondRange.length)
else { return nil }
Expand Down
4 changes: 2 additions & 2 deletions Source/SwiftLintFramework/Rules/ForceUnwrappingRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public struct ForceUnwrappingRule: OptInRule, ConfigurationProviderRule {
file: File) -> NSRange? {
if match.numberOfRanges < 3 { return nil }

let firstRange = match.rangeAt(1)
let secondRange = match.rangeAt(2)
let firstRange = match.range(at: 1)
let secondRange = match.range(at: 2)

guard let matchByteFirstRange = nsstring
.NSRangeToByteRange(start: firstRange.location, length: firstRange.length),
Expand Down
8 changes: 4 additions & 4 deletions Source/SwiftLintFramework/Rules/GenericTypeNameRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public struct GenericTypeNameRule: ASTRule, ConfigurationProviderRule {
guard tokens.first == .keyword,
Set(tokens.dropFirst()) == [.identifier],
let match = genericTypeRegex.firstMatch(in: file.contents, options: [],
range: range)?.rangeAt(1) else {
range: range)?.range(at: 1) else {
return []
}

Expand All @@ -101,7 +101,7 @@ public struct GenericTypeNameRule: ASTRule, ConfigurationProviderRule {
case let start = nameOffset + nameLength,
case let length = bodyOffset - start,
let range = contents.byteRangeToNSRange(start: start, length: length),
let match = genericTypeRegex.firstMatch(in: file.contents, options: [], range: range)?.rangeAt(1) else {
let match = genericTypeRegex.firstMatch(in: file.contents, options: [], range: range)?.range(at: 1) else {
return []
}

Expand All @@ -116,7 +116,7 @@ public struct GenericTypeNameRule: ASTRule, ConfigurationProviderRule {
let length = dictionary.nameLength,
case let contents = file.contents.bridge(),
let range = contents.byteRangeToNSRange(start: offset, length: length),
let match = genericTypeRegex.firstMatch(in: file.contents, options: [], range: range)?.rangeAt(1),
let match = genericTypeRegex.firstMatch(in: file.contents, options: [], range: range)?.range(at: 1),
match.location < minParameterOffset(parameters: dictionary.enclosedVarParameters, file: file) else {
return []
}
Expand Down Expand Up @@ -219,7 +219,7 @@ extension String {
return (self, range)
}

let trimmedRange = match.rangeAt(1)
let trimmedRange = match.range(at: 1)
return (bridged.substring(with: trimmedRange), trimmedRange)
}
}
2 changes: 1 addition & 1 deletion Source/SwiftLintFramework/Rules/ImplicitReturnRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public struct ImplicitReturnRule: ConfigurationProviderRule, CorrectableRule, Op
return nil
}

return result.rangeAt(1)
return result.range(at: 1)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public struct ReturnArrowWhitespaceRule: CorrectableRule, ConfigurationProviderR
guard result.numberOfRanges > (replacementsByIndex.keys.max() ?? 0) else { break }

for (index, string) in replacementsByIndex {
if let range = contents.nsrangeToIndexRange(result.rangeAt(index)) {
if let range = contents.nsrangeToIndexRange(result.range(at: index)) {
contents.replaceSubrange(range, with: string)
break
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public struct ShorthandOperatorRule: ConfigurationProviderRule {

// byteRanges will have the ranges of captured groups
let byteRanges: [NSRange?] = (1..<match.numberOfRanges).map { rangeIdx in
let range = match.rangeAt(rangeIdx)
let range = match.range(at: rangeIdx)
guard range.location != NSNotFound else {
return nil
}
Expand Down
12 changes: 6 additions & 6 deletions Source/SwiftLintFramework/Rules/StatementPositionRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ private extension StatementPositionRule {
if match.numberOfRanges != 5 {
return match
}
if match.rangeAt(2).length == 0 {
if match.range(at: 2).length == 0 {
return match
}
let range1 = match.rangeAt(1)
let range2 = match.rangeAt(3)
let range1 = match.range(at: 1)
let range2 = match.range(at: 3)
let whitespace1 = contents.substring(from: range1.location, length: range1.length)
let whitespace2 = contents.substring(from: range2.location, length: range2.length)
if whitespace1 == whitespace2 {
Expand Down Expand Up @@ -209,9 +209,9 @@ private extension StatementPositionRule {
var corrections = [Correction]()

for match in validMatches.reversed() {
let range1 = match.rangeAt(1)
let range2 = match.rangeAt(3)
let newlineRange = match.rangeAt(2)
let range1 = match.range(at: 1)
let range2 = match.range(at: 3)
let newlineRange = match.range(at: 2)
var whitespace = contents.bridge().substring(with: range1)
let newLines: String
if newlineRange.location != NSNotFound {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public struct UnusedOptionalBindingRule: ASTRule, ConfigurationProviderRule {
return matches
.filter { $0.1.filter(kinds.contains).isEmpty }
.filter { kind != .guard || !containsOptionalTry(at: $0.0.range, of: file) }
.map { $0.0.rangeAt(1) }
.map { $0.0.range(at: 1) }
}

private func containsOptionalTry(at range: NSRange, of file: File) -> Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public struct VerticalParameterAlignmentRule: ASTRule, ConfigurationProviderRule
let nameLength = dictionary.nameLength,
let nameRange = contents.byteRangeToNSRange(start: nameOffset, length: nameLength),
let paramStart = regex(pattern).firstMatch(in: file.contents,
options: [], range: nameRange)?.rangeAt(1).location,
options: [], range: nameRange)?.range(at: 1).location,
let (startLine, startCharacter) = contents.lineAndCharacter(forCharacterOffset: paramStart),
let (endLine, _) = contents.lineAndCharacter(forByteOffset: nameOffset + nameLength - 1),
endLine > startLine else {
Expand All @@ -77,7 +77,7 @@ public struct VerticalParameterAlignmentRule: ASTRule, ConfigurationProviderRule
let violationLocations = linesRange.flatMap { lineIndex -> Int? in
let line = file.lines[lineIndex - 1]
guard let paramRange = paramRegex.firstMatch(in: file.contents, options: [],
range: line.range)?.rangeAt(1),
range: line.range)?.range(at: 1),
let (_, paramCharacter) = contents.lineAndCharacter(forCharacterOffset: paramRange.location),
paramCharacter != startCharacter else {
return nil
Expand Down
2 changes: 1 addition & 1 deletion Source/SwiftLintFramework/Rules/VoidReturnRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public struct VoidReturnRule: ConfigurationProviderRule, CorrectableRule {
let excludingPattern = "(\(pattern))\\s*(throws\\s+)?->"

return file.match(pattern: pattern, excludingSyntaxKinds: kinds, excludingPattern: excludingPattern,
exclusionMapping: { $0.rangeAt(1) }).flatMap {
exclusionMapping: { $0.range(at: 1) }).flatMap {
let parensRegex = regex(parensPattern)
return parensRegex.firstMatch(in: file.contents, options: [], range: $0)?.range
}
Expand Down
4 changes: 0 additions & 4 deletions SwiftLint.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@
D47A510E1DB29EEB00A4CC21 /* SwitchCaseOnNewlineRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = D47A510D1DB29EEB00A4CC21 /* SwitchCaseOnNewlineRule.swift */; };
D47A51101DB2DD4800A4CC21 /* AttributesRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = D47A510F1DB2DD4800A4CC21 /* AttributesRule.swift */; };
D47F31151EC918B600E3E1CA /* ProtocolPropertyAccessorsOrderRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = D47F31141EC918B600E3E1CA /* ProtocolPropertyAccessorsOrderRule.swift */; };
D48668C21EF164340068CA84 /* Collection+PrefixWhile.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4B69E841EF12F7A00FBBD97 /* Collection+PrefixWhile.swift */; };
D48AE2CC1DFB58C5001C6A4A /* AttributesRulesExamples.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48AE2CB1DFB58C5001C6A4A /* AttributesRulesExamples.swift */; };
D4998DE71DF191380006E05D /* AttributesRuleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4998DE61DF191380006E05D /* AttributesRuleTests.swift */; };
D4998DE91DF194F20006E05D /* FileHeaderRuleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4998DE81DF194F20006E05D /* FileHeaderRuleTests.swift */; };
Expand Down Expand Up @@ -465,7 +464,6 @@
D4B022A31E105636007E5297 /* GenericTypeNameRule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GenericTypeNameRule.swift; sourceTree = "<group>"; };
D4B022AF1E109816007E5297 /* CharacterSet+LinuxHack.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CharacterSet+LinuxHack.swift"; sourceTree = "<group>"; };
D4B022B11E10B613007E5297 /* RedundantVoidReturnRule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RedundantVoidReturnRule.swift; sourceTree = "<group>"; };
D4B69E841EF12F7A00FBBD97 /* Collection+PrefixWhile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Collection+PrefixWhile.swift"; sourceTree = "<group>"; };
D4C0E46E1E3D973600C560F2 /* ForWhereRule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForWhereRule.swift; sourceTree = "<group>"; };
D4C27BFD1E12D53F00DF713E /* Version.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Version.swift; sourceTree = "<group>"; };
D4C27BFF1E12DFF500DF713E /* LinterCacheTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LinterCacheTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1042,7 +1040,6 @@
D47079AA1DFDCF7A00027086 /* SwiftExpressionKind.swift */,
E87E4A081BFB9CAE00FCFE46 /* SyntaxKind+SwiftLint.swift */,
6CC4259A1C77046200AEA885 /* SyntaxMap+SwiftLint.swift */,
D4B69E841EF12F7A00FBBD97 /* Collection+PrefixWhile.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -1309,7 +1306,6 @@
E87E4A091BFB9CAE00FCFE46 /* SyntaxKind+SwiftLint.swift in Sources */,
3B0B14541C505D6300BE82F7 /* SeverityConfiguration.swift in Sources */,
E88198551BEA949A00333A11 /* ControlStatementRule.swift in Sources */,
D48668C21EF164340068CA84 /* Collection+PrefixWhile.swift in Sources */,
E57B23C11B1D8BF000DEA512 /* ReturnArrowWhitespaceRule.swift in Sources */,
E816194E1BFBFEAB00946723 /* ForceTryRule.swift in Sources */,
E88198541BEA945100333A11 /* CommaRule.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion SwiftLintFramework.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ Pod::Spec.new do |s|
s.platform = :osx, '10.10'
s.source_files = 'Source/SwiftLintFramework/**/*.swift'
s.pod_target_xcconfig = { 'APPLICATION_EXTENSION_API_ONLY' => 'YES' }
s.dependency 'SourceKittenFramework', '~> 0.17'
s.dependency 'SourceKittenFramework', '~> 0.18'
s.dependency 'Yams', '~> 0.3'
end