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

Commit

Permalink
Lint output (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
djbe authored and AliSoftware committed Feb 12, 2017
1 parent 08137d9 commit 28be61a
Show file tree
Hide file tree
Showing 46 changed files with 282 additions and 158 deletions.
11 changes: 11 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
disabled_rules:
- type_name

opt_in_rules:
- force_unwrapping

# Rules customization
line_length:
warning: 120
error: 200

3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ env:
- RAKETASK=test

script:
- Scripts/install_swiftlint.sh
- PROJECT_DIR=Tests Scripts/swiftlint-code.sh
- rake "$RAKETASK"
- Scripts/swiftlint-output.sh
- Scripts/compile-modules.sh
- Scripts/compile-output.sh
25 changes: 25 additions & 0 deletions Scripts/install_swiftlint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Installs the SwiftLint package.
# Tries to get the precompiled .pkg file from Github, but if that
# fails just recompiles from source.
#
# Original script: https://alexplescan.com/posts/2016/03/03/setting-up-swiftlint-on-travis-ci/

set -e

SWIFTLINT_PKG_PATH="/tmp/SwiftLint.pkg"
SWIFTLINT_PKG_URL="https://github.com/realm/SwiftLint/releases/download/0.16.1/SwiftLint.pkg"

wget --output-document=$SWIFTLINT_PKG_PATH $SWIFTLINT_PKG_URL

if [ -f $SWIFTLINT_PKG_PATH ]; then
echo "SwiftLint package exists! Installing it..."
sudo installer -pkg $SWIFTLINT_PKG_PATH -target /
else
echo "SwiftLint package doesn't exist. Compiling from source..." &&
git clone https://github.com/realm/SwiftLint.git /tmp/SwiftLint &&
cd /tmp/SwiftLint &&
git submodule update --init --recursive &&
sudo make install
fi
6 changes: 6 additions & 0 deletions Scripts/swiftlint-code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if which swiftlint >/dev/null; then
# Lint SwiftGen's source itself
swiftlint lint --path "${PROJECT_DIR}/TestSuites"
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
6 changes: 6 additions & 0 deletions Scripts/swiftlint-output.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if which swiftlint >/dev/null; then
# Lint generated code in Tests/Expected
swiftlint lint --path "Tests/Expected"
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
8 changes: 4 additions & 4 deletions Tests/Expected/Storyboards-iOS/default-context-all.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ enum StoryboardSegue {
case Test = "test"
}
enum Message: String, StoryboardSegueType {
case CustomBack = "CustomBack"
case Embed = "Embed"
case NonCustom = "NonCustom"
case CustomBack
case Embed
case NonCustom
case Show_NavCtrl = "Show-NavCtrl"
}
enum Wizard: String, StoryboardSegueType {
case ShowPassword = "ShowPassword"
case ShowPassword
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ enum XCTStoryboardsSegue {
case Test = "test"
}
enum Message: String, StoryboardSegueType {
case CustomBack = "CustomBack"
case Embed = "Embed"
case NonCustom = "NonCustom"
case CustomBack
case Embed
case NonCustom
case Show_NavCtrl = "Show-NavCtrl"
}
enum Wizard: String, StoryboardSegueType {
case ShowPassword = "ShowPassword"
case ShowPassword
}
}
9 changes: 4 additions & 5 deletions Tests/Expected/Storyboards-iOS/lowercase-context-all.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,12 @@ enum StoryboardSegue {
case Test = "test"
}
enum Message: String, StoryboardSegueType {
case CustomBack = "CustomBack"
case Embed = "Embed"
case NonCustom = "NonCustom"
case CustomBack
case Embed
case NonCustom
case Show_NavCtrl = "Show-NavCtrl"
}
enum Wizard: String, StoryboardSegueType {
case ShowPassword = "ShowPassword"
case ShowPassword
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,12 @@ enum XCTStoryboardsSegue {
case Test = "test"
}
enum Message: String, StoryboardSegueType {
case CustomBack = "CustomBack"
case Embed = "Embed"
case NonCustom = "NonCustom"
case CustomBack
case Embed
case NonCustom
case Show_NavCtrl = "Show-NavCtrl"
}
enum Wizard: String, StoryboardSegueType {
case ShowPassword = "ShowPassword"
case ShowPassword
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,3 @@ extension UIViewController {
}

// No storyboard found

3 changes: 1 addition & 2 deletions Tests/Expected/Storyboards-iOS/swift3-context-all.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ enum StoryboardScene {

enum StoryboardSegue {
enum AdditionalImport: String, StoryboardSegueType {
case test = "test"
case test
}
enum Message: String, StoryboardSegueType {
case customBack = "CustomBack"
Expand All @@ -183,4 +183,3 @@ enum StoryboardSegue {
case showPassword = "ShowPassword"
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ enum XCTStoryboardsScene {

enum XCTStoryboardsSegue {
enum AdditionalImport: String, StoryboardSegueType {
case test = "test"
case test
}
enum Message: String, StoryboardSegueType {
case customBack = "CustomBack"
Expand All @@ -183,4 +183,3 @@ enum XCTStoryboardsSegue {
case showPassword = "ShowPassword"
}
}

1 change: 0 additions & 1 deletion Tests/Expected/Storyboards-iOS/swift3-context-empty.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,3 @@ extension UIViewController {
}

// No storyboard found

29 changes: 14 additions & 15 deletions Tests/Expected/Storyboards-iOS/uppercase-context-all.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ enum StoryboardScene {
return vc
}

case SomeSlackViewControllerInstance = "SomeSlackViewControllerInstance"
case SomeSlackViewControllerInstance
static func someSlackViewControllerInstanceViewController() -> SlackTextViewController.SLKTextViewController {
guard let vc = StoryboardScene.AdditionalImport.SomeSlackViewControllerInstance.viewController() as? SlackTextViewController.SLKTextViewController
else {
Expand All @@ -77,20 +77,20 @@ enum StoryboardScene {
enum Dependency: String, StoryboardSceneType {
static let storyboardName = "Dependency"

case Dependent = "Dependent"
case Dependent
static func dependentViewController() -> UIViewController {
return StoryboardScene.Dependency.Dependent.viewController()
}
}
enum Message: String, StoryboardSceneType {
static let storyboardName = "Message"

case Composer = "Composer"
case Composer
static func composerViewController() -> UIViewController {
return StoryboardScene.Message.Composer.viewController()
}

case MessagesList = "MessagesList"
case MessagesList
static func messagesListViewController() -> UITableViewController {
guard let vc = StoryboardScene.Message.MessagesList.viewController() as? UITableViewController
else {
Expand All @@ -99,7 +99,7 @@ enum StoryboardScene {
return vc
}

case NavCtrl = "NavCtrl"
case NavCtrl
static func navCtrlViewController() -> UINavigationController {
guard let vc = StoryboardScene.Message.NavCtrl.viewController() as? UINavigationController
else {
Expand All @@ -108,7 +108,7 @@ enum StoryboardScene {
return vc
}

case URLChooser = "URLChooser"
case URLChooser
static func urlChooserViewController() -> XXPickerViewController {
guard let vc = StoryboardScene.Message.URLChooser.viewController() as? XXPickerViewController
else {
Expand All @@ -120,7 +120,7 @@ enum StoryboardScene {
enum Placeholder: String, StoryboardSceneType {
static let storyboardName = "Placeholder"

case Navigation = "Navigation"
case Navigation
static func navigationViewController() -> UINavigationController {
guard let vc = StoryboardScene.Placeholder.Navigation.viewController() as? UINavigationController
else {
Expand All @@ -144,7 +144,7 @@ enum StoryboardScene {
return StoryboardScene.Wizard.Accept_CGU.viewController()
}

case CreateAccount = "CreateAccount"
case CreateAccount
static func createAccountViewController() -> CreateAccViewController {
guard let vc = StoryboardScene.Wizard.CreateAccount.viewController() as? CreateAccViewController
else {
Expand All @@ -153,7 +153,7 @@ enum StoryboardScene {
return vc
}

case Preferences = "Preferences"
case Preferences
static func preferencesViewController() -> UITableViewController {
guard let vc = StoryboardScene.Wizard.Preferences.viewController() as? UITableViewController
else {
Expand All @@ -162,7 +162,7 @@ enum StoryboardScene {
return vc
}

case Validate_Password = "Validate_Password"
case Validate_Password
static func validatePasswordViewController() -> UIViewController {
return StoryboardScene.Wizard.Validate_Password.viewController()
}
Expand All @@ -174,13 +174,12 @@ enum StoryboardSegue {
case Test = "test"
}
enum Message: String, StoryboardSegueType {
case CustomBack = "CustomBack"
case Embed = "Embed"
case NonCustom = "NonCustom"
case CustomBack
case Embed
case NonCustom
case Show_NavCtrl = "Show-NavCtrl"
}
enum Wizard: String, StoryboardSegueType {
case ShowPassword = "ShowPassword"
case ShowPassword
}
}

29 changes: 14 additions & 15 deletions Tests/Expected/Storyboards-iOS/uppercase-context-customname.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ enum XCTStoryboardsScene {
return vc
}

case SomeSlackViewControllerInstance = "SomeSlackViewControllerInstance"
case SomeSlackViewControllerInstance
static func someSlackViewControllerInstanceViewController() -> SlackTextViewController.SLKTextViewController {
guard let vc = XCTStoryboardsScene.AdditionalImport.SomeSlackViewControllerInstance.viewController() as? SlackTextViewController.SLKTextViewController
else {
Expand All @@ -77,20 +77,20 @@ enum XCTStoryboardsScene {
enum Dependency: String, StoryboardSceneType {
static let storyboardName = "Dependency"

case Dependent = "Dependent"
case Dependent
static func dependentViewController() -> UIViewController {
return XCTStoryboardsScene.Dependency.Dependent.viewController()
}
}
enum Message: String, StoryboardSceneType {
static let storyboardName = "Message"

case Composer = "Composer"
case Composer
static func composerViewController() -> UIViewController {
return XCTStoryboardsScene.Message.Composer.viewController()
}

case MessagesList = "MessagesList"
case MessagesList
static func messagesListViewController() -> UITableViewController {
guard let vc = XCTStoryboardsScene.Message.MessagesList.viewController() as? UITableViewController
else {
Expand All @@ -99,7 +99,7 @@ enum XCTStoryboardsScene {
return vc
}

case NavCtrl = "NavCtrl"
case NavCtrl
static func navCtrlViewController() -> UINavigationController {
guard let vc = XCTStoryboardsScene.Message.NavCtrl.viewController() as? UINavigationController
else {
Expand All @@ -108,7 +108,7 @@ enum XCTStoryboardsScene {
return vc
}

case URLChooser = "URLChooser"
case URLChooser
static func urlChooserViewController() -> XXPickerViewController {
guard let vc = XCTStoryboardsScene.Message.URLChooser.viewController() as? XXPickerViewController
else {
Expand All @@ -120,7 +120,7 @@ enum XCTStoryboardsScene {
enum Placeholder: String, StoryboardSceneType {
static let storyboardName = "Placeholder"

case Navigation = "Navigation"
case Navigation
static func navigationViewController() -> UINavigationController {
guard let vc = XCTStoryboardsScene.Placeholder.Navigation.viewController() as? UINavigationController
else {
Expand All @@ -144,7 +144,7 @@ enum XCTStoryboardsScene {
return XCTStoryboardsScene.Wizard.Accept_CGU.viewController()
}

case CreateAccount = "CreateAccount"
case CreateAccount
static func createAccountViewController() -> CreateAccViewController {
guard let vc = XCTStoryboardsScene.Wizard.CreateAccount.viewController() as? CreateAccViewController
else {
Expand All @@ -153,7 +153,7 @@ enum XCTStoryboardsScene {
return vc
}

case Preferences = "Preferences"
case Preferences
static func preferencesViewController() -> UITableViewController {
guard let vc = XCTStoryboardsScene.Wizard.Preferences.viewController() as? UITableViewController
else {
Expand All @@ -162,7 +162,7 @@ enum XCTStoryboardsScene {
return vc
}

case Validate_Password = "Validate_Password"
case Validate_Password
static func validatePasswordViewController() -> UIViewController {
return XCTStoryboardsScene.Wizard.Validate_Password.viewController()
}
Expand All @@ -174,13 +174,12 @@ enum XCTStoryboardsSegue {
case Test = "test"
}
enum Message: String, StoryboardSegueType {
case CustomBack = "CustomBack"
case Embed = "Embed"
case NonCustom = "NonCustom"
case CustomBack
case Embed
case NonCustom
case Show_NavCtrl = "Show-NavCtrl"
}
enum Wizard: String, StoryboardSegueType {
case ShowPassword = "ShowPassword"
case ShowPassword
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,3 @@ extension UIViewController {
}

// No storyboard found

Loading

0 comments on commit 28be61a

Please # to comment.