Skip to content

Commit

Permalink
Fix swiftlint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
drmohundro committed Jun 2, 2017
1 parent 37ccbe3 commit 209a7b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
20 changes: 10 additions & 10 deletions Source/SWXMLHash.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class SWXMLHashOptions {
/// determines whether to parse XML namespaces or not (forwards to
/// `XMLParser.shouldProcessNamespaces`)
public var shouldProcessNamespaces = false

/// Matching element names, element values, attribute names, attribute values
/// will be case insensitive. This will not affect parsing (data does not change)
public var caseInsensitive = false
Expand Down Expand Up @@ -764,7 +764,7 @@ public class XMLElement: XMLContent {
/// The name of the element
public let name: String

public var caseInsensitive:Bool
public var caseInsensitive: Bool

/// All attributes
public var allAttributes = [String: XMLAttribute]()
Expand Down Expand Up @@ -813,7 +813,7 @@ public class XMLElement: XMLContent {
- name: The name of the element to be initialized
- index: The index of the element to be initialized
*/
init(name: String, index: Int = 0, caseInsensitive:Bool) {
init(name: String, index: Int = 0, caseInsensitive: Bool) {
self.name = name
self.caseInsensitive = caseInsensitive
self.index = index
Expand All @@ -828,7 +828,7 @@ public class XMLElement: XMLContent {
- returns: The XMLElement that has now been added
*/

func addElement(_ name: String, withAttributes attributes: [String: String], caseInsensitive:Bool) -> XMLElement {
func addElement(_ name: String, withAttributes attributes: [String: String], caseInsensitive: Bool) -> XMLElement {
let element = XMLElement(name: name, index: count, caseInsensitive: caseInsensitive)
count += 1

Expand Down Expand Up @@ -896,12 +896,12 @@ extension SWXMLHash {
public typealias SWXMLHashXMLElement = XMLElement

fileprivate extension String {
func compare(_ s2: String?, _ insensitive: Bool) -> Bool {
guard let s2 = s2 else { return false }
let s1 = self
if (insensitive) {
return s1.caseInsensitiveCompare(s2) == .orderedSame
func compare(_ str2: String?, _ insensitive: Bool) -> Bool {
guard let str2 = str2 else { return false }
let str1 = self
if insensitive {
return str1.caseInsensitiveCompare(str2) == .orderedSame
}
return s1 == s2
return str1 == str2
}
}
3 changes: 1 addition & 2 deletions Tests/SWXMLHashTests/XMLParsingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class XMLParsingTests: XCTestCase {
XCTFail("\(error)")
}
}

func testShouldBeAbleToLookUpElementsByNameAndAttributeCaseInsensitive() {
do {
let xmlInsensitive = SWXMLHash.config({ (config) in
Expand All @@ -72,7 +72,6 @@ class XMLParsingTests: XCTestCase {
}
}


func testShouldBeAbleToIterateElementGroups() {
let result = xml!["root"]["catalog"]["book"].all.map({ $0["genre"].element!.text }).joined(separator: ", ")
XCTAssertEqual(result, "Computer, Fantasy, Fantasy")
Expand Down

0 comments on commit 209a7b4

Please sign in to comment.