Update SwiftLint to 0.39.2 (#295)

* Update SwiftLint to 0.39.2

* Enable a bunch of extra rules

* Fix all warnings

* Ignore this Xcode generated folder

Co-authored-by: Olivier Halligon <olivier@halligon.net>
This commit is contained in:
David Jennes
2020-08-12 22:52:00 +02:00
committed by GitHub
parent a84cd3d877
commit 19646bcddf
15 changed files with 95 additions and 48 deletions

View File

@@ -1,13 +1,13 @@
public struct Environment {
public let templateClass: Template.Type
public var extensions: [Extension]
public var loader: Loader?
public init(loader: Loader? = nil,
extensions: [Extension] = [],
templateClass: Template.Type = Template.self) {
public init(
loader: Loader? = nil,
extensions: [Extension] = [],
templateClass: Template.Type = Template.self
) {
self.templateClass = templateClass
self.loader = loader
self.extensions = extensions + [DefaultExtension()]
@@ -44,5 +44,4 @@ public struct Environment {
template.environment = self
return try template.render(context)
}
}

View File

@@ -55,7 +55,6 @@ public protocol ErrorReporter: AnyObject {
}
open class SimpleErrorReporter: ErrorReporter {
open func renderError(_ error: Error) -> String {
guard let templateError = error as? TemplateSyntaxError else { return error.localizedDescription }
@@ -74,10 +73,9 @@ open class SimpleErrorReporter: ErrorReporter {
"""
}
var descriptions = templateError.stackTrace.reduce([]) { $0 + [describe(token: $1)] }
var descriptions = templateError.stackTrace.reduce(into: []) { $0.append(describe(token: $1)) }
let description = templateError.token.map(describe(token:)) ?? templateError.reason
descriptions.append(description)
return descriptions.joined(separator: "\n")
}
}

View File

@@ -113,7 +113,6 @@ final class InExpression: Expression, InfixOperator, CustomStringConvertible {
return false
}
}
final class OrExpression: Expression, InfixOperator, CustomStringConvertible {

View File

@@ -108,8 +108,8 @@ func indent(_ content: String, indentation: String, indentFirst: Bool) -> String
var lines = content.components(separatedBy: .newlines)
let firstLine = (indentFirst ? indentation : "") + lines.removeFirst()
let result = lines.reduce([firstLine]) { result, line in
result + [(line.isEmpty ? "" : "\(indentation)\(line)")]
let result = lines.reduce(into: [firstLine]) { result, line in
result.append(line.isEmpty ? "" : "\(indentation)\(line)")
}
return result.joined(separator: "\n")
}

View File

@@ -63,11 +63,8 @@ class ExtendsNode: NodeType {
}
let blockNodes = parsedNodes.compactMap { $0 as? BlockNode }
let nodes = blockNodes.reduce([String: BlockNode]()) { accumulator, node -> [String: BlockNode] in
var dict = accumulator
dict[node.name] = node
return dict
let nodes = blockNodes.reduce(into: [String: BlockNode]()) { accumulator, node in
accumulator[node.name] = node
}
return ExtendsNode(templateName: Variable(bits[1]), blocks: nodes, token: token)
@@ -185,5 +182,4 @@ class BlockNode: NodeType {
}
return childContext
}
}

View File

@@ -108,7 +108,6 @@ struct Lexer {
let offset = templateString.distance(from: line.range.lowerBound, to: range.lowerBound)
return (line.content, line.number, offset)
}
}
class Scanner {

View File

@@ -87,7 +87,6 @@ public class TokenParser {
public func compileResolvable(_ token: String, containedIn containingToken: Token) throws -> Resolvable {
return try environment.compileResolvable(token, containedIn: containingToken)
}
}
extension Environment {
@@ -180,7 +179,6 @@ extension Environment {
public func compileExpression(components: [String], containedIn token: Token) throws -> Expression {
return try IfExpressionParser.parser(components: components, environment: self, token: token).parse()
}
}
// https://en.wikipedia.org/wiki/Levenshtein_distance#Iterative_with_two_matrix_rows

View File

@@ -50,17 +50,17 @@ open class Template: ExpressibleByStringLiteral {
// MARK: ExpressibleByStringLiteral
// Create a templaVte with a template string literal
public convenience required init(stringLiteral value: String) {
public required convenience init(stringLiteral value: String) {
self.init(templateString: value)
}
// Create a template with a template string literal
public convenience required init(extendedGraphemeClusterLiteral value: StringLiteralType) {
public required convenience init(extendedGraphemeClusterLiteral value: StringLiteralType) {
self.init(stringLiteral: value)
}
// Create a template with a template string literal
public convenience required init(unicodeScalarLiteral value: StringLiteralType) {
public required convenience init(unicodeScalarLiteral value: StringLiteralType) {
self.init(stringLiteral: value)
}

View File

@@ -189,7 +189,6 @@ public struct RangeVariable: Resolvable {
let range = min(lower, upper)...max(lower, upper)
return lower > upper ? Array(range.reversed()) : Array(range)
}
}
func normalize(_ current: Any?) -> Any? {