Skip to content

Commit

Permalink
Setup SwiftLint to run locally (#697)
Browse files Browse the repository at this point in the history
  • Loading branch information
mokagio authored Nov 7, 2022
2 parents f6be0c8 + 2badf37 commit 964b007
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ Pods/
fastlane/README.md
fastlane/report.xml
fastlane/test_output

# SwiftLint Remote Config Cache
.swiftlint/RemoteConfigCache
2 changes: 2 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
parent_config: https://raw.githubusercontent.com/Automattic/swiftlint-config/0f8ab6388bd8d15a04391825ab125f80cfb90704/.swiftlint.yml
remote_timeout: 10.0
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Why is there a `Makefile` when we already have a `Fastfile` in this project?
#
# Because when running Ruby code (i.e. `bundle exec fastlane <lane>`) from
# within an Xcode build phase, Xcode will use a shell different from the user's
# and with system Ruby where Bundler and Fastlane may or may not be available.
# `make` on the other hand, is always available, therefore `make lint` can be
# reliably called from both the user's terminal, Xcode, and CI.
SWIFTLINT=./Pods/SwiftLint/swiftlint

lint:
$(SWIFTLINT) lint --quiet

format:
$(SWIFTLINT) lint --autocorrect --quiet
33 changes: 23 additions & 10 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,30 @@ target 'WordPressAuthenticatorTests' do
pod 'OCMock', '~> 3.4'
pod 'Expecta', '1.0.6'
pod 'Specta', '1.0.7'
end

# Used to donwload CLI tools.
abstract_target 'Tools' do
pod 'SwiftLint', '~> 0.49'
end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |configuration|
# Let Pods targets inherit deployment target from the app
# This solution is suggested here: https://github.com/CocoaPods/CocoaPods/issues/4859
pod_ios_deployment_target = Gem::Version.new(configuration.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
configuration.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET' if pod_ios_deployment_target <= ios_deployment_target

post_install do |installer|
# Let Pods targets inherit deployment target from the app
# This solution is suggested here: https://github.com/CocoaPods/CocoaPods/issues/4859
# =====================================
#
installer.pods_project.targets.each do |target|
target.build_configurations.each do |configuration|
pod_ios_deployment_target = Gem::Version.new(configuration.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
configuration.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET' if pod_ios_deployment_target <= ios_deployment_target
end
# This addresses Xcode 12, 13, and 14 showing an "Update to recommended
# settings" warning on the Pods project.
#
# See:
#
# - https://github.com/CocoaPods/CocoaPods/issues/10189
# - https://github.com/CocoaPods/CocoaPods/issues/11553
configuration.build_settings.delete 'ARCHS'
configuration.build_settings['DEAD_CODE_STRIPPING'] = 'YES'
end
end
end
6 changes: 5 additions & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ PODS:
- OCMock (3.8.1)
- Specta (1.0.7)
- SVProgressHUD (2.2.5)
- SwiftLint (0.49.1)
- UIDeviceIdentifier (1.6.0)
- WordPressKit (4.24.0):
- Alamofire (~> 4.8.0)
Expand All @@ -49,6 +50,7 @@ DEPENDENCIES:
- OCMock (~> 3.4)
- Specta (= 1.0.7)
- SVProgressHUD (= 2.2.5)
- SwiftLint (~> 0.49)
- WordPressKit (~> 4.18-beta)
- WordPressShared (~> 1.12-beta)
- WordPressUI (~> 1.7-beta)
Expand All @@ -69,6 +71,7 @@ SPEC REPOS:
- OCMock
- Specta
- SVProgressHUD
- SwiftLint
- UIDeviceIdentifier
- WordPressKit
- WordPressShared
Expand All @@ -90,12 +93,13 @@ SPEC CHECKSUMS:
OCMock: 29f6e52085b4e7d9b075cbf03ed7c3112f82f934
Specta: 3e1bd89c3517421982dc4d1c992503e48bd5fe66
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
SwiftLint: 32ee33ded0636d0905ef6911b2b67bbaeeedafa5
UIDeviceIdentifier: f4bf3b343581a1beacdbf5fb1a8825bd5f05a4a4
WordPressKit: ee58e3d313ddce1f768e87d76364d261ad86fca9
WordPressShared: 38cb62e9cb998d4dc3c1611f17934c6875a6b3e8
WordPressUI: 1cf47a3b78154faf69caa18569ee7ece1e510fa0
wpxmlrpc: bf55a43a7e710bd2a4fb8c02dfe83b1246f14f13

PODFILE CHECKSUM: a1020c109a62537b5751fddc9375bacd6c45db78
PODFILE CHECKSUM: 4aeaf3c769fe14a1696e9e1c42b609b7e9f8858c

COCOAPODS: 1.11.3
22 changes: 21 additions & 1 deletion WordPressAuthenticator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 52;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -1013,6 +1013,7 @@
B5ED78F0207E976500A8FD8C /* Frameworks */,
B5ED78F2207E976500A8FD8C /* Resources */,
B5A5274B20B479D30065BE81 /* CopyFiles */,
3FCF8AA329111BD200E64F8D /* Lint */,
);
buildRules = (
);
Expand Down Expand Up @@ -1131,6 +1132,25 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
3FCF8AA329111BD200E64F8D /* Lint */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = Lint;
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "make lint\n";
};
6CD6648B820552D8638F8EDA /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class AuthenticatorAnalyticsTracker {
///
case loginWithSiteAddress = "login_site_address"

/// This flow starts when the user wants to troubleshoot their site by inputting its address
/// This flow starts when the user wants to troubleshoot their site by inputting its address
///
case siteDiscovery = "site_discovery"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,14 +557,14 @@ import WordPressKit

public extension WordPressAuthenticator {

func getAppleIDCredentialState(for userID: String, completion: @escaping (ASAuthorizationAppleIDProvider.CredentialState, Error?) -> Void) {
func getAppleIDCredentialState(for userID: String, completion: @escaping (ASAuthorizationAppleIDProvider.CredentialState, Error?) -> Void) {
AppleAuthenticator.sharedInstance.getAppleIDCredentialState(for: userID) { (state, error) in
// If credentialState == .notFound, error will have a value.
completion(state, error)
}
}

func startObservingAppleIDCredentialRevoked(completion: @escaping () -> Void) {
func startObservingAppleIDCredentialRevoked(completion: @escaping () -> Void) {
appleIDCredentialObserver = NotificationCenter.default.addObserver(forName: AppleAuthenticator.credentialRevokedNotification, object: nil, queue: nil) { (_) in
completion()
}
Expand Down
2 changes: 1 addition & 1 deletion WordPressAuthenticator/Logging/CocoaLumberjack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import CocoaLumberjack

// June 14 2017 - @astralbodies
// Taken from CocoaLumberjack repository - reproduced to prevent issue with
// Taken from CocoaLumberjack repository - reproduced to prevent issue with
// CocoaPods and some weird bug with frameworks

// Software License Agreement (BSD License)
Expand Down
2 changes: 1 addition & 1 deletion WordPressAuthenticator/Navigation/NavigationCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation

/// NavigationCommand abstracts logic necessary provide clients of this library
/// with a way to navigate to a particular location in the UL navigation flow.
///
///
/// Concrete implementations of this protocol will decide what that means
///
public protocol NavigationCommand {
Expand Down
5 changes: 4 additions & 1 deletion WordPressAuthenticator/Signin/LoginWPComViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ class LoginWPComViewController: LoginViewController, NUXKeyboardResponder {
return NSLocalizedString("To proceed with this Google account, please first log in with your WordPress.com password. This will only be asked once.", comment: "")
}

return NSLocalizedString("Please enter the password for your WordPress.com account to log in with your Apple ID.", comment: "")
return NSLocalizedString(
"Please enter the password for your WordPress.com account to log in with your Apple ID.",
comment: "Instructional text shown when requesting the user's password for a login initiated via Sign In with Apple"
)
}()

passwordField?.placeholder = NSLocalizedString("Password", comment: "Password placeholder")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class SignupEmailViewController: LoginViewController, NUXKeyboardResponder {

// MARK: - Email Availability

private func checkEmailAvailability(completion:@escaping (Bool) -> Void) {
private func checkEmailAvailability(completion: @escaping (Bool) -> Void) {

let remote = AccountServiceRemoteREST(
wordPressComRestApi: WordPressComRestApi(baseUrlString: WordPressAuthenticator.shared.configuration.wpcomAPIBaseURL))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ class PasswordViewController: LoginViewController {
// is the actual error string. So check for "password" in the error string, and show the custom
// error message. Otherwise, show the actual response error.
var displayMessage: String {
// swiftlint:disable localization_comment
if nsError.localizedDescription.contains(NSLocalizedString("password", comment: "")) {
// swiftlint:enable localization_comment
return NSLocalizedString("It seems like you've entered an incorrect password. Want to give it another try?", comment: "An error message shown when a wpcom user provides the wrong password.")
}
return nsError.localizedDescription
Expand Down

0 comments on commit 964b007

Please sign in to comment.