Skip to content
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

Use SwiftLint via CocoaPods #78

Merged
merged 9 commits into from
Apr 9, 2018
Merged
Show file tree
Hide file tree
Changes from 6 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
14 changes: 14 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
disabled_rules:
- type_name

opt_in_rules:
- force_unwrapping
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍, + 💯


# Rules customization
line_length:
warning: 120
error: 200

nesting:
type_level:
warning: 2
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ _None_

### Internal Changes

_None_
* Switched to using SwiftLint via CocoaPods instead of our own install scripts.
[David Jennes](https://github.com/djbe)
[#78](https://github.com/SwiftGen/StencilSwiftKit/pull/78)

## 2.4.0

Expand Down
1 change: 1 addition & 0 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ use_frameworks!

target 'Tests' do
pod 'StencilSwiftKit', path: '.'
pod 'SwiftLint', '~> 0.25'
end
9 changes: 6 additions & 3 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ PODS:
- PathKit (~> 0.8.0)
- StencilSwiftKit (2.4.0):
- Stencil (~> 0.10)
- SwiftLint (0.25.0)

DEPENDENCIES:
- StencilSwiftKit (from `.`)
- SwiftLint (~> 0.25)

EXTERNAL SOURCES:
StencilSwiftKit:
Expand All @@ -15,8 +17,9 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
PathKit: dcab05d701474011aae0e40cf892298a831f63d6
Stencil: 40b382c52edab08f1e800e6144c1f04ae47a7a9a
StencilSwiftKit: 41693610fdab5a3782f9722b420d87eb4b287f33
StencilSwiftKit: 385f50e5263290411a059dadcbbc153b4f242f3c
SwiftLint: e14651157288e9e01d6e1a71db7014fb5744a8ea

PODFILE CHECKSUM: a08ecc2ab2ae91e8f0cddb740ac4e30be2cffc7d
PODFILE CHECKSUM: 4f35313d732240f2655b591ec8ce3f742e804e98

COCOAPODS: 1.3.1
COCOAPODS: 1.4.0
9 changes: 6 additions & 3 deletions Pods/Manifest.lock

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

637 changes: 334 additions & 303 deletions Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions Pods/SwiftLint/LICENSE

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

Binary file added Pods/SwiftLint/swiftlint
Binary file not shown.
8 changes: 4 additions & 4 deletions Pods/Target Support Files/PathKit/PathKit.xcconfig

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

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

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

44 changes: 38 additions & 6 deletions Pods/Target Support Files/Pods-Tests/Pods-Tests-frameworks.sh

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

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

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

10 changes: 5 additions & 5 deletions Pods/Target Support Files/Stencil/Stencil.xcconfig

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

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

2 changes: 1 addition & 1 deletion StencilSwiftKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [[ ! $CI ]]; then\n [[ -r ~/.profile ]] && source ~/.profile\n if [[ `which bundler` ]]; then\n bundle exec rake lint:code\n bundle exec rake lint:tests\n else\n echo \"warning: bundler not found, can't lint code. Please install bundler then run bundle install.\"\n fi\nfi";
shellScript = "if [[ ! $CI ]]; then\n \"$PODS_ROOT/SwiftLint/swiftlint\" lint --strict --config \"${SRCROOT}/.swiftlint.yml\" --path \"${SRCROOT}/Sources\"\n \"$PODS_ROOT/SwiftLint/swiftlint\" lint --strict --config \"${SRCROOT}/.swiftlint.yml\" --path \"${SRCROOT}/Tests\"\nfi";
};
DE127EA8748200EF28090721 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
7 changes: 6 additions & 1 deletion Tests/StencilSwiftKitTests/ParseBoolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ import XCTest
@testable import StencilSwiftKit

class ParseBoolTests: XCTestCase {

func testParseBool_TrueWithString() throws {
// swiftlint:disable force_unwrapping
XCTAssertTrue(try Filters.parseBool(from: ["true"])!)
XCTAssertTrue(try Filters.parseBool(from: ["yes"])!)
XCTAssertTrue(try Filters.parseBool(from: ["1"])!)
// swiftlint:enable force_unwrapping
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should instead use XCTAssertTrue((try …) ?? false) or XCTAssertEquals(try …, true) to avoid the force-unwrap here? Especially, in case there's a regression one day and the test parseBool(from: ["true"]) starts to fail and return an unexpected nil, that force-unwrap will make the test harness crash and stop the whole test process, instead of marking that test as failed and continue with other test cases…

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd have to be careful then to provide the "inverse" value as a fallback for each test. Here it's true, for the parseBool(from: ["false"]) it should be false, ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's why I'd prefer to use the more readable XCTAssertEquals(…, true) there rather than XCTAssertTrue(… ?? false)

}

func testParseBool_FalseWithString() throws {
// swiftlint:disable force_unwrapping
XCTAssertFalse(try Filters.parseBool(from: ["false"])!)
XCTAssertFalse(try Filters.parseBool(from: ["no"])!)
XCTAssertFalse(try Filters.parseBool(from: ["0"])!)
// swiftlint:enable force_unwrapping
}

func testParseBool_WithOptionalInt() throws {
Expand Down Expand Up @@ -57,7 +60,9 @@ class ParseBoolTests: XCTestCase {
}

func testParseBool_WithNonZeroIndex() throws {
// swiftlint:disable force_unwrapping
XCTAssertTrue(try Filters.parseBool(from: ["test", "true"], at: 1)!)
XCTAssertFalse(try Filters.parseBool(from: ["test", "false"], at: 1)!)
// swiftlint:enable force_unwrapping
}
}
1 change: 0 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ machine:

dependencies:
post:
- bundle exec rake lint:install
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same questions as in SwiftGen/SwiftGen#401 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same answer :trollface:

- curl -sS https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash

test:
Expand Down
Loading