Skip to content

Commit 6260997

Browse files
committed
Swiftlint fixes
1 parent 034d75a commit 6260997

File tree

13 files changed

+57
-57
lines changed

13 files changed

+57
-57
lines changed

.swiftlint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ opt_in_rules:
2424
- empty_enum_arguments
2525
- empty_parameters
2626
- empty_parentheses_with_trailing_closure
27-
- explicit_acl
27+
# - explicit_acl
2828
- explicit_enum_raw_value
2929
- explicit_init
3030
- explicit_top_level_acl
31-
- explicit_type_interface
31+
# - explicit_type_interface
3232
- extension_access_modifier
3333
- fallthrough
3434
- fatal_error_message

Examples/ColorParserExample/Sources/ColorParserExample/ColorParserExample.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import AppKit
22
@_exported import Eval
3-
import Foundation
43
@_exported import class Eval.Pattern
4+
import Foundation
55

66
public class ColorParser: EvaluatorWithLocalContext {
77
let interpreter: TypedInterpreter
@@ -48,23 +48,23 @@ extension String {
4848

4949
extension NSColor {
5050
func blend(with other: NSColor, using factor: CGFloat = 0.5) -> NSColor {
51-
let rightFactor = 1.0 - factor
51+
let inverseFactor = 1.0 - factor
5252

53-
var lr: CGFloat = 0
54-
var lg: CGFloat = 0
55-
var lb: CGFloat = 0
56-
var la: CGFloat = 0
57-
getRed(&lr, green: &lg, blue: &lb, alpha: &la)
53+
var leftRed: CGFloat = 0
54+
var leftGreen: CGFloat = 0
55+
var leftBlue: CGFloat = 0
56+
var leftAlpha: CGFloat = 0
57+
getRed(&leftRed, green: &leftGreen, blue: &leftBlue, alpha: &leftAlpha)
5858

59-
var rr: CGFloat = 0
60-
var rg: CGFloat = 0
61-
var rb: CGFloat = 0
62-
var ra: CGFloat = 0
63-
other.getRed(&rr, green: &rg, blue: &rb, alpha: &ra)
59+
var rightRed: CGFloat = 0
60+
var rightGreen: CGFloat = 0
61+
var rightBlue: CGFloat = 0
62+
var rightAlpha: CGFloat = 0
63+
other.getRed(&rightRed, green: &rightGreen, blue: &rightBlue, alpha: &rightAlpha)
6464

65-
return NSColor(calibratedRed: lr * factor + rr * rightFactor,
66-
green: lg * factor + rg * rightFactor,
67-
blue: lb * factor + rb * rightFactor,
68-
alpha: la * factor + ra * rightFactor)
65+
return NSColor(calibratedRed: leftRed * factor + rightRed * inverseFactor,
66+
green: leftGreen * factor + rightGreen * inverseFactor,
67+
blue: leftBlue * factor + rightBlue * inverseFactor,
68+
alpha: leftAlpha * factor + rightAlpha * inverseFactor)
6969
}
7070
}

Examples/TemplateExample/Sources/TemplateExample/TemplateExample.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@_exported import Eval
2-
import Foundation
32
@_exported import class Eval.Pattern
3+
import Foundation
44

55
public class TemplateLanguage: EvaluatorWithLocalContext {
66
public typealias EvaluatedType = String
@@ -67,7 +67,7 @@ public class TemplateLanguage: EvaluatorWithLocalContext {
6767
}
6868
return convert(value)
6969
}
70-
70+
7171
func replaceWhitespaces(_ input: String) -> String {
7272
let tag = "{-}"
7373
var input = input
@@ -106,8 +106,8 @@ public class TemplateLanguage: EvaluatorWithLocalContext {
106106
}
107107
}
108108

109-
typealias Macro = (arguments: [String], body: String)
110-
typealias BlockRenderer = (_ context: Context) -> String
109+
internal typealias Macro = (arguments: [String], body: String)
110+
internal typealias BlockRenderer = (_ context: Context) -> String
111111

112112
extension Context {
113113
static let macrosKey: String = "__macros"
@@ -181,7 +181,7 @@ public class TemplateLibrary {
181181
}
182182
}
183183
}
184-
184+
185185
public static var printStatement: Pattern<String, TemplateInterpreter<String>> {
186186
return Pattern([OpenKeyword("{{"), Variable<Any>("body"), CloseKeyword("}}")]) { variables, interpreter, _ in
187187
guard let body = variables["body"] else { return nil }
@@ -411,12 +411,12 @@ public class StandardLibrary {
411411

412412
public static var numericType: DataType<Double> {
413413
let numberLiteral = Literal { value, _ in Double(value) }
414-
let pi = Literal("pi", convertsTo: Double.pi)
415-
return DataType(type: Double.self, literals: [numberLiteral, pi]) { value, _ in String(format: "%g", value) }
414+
let piLiteral = Literal("pi", convertsTo: Double.pi)
415+
return DataType(type: Double.self, literals: [numberLiteral, piLiteral]) { value, _ in String(format: "%g", value) }
416416
}
417417

418418
public static var stringType: DataType<String> {
419-
let singleQuotesLiteral = literal(opening: "'", closing: "'") { (input, _) in input }
419+
let singleQuotesLiteral = literal(opening: "'", closing: "'") { input, _ in input }
420420
return DataType(type: String.self, literals: [singleQuotesLiteral]) { value, _ in value }
421421
}
422422

@@ -994,7 +994,7 @@ public class StandardLibrary {
994994
}
995995

996996
public static var methodCallWithIntResult: Function<Double> {
997-
return Function([Variable<Any>("lhs"), Keyword("."), Variable<String>("rhs", options: .notInterpreted)]) { (arguments, _, _) -> Double? in
997+
return Function([Variable<Any>("lhs"), Keyword("."), Variable<String>("rhs", options: .notInterpreted)]) { arguments, _, _ -> Double? in
998998
if let lhs = arguments["lhs"] as? NSObjectProtocol,
999999
let rhs = arguments["rhs"] as? String,
10001000
let result = lhs.perform(Selector(rhs)) {
@@ -1170,11 +1170,11 @@ extension String {
11701170

11711171
var html: String {
11721172
var html = ""
1173-
for c in self {
1174-
if let entity = String.enc[c] {
1173+
for character in self {
1174+
if let entity = String.enc[character] {
11751175
html.append(entity)
11761176
} else {
1177-
html.append(c)
1177+
html.append(character)
11781178
}
11791179
}
11801180
return html

Examples/TemplateExample/Tests/TemplateExampleTests/TemplateExampleTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ class TemplateExampleTests: XCTestCase {
1414
func testIfStatement() {
1515
XCTAssertEqual(eval("{% if true %}Hello{% endif %} {{ name }}!", ["name": "Teve"]), "Hello Teve!")
1616
}
17-
17+
1818
func testEmbeddedIfStatement() {
1919
XCTAssertEqual(eval("Result: {% if x > 1 %}{% if x < 5 %}1<x<5{% endif %}{% endif %}", ["x": 2]), "Result: 1<x<5")
20-
20+
2121
XCTAssertEqual(eval("Result: {% if x > 1 %}{% if x < 5 %}1<x<5{% endif %}{% else %}x<=1{% endif %}", ["x": 2]), "Result: 1<x<5")
2222
XCTAssertEqual(eval("Result: {% if x >= 5 %}x>=5{% else %}{% if x > 1 %}1<x<5{% endif %}{% endif %}", ["x": 2]), "Result: 1<x<5")
23-
23+
2424
XCTAssertEqual(eval("Result: {% if x > 1 %}{% if x < 5 %}1<x<5{% else %}x>=5{% endif %}{% else %}x<=1{% endif %}", ["x": 2]), "Result: 1<x<5")
2525
XCTAssertEqual(eval("Result: {% if x >= 5 %}x>=5{% else %}{% if x > 1 %}1<x<5{% else %}x<=1{% endif %}{% endif %}", ["x": 2]), "Result: 1<x<5")
2626
}
@@ -66,12 +66,12 @@ class TemplateExampleTests: XCTestCase {
6666
XCTAssertEqual(eval("{% block title5 %}Hello {{name}}{% endblock %}{% block title5 %}{{ parent() }}!{% endblock %}", ["name": "George"]), "Hello George!")
6767
XCTAssertEqual(eval("{% block title6 %}Hello {{name}}{% endblock %}{% block title6 %}{{ parent(name='Laszlo') }}!{% endblock %}", ["name": "Geroge"]), "Hello Laszlo!")
6868
}
69-
69+
7070
func testSpaceElimination() {
7171
XCTAssertEqual(eval("asd {-} jkl"), "asdjkl")
7272
XCTAssertEqual(eval("{-} jkl"), "jkl")
7373
XCTAssertEqual(eval("asd {-}"), "asd")
74-
74+
7575
XCTAssertEqual(eval("asd {-}{% if true %} Hello {% endif %} "), "asd Hello ")
7676
XCTAssertEqual(eval("asd {-}{% if true %}{-} Hello {% endif %} "), "asdHello ")
7777
XCTAssertEqual(eval("asd {% if true %} Hello {-} {% endif %} "), "asd Hello ")

Scripts/Sources/Automation/Eval.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class Eval {
230230
if matches > 0, let currentTag = try Shell.execute("git show HEAD~1:.version")?.output {
231231
let currentTag = currentTag.trimmingCharacters(in: .whitespacesAndNewlines)
232232
let tag = message.replacingOccurrences(of: "Version ", with: "")
233-
233+
234234
guard let tags = try Shell.execute("git tag -l")?.output?.components(separatedBy: .whitespacesAndNewlines),
235235
!tags.contains(tag) else { return }
236236

Scripts/Sources/Automation/Shell.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ class Shell {
5757
}
5858

5959
let observer = NotificationCenter.default.addObserver(forName: Notification.Name.NSFileHandleDataAvailable, object: fileHandle, queue: nil) { notification in
60-
if let fh = notification.object as? FileHandle {
61-
process(data: fh.availableData)
62-
fh.waitForDataInBackgroundAndNotify()
60+
if let noitificationFileHandle = notification.object as? FileHandle {
61+
process(data: noitificationFileHandle.availableData)
62+
noitificationFileHandle.waitForDataInBackgroundAndNotify()
6363
}
6464
}
6565

Sources/Eval/Common.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public class Context {
115115
/// - returns: A new `InterpreterContext` instance with the current and the parameter variables merged inside
116116
public func merging(with other: Context?) -> Context {
117117
if let other = other {
118-
return Context(variables: other.variables.merging(self.variables) { (eixstingValue, _) in eixstingValue })
118+
return Context(variables: other.variables.merging(self.variables) { eixstingValue, _ in eixstingValue })
119119
} else {
120120
return self
121121
}

Sources/Eval/Elements.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public class GenericVariable<T, E: Interpreter> : VariableProtocol, PatternEleme
162162
/// - parameter map: If provided, then the result of the evaluated variable will be running through this map function. By default the map tries to convert the matched value to the expected type, using the `as?` operator. Defaults to identical map, using the `as?` operator for value transformation
163163
public init(_ name: String,
164164
options: VariableOptions = [],
165-
map: @escaping VariableMapper<T, E> = { (value, _) in value as? T }) {
165+
map: @escaping VariableMapper<T, E> = { value, _ in value as? T }) {
166166
self.name = name
167167
self.options = options
168168
self.map = map

Sources/Eval/TemplateInterpreter.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,11 @@ public class TemplateVariable: GenericVariable<String, StringTemplateInterpreter
135135
/// - parameter options: Options that modify the behaviour of the variable matching, and the output that the framework provides
136136
/// - parameter map: If provided, then the result of the evaluated variable will be running through this map function
137137
/// Whether the processed variable sould be trimmed (removing whitespaces from both sides). Defaults to `true`
138-
public override init(_ name: String, options: VariableOptions = [], map: @escaping VariableMapper<String, StringTemplateInterpreter> = { (value, _) in value as? String }) {
138+
public override init(_ name: String, options: VariableOptions = [], map: @escaping VariableMapper<String, StringTemplateInterpreter> = { value, _ in value as? String }) {
139139
super.init(name, options: options.union(.notInterpreted)) { value, interpreter in
140140
guard let stringValue = value as? String else { return "" }
141141
let result = options.interpreted ? interpreter.evaluate(stringValue) : stringValue
142142
return map(result, interpreter)
143143
}
144144
}
145145
}
146-

Sources/Eval/Utilities/Matcher.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import Foundation
2424
/// A tuple with the variable metadata and its value
2525
/// - parameter metadata: Name, options, mapping information
2626
/// - parameter value: The value of the variable
27-
typealias VariableValue = (metadata: VariableProtocol, value: String)
27+
internal typealias VariableValue = (metadata: VariableProtocol, value: String)
2828

2929
/// A processor that can process a raw value with extra information, such as interpreter and context
3030
internal protocol VariableProcessorProtocol {
@@ -181,7 +181,7 @@ internal class Matcher {
181181
}
182182
} while true
183183
}
184-
184+
185185
/// Removes whitespaces characters from the upcoming consecutive input characters, when the context allows to do so
186186
/// - parameter remainder: The input to remove whitespaces from
187187
/// - parameter index: The index of the current element
@@ -237,7 +237,7 @@ internal class Matcher {
237237
nextElement(&elementIndex)
238238
}
239239
} else {
240-
variables.merge(embeddedVariables) { (key, _) in key }
240+
variables.merge(embeddedVariables) { key, _ in key }
241241
if currentlyActiveVariable != nil {
242242
guard registerAndValidateVariable(variables: &variables) else { return .noMatch }
243243
currentlyActiveVariable = nil

0 commit comments

Comments
 (0)