Skip to content

Commit

Permalink
Merge branch 'master' into swift3.0
Browse files Browse the repository at this point in the history
* master:
  add empty changelog section
  update Releasing.md with `brew bump-formula-pr`
  0.13.1: Heavy Cycle
  remove unused function dictFromKeyValuePairs
  add tests for reporterFromString(_:)
  small refactoring of SwitchCaseOnNewlineRule.swift

# Conflicts:
#	Source/SwiftLintFramework/Extensions/File+Cache.swift
#	Source/SwiftLintFramework/Rules/SwitchCaseOnNewlineRule.swift
  • Loading branch information
norio-nomura committed Nov 30, 2016
2 parents b7862b9 + 5473c69 commit 363bcf5
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 23 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@

##### Enhancements

* None.

##### Bug Fixes

* None.

## 0.13.1: Heavy Cycle

##### Breaking

* None.

##### Enhancements

* Add `ImplicitGetterRule` to warn against using `get` on computed read-only
properties.
[Marcelo Fabri](https://github.com/marcelofabri)
Expand Down
5 changes: 1 addition & 4 deletions Releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,4 @@ For SwiftLint contributors, follow these steps to cut a release:
* Upload the pkg installer and Carthage zip you just built to the GitHub
release binaries.
* Click "Publish release"
9. File a PR towards Homebrew bumping the `tag`, `revision` & Xcode version
dependency if necessary.
See [homebrew#45650](https://github.com/Homebrew/homebrew/pull/45650) as an
example.
9. Update Homebrew: `brew bump-formula-pr --tag=$(git describe --tags) --revision=$(git rev-parse HEAD) swiftlint`.
8 changes: 0 additions & 8 deletions Source/SwiftLintFramework/Extensions/File+Cache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,6 @@ extension File {
}
}

private func dictFromKeyValuePairs<Key: Hashable, Value>(_ pairs: [(Key, Value)]) -> [Key: Value] {
var dict = [Key: Value]()
for pair in pairs {
dict[pair.0] = pair.1
}
return dict
}

private func substructureForDict(_ dict: [String: SourceKitRepresentable]) ->
[[String: SourceKitRepresentable]]? {
return (dict["key.substructure"] as? [SourceKitRepresentable])?.flatMap {
Expand Down
12 changes: 3 additions & 9 deletions Source/SwiftLintFramework/Rules/SwitchCaseOnNewlineRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ public struct SwitchCaseOnNewlineRule: ConfigurationProviderRule, Rule, OptInRul
}

private func contentForRange(start: Int, length: Int, file: File) -> String {
return file.contents.substringWithByteRange(start: start,
length: length) ?? ""
return file.contents.substringWithByteRange(start: start, length: length) ?? ""
}

private func trailingComments(tokens: [SyntaxToken]) -> [SyntaxToken] {
Expand All @@ -112,19 +111,14 @@ public struct SwitchCaseOnNewlineRule: ConfigurationProviderRule, Rule, OptInRul
if !shouldRemove {
lastWasComment = false
}

return shouldRemove
}.reversed()
}

private func isViolation(lineTokens: [SyntaxToken], file: File, line: Line) -> Bool {
let trailingCommentsTokens = trailingComments(tokens: lineTokens)

guard let firstToken = lineTokens.first else {
return false
}

if isEnumCase(file: file, token: firstToken) {
guard let firstToken = lineTokens.first, !isEnumCase(file, token: firstToken) else {
return false
}

Expand All @@ -141,7 +135,7 @@ public struct SwitchCaseOnNewlineRule: ConfigurationProviderRule, Rule, OptInRul
return !cleaned.hasSuffix(":")
}

private func isEnumCase(file: File, token: SyntaxToken) -> Bool {
private func isEnumCase(_ file: File, token: SyntaxToken) -> Bool {
let kinds = file.structure.kindsFor(token.offset).flatMap {
SwiftDeclarationKind(rawValue: $0.kind)
}
Expand Down
2 changes: 1 addition & 1 deletion Source/SwiftLintFramework/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.13.0</string>
<string>0.13.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion Source/swiftlint/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.13.0</string>
<string>0.13.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
14 changes: 14 additions & 0 deletions Tests/SwiftLintFrameworkTests/ReporterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ import XCTest

class ReporterTests: XCTestCase {

func testReporterFromString() {
let reporters: [Reporter.Type] = [
XcodeReporter.self,
JSONReporter.self,
CSVReporter.self,
CheckstyleReporter.self,
JUnitReporter.self,
HTMLReporter.self
]
for reporter in reporters {
XCTAssertEqual(reporter.identifier, reporterFromString(reporter.identifier).identifier)
}
}

func generateViolations() -> [StyleViolation] {
let location = Location(file: "filename", line: 1, character: 2)
return [
Expand Down

0 comments on commit 363bcf5

Please sign in to comment.