Skip to content

SwiftLint 0.27 #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
opt_in_rules:
- anyobject_protocol
- array_init
- attributes
- closure_end_indentation
- closure_spacing
- contains_over_first_not_nil
- convenience_type
- discouraged_optional_boolean
- discouraged_optional_collection
- empty_count
- empty_string
- fallthrough
- fatal_error_message
- first_where
- force_unwrapping
- implicit_return
- implicitly_unwrapped_optional
- joined_default_parameter
- literal_expression_end_indentation
- lower_acl_than_parent
- modifier_order
- multiline_arguments
- multiline_function_chains
- multiline_parameters
- number_separator
- object_literal
- operator_usage_whitespace
- overridden_super_call
- override_in_extension
Expand All @@ -27,6 +35,7 @@ opt_in_rules:
- sorted_first_last
- sorted_imports
- trailing_closure
- unavailable_function
- unneeded_parentheses_in_closure_argument
- vertical_parameter_alignment_on_call
- yoda_condition
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
* Updated to latest Xcode (9.3.0).
[David Jennes](https://github.com/djbe)
[#86](https://github.com/SwiftGen/StencilSwiftKit/pull/86)
* Update to SwiftLint 0.27 and enable some extra SwiftLint rules.
[David Jennes](https://github.com/djbe)
[#96](https://github.com/SwiftGen/StencilSwiftKit/pull/96)

## 2.5.0

Expand Down
4 changes: 2 additions & 2 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PODS:
- PathKit (~> 0.8.0)
- StencilSwiftKit (2.5.0):
- Stencil (~> 0.12)
- SwiftLint (0.25.1)
- SwiftLint (0.27.0)

DEPENDENCIES:
- StencilSwiftKit (from `.`)
Expand All @@ -24,7 +24,7 @@ SPEC CHECKSUMS:
PathKit: dcab05d701474011aae0e40cf892298a831f63d6
Stencil: c324035607f483153c780fb42367d284cadd30a6
StencilSwiftKit: 80a778f61bb742fd7714a5f9f3c2249d2eafa594
SwiftLint: ce933681be10c3266e82576dad676fa815a602e9
SwiftLint: 3207c1faa2240bf8973b191820a116113cd11073

PODFILE CHECKSUM: 0bd9ec310bace9d5b62e785ea1fb74547c15074d

Expand Down
4 changes: 2 additions & 2 deletions Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Pods/SwiftLint/swiftlint
Binary file not shown.
4 changes: 2 additions & 2 deletions Sources/SetNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Stencil
class SetNode: NodeType {
enum Content {
case nodes([NodeType])
case reference(to: Resolvable)
case reference(resolvable: Resolvable)
}

let variableName: String
Expand All @@ -29,7 +29,7 @@ class SetNode: NodeType {
if components.count == 3 {
// we have a value expression, no nodes
let resolvable = try parser.compileResolvable(components[2], containedIn: token)
return SetNode(variableName: variable, content: .reference(to: resolvable))
return SetNode(variableName: variable, content: .reference(resolvable: resolvable))
} else {
// no value expression, parse until an `endset` node
let setNodes = try parser.parse(until(["endset"]))
Expand Down
2 changes: 1 addition & 1 deletion Sources/StencilSwiftTemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ open class StencilSwiftTemplate: Template {
}

// swiftlint:disable:next discouraged_optional_collection
open override func render(_ dictionary: [String: Any]? = nil) throws -> String {
override open func render(_ dictionary: [String: Any]? = nil) throws -> String {
return try removeExtraLines(from: super.render(dictionary))
}

Expand Down
16 changes: 8 additions & 8 deletions Tests/StencilSwiftKitTests/SetNodeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class SetNodeTests: XCTestCase {
}

do {
let node = SetNode(variableName: "value", content: .reference(to: Variable("test")))
let node = SetNode(variableName: "value", content: .reference(resolvable: Variable("test")))
let context = Context(dictionary: [:])
let output = try node.render(context)
XCTAssertEqual(output, "")
Expand Down Expand Up @@ -141,14 +141,14 @@ class SetNodeTests: XCTestCase {
XCTAssertNil(context["c"])

// alias a into c
node = SetNode(variableName: "c", content: .reference(to: Variable("a")))
node = SetNode(variableName: "c", content: .reference(resolvable: Variable("a")))
_ = try node.render(context)
XCTAssertEqual(context["a"] as? String, "hi")
XCTAssertEqual(context["b"] as? String, "world")
XCTAssertEqual(context["c"] as? String, "hi")

// alias non-existing into c
node = SetNode(variableName: "c", content: .reference(to: Variable("foo")))
node = SetNode(variableName: "c", content: .reference(resolvable: Variable("foo")))
_ = try node.render(context)
XCTAssertEqual(context["a"] as? String, "hi")
XCTAssertEqual(context["b"] as? String, "world")
Expand Down Expand Up @@ -177,14 +177,14 @@ class SetNodeTests: XCTestCase {
XCTAssertEqual(context["c"] as? Int, 3)

// alias a into c
node = SetNode(variableName: "c", content: .reference(to: Variable("a")))
node = SetNode(variableName: "c", content: .reference(resolvable: Variable("a")))
_ = try node.render(context)
XCTAssertEqual(context["a"] as? String, "hello")
XCTAssertEqual(context["b"] as? String, "world")
XCTAssertEqual(context["c"] as? String, "hello")

// alias non-existing into c
node = SetNode(variableName: "c", content: .reference(to: Variable("foo")))
node = SetNode(variableName: "c", content: .reference(resolvable: Variable("foo")))
_ = try node.render(context)
XCTAssertEqual(context["a"] as? String, "hello")
XCTAssertEqual(context["b"] as? String, "world")
Expand Down Expand Up @@ -238,7 +238,7 @@ class SetNodeTests: XCTestCase {
XCTAssertNil(context["c"])

// alias a into c
node = SetNode(variableName: "c", content: .reference(to: Variable("a")))
node = SetNode(variableName: "c", content: .reference(resolvable: Variable("a")))
_ = try node.render(context)
XCTAssertEqual(context["a"] as? String, "hello")
XCTAssertEqual(context["b"] as? Int, 2)
Expand All @@ -264,7 +264,7 @@ class SetNodeTests: XCTestCase {
XCTAssertNil(context["b"])

// set b
node = SetNode(variableName: "b", content: .reference(to: Variable("items")))
node = SetNode(variableName: "b", content: .reference(resolvable: Variable("items")))
_ = try node.render(context)
XCTAssertEqual(context["b"] as? [Int], [1, 3, 7])
}
Expand All @@ -274,7 +274,7 @@ class SetNodeTests: XCTestCase {

let parser = TokenParser(tokens: [], environment: stencilSwiftEnvironment())
let argument = try FilterExpression(token: "greet|uppercase", parser: parser)
let node = SetNode(variableName: "a", content: .reference(to: argument))
let node = SetNode(variableName: "a", content: .reference(resolvable: argument))

_ = try node.render(context)
XCTAssertEqual(context["a"] as? String, "HELLO")
Expand Down
2 changes: 1 addition & 1 deletion Tests/StencilSwiftKitTests/StringFiltersTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class StringFiltersTests: XCTestCase {
return stringRepresentation.hashValue
}

public static func == (lhs: Input, rhs: Input) -> Bool {
static func == (lhs: Input, rhs: Input) -> Bool {
return lhs.stringRepresentation == rhs.stringRepresentation
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/StencilSwiftKitTests/TestsHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private let koCode = (num: colorCode("fg127,127,127") + colorCode("bg127,0,0"),

func diff(_ result: String, _ expected: String) -> String? {
guard result != expected else { return nil }
var firstDiff: Int? = nil
var firstDiff: Int?
let newlines = CharacterSet.newlines
let lhsLines = result.components(separatedBy: newlines)
let rhsLines = expected.components(separatedBy: newlines)
Expand Down