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

chore: GitHub action and swiftlint cleanup #231

Merged
merged 6 commits into from
Jan 22, 2020
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
17 changes: 11 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
name: SwiftLint
on: [push]

on:
[push, pull_request]

jobs:
docker-lint:
name: Docker Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: GitHub Action for SwiftLint
uses: norio-nomura/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v1
- name: GitHub Action for SwiftLint
uses: norio-nomura/[email protected]
- name: GitHub Action for SwiftLint with --strict
uses: norio-nomura/[email protected]
with:
args: --strict
7 changes: 5 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Main
on: [push]

on:
[push, pull_request]

jobs:
mac-test:
name: Mac Test
Expand All @@ -15,7 +18,7 @@ jobs:
run: |
set -o pipefail
xcodebuild $ACTION $WORKSPACE -scheme "SWXMLHash OSX" | xcpretty
xcodebuild $ACTION $WORKSPACE -scheme "SWXMLHash iOS" -sdk iphonesimulator -destination "OS=12.4,name=iPhone XS" | xcpretty
xcodebuild $ACTION $WORKSPACE -scheme "SWXMLHash iOS" -sdk iphonesimulator -destination "OS=13.2.2,name=iPhone 11" | xcpretty
xcodebuild $ACTION $WORKSPACE -scheme "SWXMLHash tvOS" -sdk appletvsimulator -destination "name=Apple TV" | xcpretty
xcodebuild build $WORKSPACE -scheme "SWXMLHash watchOS" -sdk watchsimulator | xcpretty
bash <(curl -s https://codecov.io/bash) -t ${{secrets.CODECOV_TOKEN}}
Expand Down
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0
5.1
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ibmcom/swift-ubuntu:latest
FROM swift:5.1

ENV APP_HOME ./app
RUN mkdir $APP_HOME
Expand Down
46 changes: 23 additions & 23 deletions Source/SWXMLHash.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public class SWXMLHash {
- returns: An XMLIndexer instance that is used to look up elements in the XML
*/
class public func parse(_ xml: String) -> XMLIndexer {
return SWXMLHash().parse(xml)
SWXMLHash().parse(xml)
}

/**
Expand All @@ -130,7 +130,7 @@ public class SWXMLHash {
- returns: An XMLIndexer instance that is used to look up elements in the XML
*/
class public func parse(_ data: Data) -> XMLIndexer {
return SWXMLHash().parse(data)
SWXMLHash().parse(data)
}

/**
Expand All @@ -140,7 +140,7 @@ public class SWXMLHash {
- returns: An XMLIndexer instance that is used to look up elements in the XML
*/
class public func lazy(_ xml: String) -> XMLIndexer {
return config { conf in conf.shouldProcessLazily = true }.parse(xml)
config { conf in conf.shouldProcessLazily = true }.parse(xml)
}

/**
Expand All @@ -150,7 +150,7 @@ public class SWXMLHash {
- returns: An XMLIndexer instance that is used to look up elements in the XML
*/
class public func lazy(_ data: Data) -> XMLIndexer {
return config { conf in conf.shouldProcessLazily = true }.parse(data)
config { conf in conf.shouldProcessLazily = true }.parse(data)
}
}

Expand All @@ -162,7 +162,7 @@ struct Stack<T> {
}

mutating func pop() -> T {
return items.removeLast()
items.removeLast()
}

mutating func drop() {
Expand All @@ -174,7 +174,7 @@ struct Stack<T> {
}

func top() -> T {
return items[items.count - 1]
items[items.count - 1]
}
}

Expand Down Expand Up @@ -255,7 +255,7 @@ extension XMLParserDelegate {

func parser(_ parser: XMLParser,
resolveExternalEntityName name: String,
systemID: String?) -> Data? { return nil }
systemID: String?) -> Data? { nil }

func parser(_ parser: XMLParser,
parseErrorOccurred parseError: Error) { }
Expand Down Expand Up @@ -591,7 +591,7 @@ public enum XMLIndexer {

/// All elements at the currently indexed level
public var all: [XMLIndexer] {
return allElements.map { XMLIndexer($0) }
allElements.map { XMLIndexer($0) }
}

private var allElements: [XMLElement] {
Expand All @@ -610,7 +610,7 @@ public enum XMLIndexer {

/// All child elements from the currently indexed level
public var children: [XMLIndexer] {
return childElements.map { XMLIndexer($0) }
childElements.map { XMLIndexer($0) }
}

private var childElements: [XMLElement] {
Expand All @@ -625,7 +625,7 @@ public enum XMLIndexer {

@available(*, unavailable, renamed: "filterChildren(_:)")
public func filter(_ included: (_ elem: XMLElement, _ index: Int) -> Bool) -> XMLIndexer {
return filterChildren(included)
filterChildren(included)
}

public func filterChildren(_ included: (_ elem: XMLElement, _ index: Int) -> Bool) -> XMLIndexer {
Expand All @@ -639,7 +639,7 @@ public enum XMLIndexer {
}

public func filterAll(_ included: (_ elem: XMLElement, _ index: Int) -> Bool) -> XMLIndexer {
return handleFilteredResults(list: allElements, included: included)
handleFilteredResults(list: allElements, included: included)
}

private func handleFilteredResults(list: [XMLElement],
Expand Down Expand Up @@ -883,11 +883,11 @@ public class XMLElement: XMLContent {

/// Whether the element is case insensitive or not
public var caseInsensitive: Bool {
return options.caseInsensitive
options.caseInsensitive
}

var userInfo: [CodingUserInfoKey: Any] {
return options.userInfo
options.userInfo
}

/// All attributes
Expand All @@ -903,7 +903,7 @@ public class XMLElement: XMLContent {

/// The inner text of the element, if it exists
public var text: String {
return children.reduce("", {
children.reduce("", {
if let element = $1 as? TextElement {
return $0 + element.text
}
Expand All @@ -914,7 +914,7 @@ public class XMLElement: XMLContent {

/// The inner text of the element and its children
public var recursiveText: String {
return children.reduce("", {
children.reduce("", {
if let textElement = $1 as? TextElement {
return $0 + textElement.text
} else if let xmlElement = $1 as? XMLElement {
Expand All @@ -926,7 +926,7 @@ public class XMLElement: XMLContent {
}

public var innerXML: String {
return children.reduce("", {
children.reduce("", {
$0.description + $1.description
})
}
Expand All @@ -939,7 +939,7 @@ public class XMLElement: XMLContent {
let options: SWXMLHashOptions

var xmlChildren: [XMLElement] {
return children.compactMap { $0 as? XMLElement }
children.compactMap { $0 as? XMLElement }
}

/**
Expand Down Expand Up @@ -988,14 +988,14 @@ public class XMLElement: XMLContent {
extension TextElement: CustomStringConvertible {
/// The text value for a `TextElement` instance.
public var description: String {
return text
text
}
}

extension XMLAttribute: CustomStringConvertible {
/// The textual representation of an `XMLAttribute` instance.
public var description: String {
return "\(name)=\"\(text)\""
"\(name)=\"\(text)\""
}
}

Expand Down Expand Up @@ -1062,7 +1062,7 @@ extension XMLIndexer {
*/
public func withAttribute<A: RawRepresentable, V: RawRepresentable>(_ attr: A, _ value: V) throws -> XMLIndexer
where A.RawValue == String, V.RawValue == String {
return try withAttribute(attr.rawValue, value.rawValue)
try withAttribute(attr.rawValue, value.rawValue)
}

/**
Expand All @@ -1077,7 +1077,7 @@ extension XMLIndexer {
- throws: Throws an XMLIndexingError.Key if no element was found
*/
public func byKey<K: RawRepresentable>(_ key: K) throws -> XMLIndexer where K.RawValue == String {
return try byKey(key.rawValue)
try byKey(key.rawValue)
}

/**
Expand All @@ -1091,7 +1091,7 @@ extension XMLIndexer {
- returns: instance of XMLIndexer to match the element (or elements) found by
*/
public subscript<K: RawRepresentable>(key: K) -> XMLIndexer where K.RawValue == String {
return self[key.rawValue]
self[key.rawValue]
}
}

Expand All @@ -1107,6 +1107,6 @@ extension XMLElement {
Convenience for self[String]
*/
public func attribute<N: RawRepresentable>(by name: N) -> XMLAttribute? where N.RawValue == String {
return attribute(by: name.rawValue)
attribute(by: name.rawValue)
}
}
18 changes: 9 additions & 9 deletions Source/XMLIndexer+XMLIndexerDeserializable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ public extension XMLIndexer {
- returns: The deserialized `T` value
*/
func value<T: XMLAttributeDeserializable, A: RawRepresentable>(ofAttribute attr: A) throws -> T where A.RawValue == String {
return try value(ofAttribute: attr.rawValue)
try value(ofAttribute: attr.rawValue)
}

/**
Expand All @@ -422,7 +422,7 @@ public extension XMLIndexer {
- returns: The deserialized `T?` value, or nil if the attribute does not exist
*/
func value<T: XMLAttributeDeserializable, A: RawRepresentable>(ofAttribute attr: A) -> T? where A.RawValue == String {
return value(ofAttribute: attr.rawValue)
value(ofAttribute: attr.rawValue)
}

/**
Expand All @@ -437,7 +437,7 @@ public extension XMLIndexer {
- returns: The deserialized `[T]` value
*/
func value<T: XMLAttributeDeserializable, A: RawRepresentable>(ofAttribute attr: A) throws -> [T] where A.RawValue == String {
return try value(ofAttribute: attr.rawValue)
try value(ofAttribute: attr.rawValue)
}

/**
Expand All @@ -452,7 +452,7 @@ public extension XMLIndexer {
- returns: The deserialized `[T]?` value
*/
func value<T: XMLAttributeDeserializable, A: RawRepresentable>(ofAttribute attr: A) throws -> [T]? where A.RawValue == String {
return try value(ofAttribute: attr.rawValue)
try value(ofAttribute: attr.rawValue)
}

/**
Expand All @@ -467,7 +467,7 @@ public extension XMLIndexer {
- returns: The deserialized `[T?]` value
*/
func value<T: XMLAttributeDeserializable, A: RawRepresentable>(ofAttribute attr: A) throws -> [T?] where A.RawValue == String {
return try value(ofAttribute: attr.rawValue)
try value(ofAttribute: attr.rawValue)
}
}

Expand Down Expand Up @@ -536,7 +536,7 @@ public extension XMLElement {
- returns: The deserialized `T` value
*/
func value<T: XMLAttributeDeserializable, A: RawRepresentable>(ofAttribute attr: A) throws -> T where A.RawValue == String {
return try value(ofAttribute: attr.rawValue)
try value(ofAttribute: attr.rawValue)
}

/**
Expand All @@ -550,7 +550,7 @@ public extension XMLElement {
- returns: The deserialized `T?` value, or nil if the attribute does not exist.
*/
func value<T: XMLAttributeDeserializable, A: RawRepresentable>(ofAttribute attr: A) -> T? where A.RawValue == String {
return value(ofAttribute: attr.rawValue)
value(ofAttribute: attr.rawValue)
}
}

Expand Down Expand Up @@ -619,7 +619,7 @@ extension String: XMLElementDeserializable, XMLAttributeDeserializable {
- returns: the deserialized String value
*/
public static func deserialize(_ element: XMLElement) -> String {
return element.text
element.text
}

/**
Expand All @@ -629,7 +629,7 @@ extension String: XMLElementDeserializable, XMLAttributeDeserializable {
- returns: the deserialized String value
*/
public static func deserialize(_ attribute: XMLAttribute) -> String {
return attribute.text
attribute.text
}
}

Expand Down
2 changes: 1 addition & 1 deletion Source/shim.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
func compactMap<ElementOfResult>(
_ transform: (Self.Element
) throws -> ElementOfResult?) rethrows -> [ElementOfResult] {
return try flatMap(transform)
try flatMap(transform)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/SWXMLHashTests/LazyTypesConversionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class LazyTypesConversionTests: XCTestCase {

extension LazyTypesConversionTests {
static var allTests: [(String, (LazyTypesConversionTests) -> () throws -> Void)] {
return [
[
("testShouldConvertValueToNonOptional", testShouldConvertValueToNonOptional),
("testShouldConvertAttributeToNonOptional", testShouldConvertAttributeToNonOptional),
("testShouldBeAbleToGetUserInfoDuringDeserialization", testShouldBeAbleToGetUserInfoDuringDeserialization)
Expand Down
2 changes: 1 addition & 1 deletion Tests/SWXMLHashTests/LazyWhiteSpaceParsingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class LazyWhiteSpaceParsingTests: XCTestCase {

extension LazyWhiteSpaceParsingTests {
static var allTests: [(String, (LazyWhiteSpaceParsingTests) -> () throws -> Void)] {
return [
[
("testShouldBeAbleToPullTextBetweenElementsWithoutWhitespace", testShouldBeAbleToPullTextBetweenElementsWithoutWhitespace),
("testShouldBeAbleToCorrectlyParseCDATASectionsWithWhitespace", testShouldBeAbleToCorrectlyParseCDATASectionsWithWhitespace)
]
Expand Down
2 changes: 1 addition & 1 deletion Tests/SWXMLHashTests/LazyXMLParsingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class LazyXMLParsingTests: XCTestCase {

extension LazyXMLParsingTests {
static var allTests: [(String, (LazyXMLParsingTests) -> () throws -> Void)] {
return [
[
("testShouldBeAbleToParseIndividualElements", testShouldBeAbleToParseIndividualElements),
("testShouldBeAbleToParseElementGroups", testShouldBeAbleToParseElementGroups),
("testShouldBeAbleToParseAttributes", testShouldBeAbleToParseAttributes),
Expand Down
2 changes: 1 addition & 1 deletion Tests/SWXMLHashTests/LinuxShims.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Foundation

extension NSString {
class func path(withComponents components: [String]) -> String {
return pathWithComponents(components)
NSURL.fileURL(withPathComponents: components)!.path
}
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/SWXMLHashTests/MixedTextWithXMLElementsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MixedTextWithXMLElementsTests: XCTestCase {

extension MixedTextWithXMLElementsTests {
static var allTests: [(String, (MixedTextWithXMLElementsTests) -> () throws -> Void)] {
return [
[
("testShouldBeAbleToGetAllContentsInsideOfAnElement", testShouldBeAbleToGetAllContentsInsideOfAnElement)
]
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/SWXMLHashTests/SWXMLHashConfigTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class SWXMLHashConfigTests: XCTestCase {

extension SWXMLHashConfigTests {
static var allTests: [(String, (SWXMLHashConfigTests) -> () throws -> Void)] {
return [
[
("testShouldAllowProcessingNamespacesOrNot", testShouldAllowProcessingNamespacesOrNot)
]
}
Expand Down
Loading