From eb1d2ac191764d8684cf62598f8fa3d4e83655f9 Mon Sep 17 00:00:00 2001 From: David Jennes Date: Mon, 9 Apr 2018 23:06:24 +0200 Subject: [PATCH] New swiftlint rules --- .swiftlint.yml | 3 +++ Sources/StencilSwiftTemplate.swift | 1 + Tests/StencilSwiftKitTests/StringFiltersTests.swift | 2 +- Tests/StencilSwiftKitTests/SwiftIdentifierTests.swift | 2 +- Tests/StencilSwiftKitTests/TestsHelper.swift | 4 ++-- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index b015bb42..cd0eb704 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -5,7 +5,9 @@ opt_in_rules: - closure_spacing - contains_over_first_not_nil - discouraged_optional_boolean + - discouraged_optional_collection - empty_count + - empty_string - fatal_error_message - first_where - force_unwrapping @@ -26,6 +28,7 @@ opt_in_rules: - sorted_imports - trailing_closure - unneeded_parentheses_in_closure_argument + - untyped_error_in_catch - vertical_parameter_alignment_on_call - yoda_condition diff --git a/Sources/StencilSwiftTemplate.swift b/Sources/StencilSwiftTemplate.swift index 975fa5d9..eb78beeb 100644 --- a/Sources/StencilSwiftTemplate.swift +++ b/Sources/StencilSwiftTemplate.swift @@ -20,6 +20,7 @@ open class StencilSwiftTemplate: Template { super.init(templateString: templateStringWithMarkedNewlines, environment: environment, name: name) } + // swiftlint:disable:next discouraged_optional_collection open override func render(_ dictionary: [String: Any]? = nil) throws -> String { return try removeExtraLines(from: super.render(dictionary)) } diff --git a/Tests/StencilSwiftKitTests/StringFiltersTests.swift b/Tests/StencilSwiftKitTests/StringFiltersTests.swift index 41d23713..3da7280e 100644 --- a/Tests/StencilSwiftKitTests/StringFiltersTests.swift +++ b/Tests/StencilSwiftKitTests/StringFiltersTests.swift @@ -170,7 +170,7 @@ extension StringFiltersTests { XCTFail("Code did succeed while it was expected to fail for wrong option") } catch Filters.Error.invalidOption { // That's the expected exception we want to happen - } catch let error { + } catch let error as Error { XCTFail("Unexpected error occured: \(error)") } } diff --git a/Tests/StencilSwiftKitTests/SwiftIdentifierTests.swift b/Tests/StencilSwiftKitTests/SwiftIdentifierTests.swift index fbcdc61e..9e350ac9 100644 --- a/Tests/StencilSwiftKitTests/SwiftIdentifierTests.swift +++ b/Tests/StencilSwiftKitTests/SwiftIdentifierTests.swift @@ -61,7 +61,7 @@ extension SwiftIdentifierTests { XCTFail("Code did succeed while it was expected to fail for wrong option") } catch Filters.Error.invalidOption { // That's the expected exception we want to happen - } catch let error { + } catch let error as Error { XCTFail("Unexpected error occured: \(error)") } } diff --git a/Tests/StencilSwiftKitTests/TestsHelper.swift b/Tests/StencilSwiftKitTests/TestsHelper.swift index cc7827c3..987d33b5 100644 --- a/Tests/StencilSwiftKitTests/TestsHelper.swift +++ b/Tests/StencilSwiftKitTests/TestsHelper.swift @@ -88,8 +88,8 @@ class Fixtures { let subDir: String? = name.hasSuffix(".stencil") ? "fixtures" : "expected" do { return try path(for: name, subDirectory: subDir).read(encoding) - } catch let e { - fatalError("Unable to load fixture content: \(e)") + } catch let error as Error { + fatalError("Unable to load fixture content: \(error)") } } }