Skip to content

Commit 1bdf9d6

Browse files
committed
Rely on SPM plugins to consume SwiftLint and SwiftFormat
Use their latest releases and fix some violations and issues. # Conflicts: # .github/workflows/linting.yml # .github/workflows/testing.yml
1 parent 358908f commit 1bdf9d6

40 files changed

+125
-185
lines changed

.github/workflows/deploying.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ jobs:
2121
- name: Installing packages
2222
run: |
2323
brew update
24-
brew install carthage swiftformat
24+
brew install carthage
2525
brew install go || brew link --overwrite go
26-
brew install swiftlint || brew link --overwrite swiftlint
2726
gem install bundler
2827
- uses: actions/cache@v3
2928
id: carthage-cache

.github/workflows/linting.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/testing.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ jobs:
1414
- name: Installing packages
1515
run: |
1616
brew update
17-
brew install carthage swiftformat
18-
brew install go@1.20 || brew link --overwrite go
19-
brew install swiftlint || brew link --overwrite swiftlint
17+
brew install carthage
18+
brew install go || brew link --overwrite go
2019
gem install bundler
2120
- uses: actions/cache@v3
2221
id: carthage-cache

.swiftformat

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
blankLinesAroundMark, \
2020
blankLinesAtEndOfScope, \
2121
blankLinesAtStartOfScope, \
22+
blankLinesBetweenChainedFunctions, \
2223
# blankLinesBetweenImports, \
2324
blankLinesBetweenScopes, \
2425
blockComments, \
@@ -32,6 +33,7 @@
3233
extensionAccessControl, \
3334
fileHeader, \
3435
# genericExtensions, \
36+
headerFileName, \
3537
hoistPatternLet, \
3638
indent, \
3739
initCoderUnavailable, \
@@ -41,9 +43,11 @@
4143
linebreaks, \
4244
modifierOrder, \
4345
# markTypes, \
46+
noExplicitOwnership, \
4447
numberFormatting, \
4548
# opaqueGenericParameters, \
4649
# organizeDeclarations, \
50+
# preferForLoop, \
4751
preferKeyPath, \
4852
redundantBackticks, \
4953
redundantBreak, \
@@ -52,6 +56,7 @@
5256
redundantFileprivate, \
5357
redundantGet, \
5458
redundantInit, \
59+
redundantInternal, \
5560
redundantLet, \
5661
redundantLetError, \
5762
redundantNilInit, \
@@ -62,11 +67,13 @@
6267
redundantRawValues, \
6368
redundantReturn, \
6469
redundantSelf, \
70+
redundantStaticSelf, \
6571
redundantType, \
6672
redundantVoidReturnType, \
6773
semicolons, \
68-
sortedImports, \
69-
sortedSwitchCases, \
74+
sortImports, \
75+
sortSwitchCases, \
76+
sortTypealiases, \
7077
spaceAroundBraces, \
7178
spaceAroundBrackets, \
7279
spaceAroundComments, \
@@ -93,6 +100,8 @@
93100
wrapAttributes, \
94101
wrapConditionalBodies, \
95102
# wrapEnumCases, \
103+
wrapLoopBodies, \
104+
wrapMultilineConditionalAssignment, \
96105
# wrapMultilineStatementBraces, \
97106
wrapSingleLineComments, \
98107
# wrapSwitchCases, \

.swiftlint.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ excluded:
77
- go
88
- Pods
99
- vendor
10+
- xcode
1011

1112
## Active rules
1213

@@ -15,8 +16,8 @@ opt_in_rules:
1516

