From d60eed5fce6d7f84012eb31774407c66ecf8e93b Mon Sep 17 00:00:00 2001 From: sshin-mobify Date: Tue, 17 Jan 2017 12:29:23 -0800 Subject: [PATCH 1/7] Added information. About swxftlint with basic linter configuration --- CHANGELOG | 2 ++ swift/README.md | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4fa4f0d..0d4a00f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +2.7.5 + - Added .swiftlint.yml that enforces Mobify code style 2.7.4 - Add links to alternative CSSComb text editor plugins 2.7.3 diff --git a/swift/README.md b/swift/README.md index bf5f08e..95e6569 100644 --- a/swift/README.md +++ b/swift/README.md @@ -6,6 +6,26 @@ We also follow the [Swift API design guidelines](https://swift.org/documentation Our overarching goals are conciseness, readability, and simplicity. +## Linting + Included is a default Mobify Swift Style Guide SwiftLint configuration,`.swiftlint.yml`. + + You can install [SwiftLint](https://github.com/realm/SwiftLint) by command `brew install swiftlint` + +### Integration + Integrate SwiftLint into Xcode to get warnings and errors displayed. You can add a new "Run Script" with: + + ```bash + if which swiftlint >/dev/null; then + swiftlint + else + echo "warning: SwiftLint not installed, install using 'brew install swiftlint'" + fi + ``` + + autocorrect is available by command `swiftlint autocorrect` + + for more information on this linter you can visit [this](https://github.com/realm/SwiftLint) page + ## Table of Contents * [Correctness](#correctness) @@ -353,7 +373,7 @@ class BoardLocation { init(row: Int, column: Int) { self.row = row self.column = column - + let closure = { print(self.row) } @@ -418,7 +438,7 @@ Mark classes `final` when inheritance is not intended. Example: ```swift // Turn any generic type into a reference type using this Box class. final class Box { - let value: T + let value: T init(_ value: T) { self.value = value } @@ -440,7 +460,7 @@ func reticulateSplines(spline: [Double]) -> Bool { For functions with long signatures, add line breaks after each parameter and indent them on the same level as the first parameter. ```swift -func reticulateSplines(spline: [Double], +func reticulateSplines(spline: [Double], adjustmentFactor: Double, translateConstant: Int, comment: String) -> Bool { @@ -906,15 +926,15 @@ When coding with conditionals, the left hand margin of the code should be the "g ```swift func computeFFT(context: Context?, inputData: InputData?) throws -> Frequencies { - guard let context = context else { - throw FFTError.noContext + guard let context = context else { + throw FFTError.noContext } - guard let inputData = inputData else { - throw FFTError.noInputData + guard let inputData = inputData else { + throw FFTError.noInputData } - + // use context and input to compute the frequencies - + return frequencies } ``` @@ -1048,4 +1068,3 @@ Prefer Autolayout over springs+struts (autoresizing mask). Autolayout automatica ## Credits Heavily based on [The Official raywenderlich.com Swift Style Guide](https://github.com/raywenderlich/swift-style-guide/blob/master/README.markdown) - From a8c3aa688c5b6444730354f7698da97773bbe014 Mon Sep 17 00:00:00 2001 From: sshin-mobify Date: Tue, 17 Jan 2017 12:35:36 -0800 Subject: [PATCH 2/7] Edited some changes in ReadMe --- swift/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/swift/README.md b/swift/README.md index 95e6569..4005df2 100644 --- a/swift/README.md +++ b/swift/README.md @@ -7,6 +7,8 @@ We also follow the [Swift API design guidelines](https://swift.org/documentation Our overarching goals are conciseness, readability, and simplicity. ## Linting + + Included is a default Mobify Swift Style Guide SwiftLint configuration,`.swiftlint.yml`. You can install [SwiftLint](https://github.com/realm/SwiftLint) by command `brew install swiftlint` From 95a0e3de2fb2f358e8c5b94a03f33e4bc8f86da0 Mon Sep 17 00:00:00 2001 From: sshin-mobify Date: Tue, 17 Jan 2017 12:36:27 -0800 Subject: [PATCH 3/7] ReadMe --- swift/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/swift/README.md b/swift/README.md index 4005df2..5f1c81a 100644 --- a/swift/README.md +++ b/swift/README.md @@ -8,10 +8,9 @@ Our overarching goals are conciseness, readability, and simplicity. ## Linting +Included is a default Mobify Swift Style Guide SwiftLint configuration,`.swiftlint.yml`. - Included is a default Mobify Swift Style Guide SwiftLint configuration,`.swiftlint.yml`. - - You can install [SwiftLint](https://github.com/realm/SwiftLint) by command `brew install swiftlint` +You can install [SwiftLint](https://github.com/realm/SwiftLint) by command `brew install swiftlint` ### Integration Integrate SwiftLint into Xcode to get warnings and errors displayed. You can add a new "Run Script" with: From f351f891a6249138c9d7b303acafc0143e4a6702 Mon Sep 17 00:00:00 2001 From: sshin-mobify Date: Tue, 17 Jan 2017 12:37:02 -0800 Subject: [PATCH 4/7] Spacing issues --- swift/README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/swift/README.md b/swift/README.md index 5f1c81a..a82f006 100644 --- a/swift/README.md +++ b/swift/README.md @@ -13,19 +13,19 @@ Included is a default Mobify Swift Style Guide SwiftLint configuration,`.swiftli You can install [SwiftLint](https://github.com/realm/SwiftLint) by command `brew install swiftlint` ### Integration - Integrate SwiftLint into Xcode to get warnings and errors displayed. You can add a new "Run Script" with: +Integrate SwiftLint into Xcode to get warnings and errors displayed. You can add a new "Run Script" with: - ```bash - if which swiftlint >/dev/null; then - swiftlint - else - echo "warning: SwiftLint not installed, install using 'brew install swiftlint'" - fi - ``` +```bash +if which swiftlint >/dev/null; then + swiftlint +else + echo "warning: SwiftLint not installed, install using 'brew install swiftlint'" +fi +``` - autocorrect is available by command `swiftlint autocorrect` +autocorrect is available by command `swiftlint autocorrect` - for more information on this linter you can visit [this](https://github.com/realm/SwiftLint) page +for more information on this linter you can visit [this](https://github.com/realm/SwiftLint) page ## Table of Contents From 7d8c335f9ccf41883c8a9fd0bddd8fba17f39029 Mon Sep 17 00:00:00 2001 From: sshin-mobify Date: Tue, 17 Jan 2017 14:19:40 -0800 Subject: [PATCH 5/7] edited configuration --- swift/.swiftlint.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 swift/.swiftlint.yml diff --git a/swift/.swiftlint.yml b/swift/.swiftlint.yml new file mode 100644 index 0000000..3ee352d --- /dev/null +++ b/swift/.swiftlint.yml @@ -0,0 +1,22 @@ +disabled_rules: + - trailing_whitespace + - line_length + - control_statement + - trailing_comma + - file_length + - unused_closure_parameter + - function_body_length + - todo + - cyclomatic_complexity + - variable_name + - type_name + - empty_parentheses_with_trailing_closure + - force_cast + - nesting + - function_parameter_count + - force_try + - legacy_constructor + +type_body_length: + - 480 # warning + - 500 # error From 22b04d31e1a13ca84ebf0863a06a84acb63e9d39 Mon Sep 17 00:00:00 2001 From: sshin-mobify Date: Tue, 17 Jan 2017 14:54:00 -0800 Subject: [PATCH 6/7] reconfigured base on Astro --- swift/.swiftlint.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/swift/.swiftlint.yml b/swift/.swiftlint.yml index 3ee352d..43d79ff 100644 --- a/swift/.swiftlint.yml +++ b/swift/.swiftlint.yml @@ -1,16 +1,10 @@ disabled_rules: - - trailing_whitespace - line_length - - control_statement - - trailing_comma - file_length - - unused_closure_parameter - function_body_length - todo - cyclomatic_complexity - variable_name - - type_name - - empty_parentheses_with_trailing_closure - force_cast - nesting - function_parameter_count From e71412f47dd24c73f19b74435172914e74ac5f7f Mon Sep 17 00:00:00 2001 From: Steven Shin Date: Fri, 3 Mar 2017 09:44:34 -0800 Subject: [PATCH 7/7] Update README.md Capitalize --- swift/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swift/README.md b/swift/README.md index a82f006..bdd24fa 100644 --- a/swift/README.md +++ b/swift/README.md @@ -23,9 +23,9 @@ else fi ``` -autocorrect is available by command `swiftlint autocorrect` +Autocorrect is available by command `swiftlint autocorrect` -for more information on this linter you can visit [this](https://github.com/realm/SwiftLint) page +For more information on this linter you can visit [this](https://github.com/realm/SwiftLint) page ## Table of Contents