Skip to content
This repository has been archived by the owner on Jun 11, 2018. It is now read-only.

Commit

Permalink
[VCD-13]: Adds SwiftLint
Browse files Browse the repository at this point in the history
  • Loading branch information
danthorpe committed Mar 22, 2016
1 parent 6cc5278 commit ea43d6a
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 22 deletions.
9 changes: 8 additions & 1 deletion .fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
default_platform :ios
lane :lint do

swiftLint(
mode: :lint,
config_file: '.swiftlint.yml'
)
end


platform :ios do

Expand Down
3 changes: 3 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
disabled_rules:
- line_length

9 changes: 4 additions & 5 deletions Tests/Support.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class FooCoder: NSObject, NSCoding, CodingType {

let value: Foo

required init(_ v: Foo) {
value = v
required init(_ aValue: Foo) {
value = aValue
}

required init?(coder aDecoder: NSCoder) {
Expand All @@ -38,7 +38,6 @@ class FooCoder: NSObject, NSCoding, CodingType {

extension Foo: Equatable { }

func ==(a: Foo, b: Foo) -> Bool {
return a.bar == b.bar
func == (lhs: Foo, rhs: Foo) -> Bool {
return lhs.bar == rhs.bar
}

1 change: 0 additions & 1 deletion Tests/ValueCodingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,3 @@ class ValueCodingTests: XCTestCase {
XCTAssertEqual(items.encoded.values, items)
}
}

67 changes: 67 additions & 0 deletions ValueCoding.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 652D3D981BCAA5AE00712107 /* Build configuration list for PBXNativeTarget "ValueCoding-OSX" */;
buildPhases = (
65A76FB51CA1FF2A00F62CBD /* Swift Lint */,
652D3D7D1BCAA5AD00712107 /* Sources */,
652D3D7E1BCAA5AD00712107 /* Frameworks */,
652D3D7F1BCAA5AD00712107 /* Headers */,
Expand Down Expand Up @@ -263,6 +264,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 652D3DB01BCAA66500712107 /* Build configuration list for PBXNativeTarget "ValueCoding-iOS" */;
buildPhases = (
65A76FB61CA1FF5900F62CBD /* Swift Lint */,
652D3D9A1BCAA66500712107 /* Sources */,
652D3D9B1BCAA66500712107 /* Frameworks */,
652D3D9C1BCAA66500712107 /* Headers */,
Expand Down Expand Up @@ -299,6 +301,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 652D3DD61BCAB86D00712107 /* Build configuration list for PBXNativeTarget "ValueCoding-watchOS" */;
buildPhases = (
65A76FB71CA1FF7E00F62CBD /* Swift Lint */,
652D3DCC1BCAB86D00712107 /* Sources */,
652D3DCD1BCAB86D00712107 /* Frameworks */,
652D3DCE1BCAB86D00712107 /* Headers */,
Expand All @@ -317,6 +320,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 65E7662A1BDFA84300889368 /* Build configuration list for PBXNativeTarget "ValueCoding-tvOS" */;
buildPhases = (
65A76FB81CA1FF9900F62CBD /* Swift Lint */,
65E766101BDFA84200889368 /* Sources */,
65E766111BDFA84200889368 /* Frameworks */,
65E766121BDFA84200889368 /* Headers */,
Expand Down Expand Up @@ -456,6 +460,69 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
65A76FB51CA1FF2A00F62CBD /* Swift Lint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Swift Lint";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint autocorrect\n [ -f .swiftlint.yml ] && CONFIG=\".swiftlint.yml\" || CONFIG=\"$HOME/.swiftlint.yml\"\n swiftlint lint --config $CONFIG\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
showEnvVarsInLog = 0;
};
65A76FB61CA1FF5900F62CBD /* Swift Lint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Swift Lint";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint autocorrect\n [ -f .swiftlint.yml ] && CONFIG=\".swiftlint.yml\" || CONFIG=\"$HOME/.swiftlint.yml\"\n swiftlint lint --config $CONFIG\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
showEnvVarsInLog = 0;
};
65A76FB71CA1FF7E00F62CBD /* Swift Lint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Swift Lint";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint autocorrect\n [ -f .swiftlint.yml ] && CONFIG=\".swiftlint.yml\" || CONFIG=\"$HOME/.swiftlint.yml\"\n swiftlint lint --config $CONFIG\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
showEnvVarsInLog = 0;
};
65A76FB81CA1FF9900F62CBD /* Swift Lint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Swift Lint";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint autocorrect\n [ -f .swiftlint.yml ] && CONFIG=\".swiftlint.yml\" || CONFIG=\"$HOME/.swiftlint.yml\"\n swiftlint lint --config $CONFIG\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
652D3D7D1BCAA5AD00712107 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down
27 changes: 12 additions & 15 deletions ValueCoding/ValueCoding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ import Foundation
// MARK: - CodingType

/**
A generic protocol for classes which can
A generic protocol for classes which can
encode/decode value types.
*/
public protocol CodingType {

/**
/**
The type of the composed value, ValueType

Bear in mind that there are no constraints on this
type. However, in reality when working with generic
types which require coding, it will be necessary to
constrain your generic clauses like this:

```swift
func foo<T: ValueCoding where T.Coder.ValueType == T>()
```

- see: ValueCoding
*/
associatedtype ValueType
Expand All @@ -49,7 +49,7 @@ public protocol ValueCoding {

/**
The Coder which implements CodingType

- see: CodingType
*/
associatedtype Coder: CodingType
Expand Down Expand Up @@ -106,7 +106,7 @@ extension ValueCoding where Coder: NSCoding, Coder.ValueType == Self {
For example

let foos = Foo.decode(decoder.decodeObjectForKey("foos") as? [AnyObject])

- parameter objects: a `SequenceType` of `AnyObject`.
- returns: the array of values which were able to be unarchived.
*/
Expand All @@ -126,11 +126,11 @@ extension ValueCoding where Coder: NSCoding, Coder.ValueType == Self {

/**
Encodes the value type into its Coder.
Typically this would be used inside of

Typically this would be used inside of
`encodeWithCoder:` when the value is composed inside
another `ValueCoding` or `NSCoding` type. For example:

encoder.encodeObject(foo.encoded, forKey: "foo")

*/
Expand All @@ -149,7 +149,7 @@ extension SequenceType where

Typically this would be used inside of
`encodeWithCoder:` when a sequence of values is
composed inside another `ValueCoding` or
composed inside another `ValueCoding` or
`NSCoding` type. For example:

encoder.encodeObject(foos.encoded, forKey: "foos")
Expand All @@ -167,13 +167,10 @@ extension SequenceType where
Generator.Element.Generator.Element.Coder.ValueType == Generator.Element.Generator.Element {

/**
Encodes a sequence of sequences of value types into
Encodes a sequence of sequences of value types into
an array of arrays of coders.
*/
public var encoded: [[Generator.Element.Generator.Element.Coder]] {
return map { $0.encoded }
}
}



0 comments on commit ea43d6a

Please sign in to comment.