diff --git a/CHANGELOG.md b/CHANGELOG.md index 8757c4a..d28a94d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,9 @@ _None_ ### Internal Changes -_None_ +* Fix swiftlint errors on enum names not conforming to the Swift 3 syntax. + [Liquidsoul](https://github.com/liquidsoul) + [#31](https://github.com/SwiftGen/SwiftGenKit/issues/31) ## 1.1.0 diff --git a/Sources/Parsers/ColorsFileParser.swift b/Sources/Parsers/ColorsFileParser.swift index feb41a9..3b871de 100644 --- a/Sources/Parsers/ColorsFileParser.swift +++ b/Sources/Parsers/ColorsFileParser.swift @@ -19,7 +19,7 @@ public enum ColorsParserError: Error, CustomStringConvertible { public var description: String { switch self { case .invalidHexColor(string: let string, key: let key): - let keyInfo = key.flatMap { k in " for key \"\(k)\"" } ?? "" + let keyInfo = key.flatMap { " for key \"\($0)\"" } ?? "" return "error: Invalid hex color \"\(string)\" found\(keyInfo)." case .invalidFile(reason: let reason): return "error: Unable to parse file. \(reason)" diff --git a/Sources/Parsers/StringsFileParser.swift b/Sources/Parsers/StringsFileParser.swift index 99cf520..35643f1 100644 --- a/Sources/Parsers/StringsFileParser.swift +++ b/Sources/Parsers/StringsFileParser.swift @@ -51,13 +51,13 @@ public final class StringsFileParser { // MARK: - Public Enum types public enum PlaceholderType: String { - case Object = "String" - case Float = "Float" - case Int = "Int" - case Char = "Character" - case CString = "UnsafePointer" - case Pointer = "UnsafePointer" - case Unknown = "UnsafePointer<()>" + case object = "String" + case float = "Float" + case int = "Int" + case char = "Character" + case cString = "UnsafePointer" + case pointer = "UnsafePointer" + case unknown = "UnsafePointer<()>" init?(formatChar char: Character) { guard let lcChar = String(char).lowercased().characters.first else { @@ -65,17 +65,17 @@ public final class StringsFileParser { } switch lcChar { case "@": - self = .Object + self = .object case "a", "e", "f", "g": - self = .Float + self = .float case "d", "i", "o", "u", "x": - self = .Int + self = .int case "c": - self = .Char + self = .char case "s": - self = .CString + self = .cString case "p": - self = .Pointer + self = .pointer default: return nil } @@ -176,7 +176,7 @@ public final class StringsFileParser { } if insertionPos > 0 { while list.count <= insertionPos-1 { - list.append(.Unknown) + list.append(.unknown) } list[insertionPos-1] = p } diff --git a/Tests/SwiftGenKitTests/StringsTests.swift b/Tests/SwiftGenKitTests/StringsTests.swift index d651706..f008a95 100644 --- a/Tests/SwiftGenKitTests/StringsTests.swift +++ b/Tests/SwiftGenKitTests/StringsTests.swift @@ -28,7 +28,7 @@ class StringsTests: XCTestCase { translation: "My awesome title")) parser.addEntry(StringsFileParser.Entry(key: "Greetings", translation: "Hello, my name is %@ and I'm %d", - types: .Object, .Int)) + types: .object, .int)) let result = parser.stencilContext() XCTDiffContexts(result, expected: "entries.plist", sub: .strings) @@ -78,44 +78,44 @@ class StringsTests: XCTestCase { func testParseStringPlaceholder() { let placeholders = StringsFileParser.PlaceholderType.placeholders(fromFormat: "%@") - XCTAssertEqual(placeholders, [.Object]) + XCTAssertEqual(placeholders, [.object]) } func testParseFloatPlaceholder() { let placeholders = StringsFileParser.PlaceholderType.placeholders(fromFormat: "%f") - XCTAssertEqual(placeholders, [.Float]) + XCTAssertEqual(placeholders, [.float]) } func testParseDoublePlaceholders() { let placeholders = StringsFileParser.PlaceholderType.placeholders(fromFormat: "%g-%e") - XCTAssertEqual(placeholders, [.Float, .Float]) + XCTAssertEqual(placeholders, [.float, .float]) } func testParseFloatWithPrecisionPlaceholders() { let placeholders = StringsFileParser.PlaceholderType.placeholders(fromFormat: "%1.2f : %.3f : %+3f : %-6.2f") - XCTAssertEqual(placeholders, [.Float, .Float, .Float, .Float]) + XCTAssertEqual(placeholders, [.float, .float, .float, .float]) } func testParseIntPlaceholders() { let placeholders = StringsFileParser.PlaceholderType.placeholders(fromFormat: "%d-%i-%o-%u-%x") - XCTAssertEqual(placeholders, [.Int, .Int, .Int, .Int, .Int]) + XCTAssertEqual(placeholders, [.int, .int, .int, .int, .int]) } func testParseCCharAndStringPlaceholders() { let placeholders = StringsFileParser.PlaceholderType.placeholders(fromFormat: "%c-%s") - XCTAssertEqual(placeholders, [.Char, .CString]) + XCTAssertEqual(placeholders, [.char, .cString]) } func testParsePositionalPlaceholders() { let placeholders = StringsFileParser.PlaceholderType.placeholders(fromFormat: "%2$d-%4$f-%3$@-%c") - XCTAssertEqual(placeholders, [.Char, .Int, .Object, .Float]) + XCTAssertEqual(placeholders, [.char, .int, .object, .float]) } func testParseComplexFormatPlaceholders() { let format = "%2$1.3d - %4$-.7f - %3$@ - %% - %5$+3c - %%" let placeholders = StringsFileParser.PlaceholderType.placeholders(fromFormat: format) // positions 2, 4, 3, 5 set to Int, Float, Object, Char, and position 1 not matched, defaulting to Unknown - XCTAssertEqual(placeholders, [.Unknown, .Int, .Object, .Float, .Char]) + XCTAssertEqual(placeholders, [.unknown, .int, .object, .float, .char]) } func testParseEscapePercentSign() {