1617
disabled_rules:
1718
- anonymous_argument_in_multiline_closure
18-
- anyobject_protocol # Deprecated.
1919
- balanced_xctest_lifecycle
20+
- contrasted_opening_brace
2021
- discouraged_none_name
2122
- discouraged_object_literal
2223
- discouraged_optional_collection # Too many false positives in implementations of system protocols.
@@ -40,10 +41,12 @@ disabled_rules:
4041
- legacy_objc_type
4142
- line_length
4243
- missing_docs
44+
- no_empty_block # To be fixed later.
4345
- no_extension_access_modifier
4446
- no_grouping_extension
4547
- no_magic_numbers # Causes a lot of violations in tests.
4648
- number_separator # Contradicts with SwiftFormat rule 'decimalgrouping'. There are not many numbers anyway in the source code.
49+
- one_declaration_per_file
4750
- prefer_nimble
4851
- prefixed_toplevel_constant # Violations are mostly in test code.
4952
- private_outlet
@@ -66,6 +69,8 @@ attributes:
6669
closure_body_length:
6770
warning: 40
6871
error: 60
72+
explicit_init:
73+
include_bare_init: true
6974
identifier_name:
7075
excluded: ["id", "to", "Defaults"]
7176
allowed_symbols: ["_"]
@@ -80,4 +85,3 @@ trailing_comma:
8085
xct_specific_matcher:
8186
matchers:
8287
- two-argument-asserts
83-

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ For more, please read the [wiki page](https://github.com/mssun/passforios/wiki).
4747

4848
## Building Pass for iOS
4949

50-
1. Install Carthage, Go, SwiftLint, and SwiftFormat: `brew install carthage go swiftlint swiftformat`.
50+
1. Install Carthage and Go: `brew install carthage go`.
5151
2. Install dependencies via Carthage. Therefore, execute `carthage bootstrap --platform iOS --use-xcframeworks` in the root directory of the project.
5252
3. Run `./scripts/gopenpgp_build.sh` to build GopenPGP.
5353
5. Open the `pass.xcodeproj` file in Xcode.

pass.xcodeproj/project.pbxproj

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
DC4914961E434301007FF592 /* LabelTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4914941E434301007FF592 /* LabelTableViewCell.swift */; };
200200
DC4914991E434600007FF592 /* PasswordDetailTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4914981E434600007FF592 /* PasswordDetailTableViewController.swift */; };
201201
DC5F385B1E56AADB00C69ACA /* PGPKeyArmorImportTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC5F385A1E56AADB00C69ACA /* PGPKeyArmorImportTableViewController.swift */; };
202-
DC8963C01E38EEB900828B09 /* SSHKeyURLImportTableViewController..swift in Sources */ = {isa = PBXBuildFile; fileRef = DC8963BF1E38EEB900828B09 /* SSHKeyURLImportTableViewController..swift */; };
202+
DC8963C01E38EEB900828B09 /* SSHKeyURLImportTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC8963BF1E38EEB900828B09 /* SSHKeyURLImportTableViewController.swift */; };
203203
DC917BD71E2E8231000FDF54 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC917BD61E2E8231000FDF54 /* AppDelegate.swift */; };
204204
DC917BDC1E2E8231000FDF54 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DC917BDA1E2E8231000FDF54 /* Main.storyboard */; };
205205
DC917BDE1E2E8231000FDF54 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DC917BDD1E2E8231000FDF54 /* Assets.xcassets */; };
@@ -496,7 +496,7 @@
496496
DC4914941E434301007FF592 /* LabelTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelTableViewCell.swift; sourceTree = "<group>"; };
497497
DC4914981E434600007FF592 /* PasswordDetailTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordDetailTableViewController.swift; sourceTree = "<group>"; };
498498
DC5F385A1E56AADB00C69ACA /* PGPKeyArmorImportTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PGPKeyArmorImportTableViewController.swift; sourceTree = "<group>"; };
499-
DC8963BF1E38EEB900828B09 /* SSHKeyURLImportTableViewController..swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SSHKeyURLImportTableViewController..swift; sourceTree = "<group>"; };
499+
DC8963BF1E38EEB900828B09 /* SSHKeyURLImportTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SSHKeyURLImportTableViewController.swift; sourceTree = "<group>"; };
500500
DC917BD31E2E8231000FDF54 /* Pass.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Pass.app; sourceTree = BUILT_PRODUCTS_DIR; };
501501
DC917BD61E2E8231000FDF54 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
502502
DC917BDB1E2E8231000FDF54 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
@@ -982,7 +982,7 @@
982982
DC037CA91E4B8EAE00609409 /* SpecialThanksTableViewController.swift */,
983983
DCC441531E916382008A90C4 /* SSHKeyArmorImportTableViewController.swift */,
984984
30650E7023F82AF8005CCD5E /* SSHKeyFileImportTableViewController.swift */,
985-
DC8963BF1E38EEB900828B09 /* SSHKeyURLImportTableViewController..swift */,
985+
DC8963BF1E38EEB900828B09 /* SSHKeyURLImportTableViewController.swift */,
986986
);
987987
path = Controllers;
988988
sourceTree = "<group>";
@@ -1361,6 +1361,8 @@
13611361
9A1F47F826E5CF4B000C0E01 /* XCRemoteSwiftPackageReference "OneTimePassword" */,
13621362
30ED1775276F8842009BA876 /* XCRemoteSwiftPackageReference "objective-git-swift-package" */,
13631363
9A2C7D802782CB2F00BD9AF3 /* XCRemoteSwiftPackageReference "yubikit-ios" */,
1364+
307CA2312CF346D40099F6DE /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */,
1365+
307CA2322CF348260099F6DE /* XCRemoteSwiftPackageReference "SwiftFormat" */,
13641366
);
13651367
productRefGroup = DC917BD41E2E8231000FDF54 /* Products */;
13661368
projectDirPath = "";
@@ -1478,7 +1480,7 @@
14781480
);
14791481
runOnlyForDeploymentPostprocessing = 0;
14801482
shellPath = /bin/sh;
1481-
shellScript = ". \"${SRCROOT}/scripts/swiftformat.sh\"\n";
1483+
shellScript = "SWIFT_PACKAGE_DIR=\"${BUILD_DIR%Build/*}SourcePackages/checkouts\"\nSWIFTFORMAT_CMD=\"$SWIFT_PACKAGE_DIR\"/SwiftFormat/CommandLineTool/swiftformat\n\nif [[ \"${CI}\" == \"true\" ]]; then\n echo \"Running in a Continuous Integration environment. Formatting is skipped.\"\n exit 0 \nfi\n\nif [[ \"${CONFIGURATION}\" == \"Release\" ]]; then\n echo \"Running during a release build. Formatting is skipped.\"\n exit 0\nfi\n\nif test -f \"$SWIFTFORMAT_CMD\" 2>&1\nthen\n \"$SWIFTFORMAT_CMD\" .\nelse\n echo \"warning: `swiftformat` command not found\"\nfi\n";
14821484
};
14831485
308800C124EB0D3600E87ED3 /* SwiftLint */ = {
14841486
isa = PBXShellScriptBuildPhase;
@@ -1497,7 +1499,7 @@
14971499
);
14981500
runOnlyForDeploymentPostprocessing = 0;
14991501
shellPath = /bin/sh;
1500-
shellScript = ". \"${SRCROOT}/scripts/swiftlint.sh\"\n";
1502+
shellScript = "SWIFT_PACKAGE_DIR=\"${BUILD_DIR%Build/*}SourcePackages/artifacts\"\nSWIFTLINT_CMD=$(ls \"$SWIFT_PACKAGE_DIR\"/swiftlintplugins/SwiftLintBinary/SwiftLintBinary.artifactbundle/swiftlint-*/bin/swiftlint | head -n 1)\n\nSTRICT_OPT=\n\nif [[ \"${CI}\" == \"true\" ]]; then\n echo \"Running in a Continuous Integration environment. Linting is strictly.\"\n STRICT_OPT=--strict\nfi\n\nif [[ \"${CONFIGURATION}\" == \"Release\" ]]; then\n echo \"Running during a release build. Linting is skipped.\"\n exit 0\nfi\n\nif test -f \"$SWIFTLINT_CMD\" 2>&1\nthen\n \"$SWIFTLINT_CMD\" lint --fix\n \"$SWIFTLINT_CMD\" lint $STRICT_OPT\nelse\n echo \"warning: `swiftlint` command not found\"\nfi\n";
15011503
};
15021504
9A996C4726DDEAF100A4485D /* Remove SPM Duplicate Frameworks */ = {
15031505
isa = PBXShellScriptBuildPhase;
@@ -1661,7 +1663,7 @@
16611663
DCC441541E916382008A90C4 /* SSHKeyArmorImportTableViewController.swift in Sources */,
16621664
306D970E24091CDD006C0E2E /* SwitchTableViewCell.swift in Sources */,
16631665
A2A61C201EEFABAD00CFE063 /* UtilsExtension.swift in Sources */,
1664-
DC8963C01E38EEB900828B09 /* SSHKeyURLImportTableViewController..swift in Sources */,
1666+
DC8963C01E38EEB900828B09 /* SSHKeyURLImportTableViewController.swift in Sources */,
16651667
DC30F83829BED4E2001EB12B /* PasswordGeneratorUISwitch.swift in Sources */,
16661668
9AFC87F025B514AD008D6060 /* PasswordDecryptor.swift in Sources */,
16671669
3066AD6823EE0D6500F65535 /* PGPKeyImporter.swift in Sources */,
@@ -2846,6 +2848,22 @@
28462848
minimumVersion = 0.99.2;
28472849
};
28482850
};
2851+
30333B292CF922D9008A2EA2 /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */ = {
2852+
isa = XCRemoteSwiftPackageReference;
2853+
repositoryURL = "https://github.com/SimplyDanny/SwiftLintPlugins.git";
2854+
requirement = {
2855+
kind = upToNextMinorVersion;
2856+
minimumVersion = 0.57.1;
2857+
};
2858+
};
2859+
307CA2322CF348260099F6DE /* XCRemoteSwiftPackageReference "SwiftFormat" */ = {
2860+
isa = XCRemoteSwiftPackageReference;
2861+
repositoryURL = "https://github.com/nicklockwood/SwiftFormat";
2862+
requirement = {
2863+
kind = upToNextMinorVersion;
2864+
minimumVersion = 0.55.2;
2865+
};
2866+
};
28492867
30A3000C26DA62F4002A734E /* XCRemoteSwiftPackageReference "Base32" */ = {
28502868
isa = XCRemoteSwiftPackageReference;
28512869
repositoryURL = "https://github.com/mattrubin/Base32";

pass.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 20 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pass/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2020

2121
var window: UIWindow?
2222

23-
lazy var passcodeLockPresenter: PasscodeLockPresenter = .init(mainWindow: self.window)
23+
lazy var passcodeLockPresenter = PasscodeLockPresenter(mainWindow: self.window)
2424

2525
func application(_: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2626
// Override point for customization after application launch.

pass/Controllers/AboutRepositoryTableViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController {
1313
private static let VALUE_NOT_AVAILABLE = "ValueNotAvailable".localize()
1414

1515
private var needRefresh = false
16-
private var indicator: UIActivityIndicatorView = .init(style: .medium)
16+
private var indicator = UIActivityIndicatorView(style: .medium)
1717

1818
private let passwordStore = PasswordStore.shared
1919

0 commit comments

Comments
 (0)