Skip to content

Commit

Permalink
Rely on SPM plugins to consume SwiftLint and SwiftFormat
Browse files Browse the repository at this point in the history
Use their latest releases and fix some violations and issues.
  • Loading branch information
SimplyDanny committed Nov 24, 2024
1 parent ba1a811 commit 80e5cf4
Show file tree
Hide file tree
Showing 36 changed files with 121 additions and 134 deletions.
13 changes: 11 additions & 2 deletions .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
blankLinesAroundMark, \
blankLinesAtEndOfScope, \
blankLinesAtStartOfScope, \
blankLinesBetweenChainedFunctions, \
# blankLinesBetweenImports, \
blankLinesBetweenScopes, \
blockComments, \
Expand All @@ -32,6 +33,7 @@
extensionAccessControl, \
fileHeader, \
# genericExtensions, \
headerFileName, \
hoistPatternLet, \
indent, \
initCoderUnavailable, \
Expand All @@ -41,9 +43,11 @@
linebreaks, \
modifierOrder, \
# markTypes, \
noExplicitOwnership, \
numberFormatting, \
# opaqueGenericParameters, \
# organizeDeclarations, \
# preferForLoop, \
preferKeyPath, \
redundantBackticks, \
redundantBreak, \
Expand All @@ -52,6 +56,7 @@
redundantFileprivate, \
redundantGet, \
redundantInit, \
redundantInternal, \
redundantLet, \
redundantLetError, \
redundantNilInit, \
Expand All @@ -62,11 +67,13 @@
redundantRawValues, \
redundantReturn, \
redundantSelf, \
redundantStaticSelf, \
redundantType, \
redundantVoidReturnType, \
semicolons, \
sortedImports, \
sortedSwitchCases, \
sortImports, \
sortSwitchCases, \
sortTypealiases, \
spaceAroundBraces, \
spaceAroundBrackets, \
spaceAroundComments, \
Expand All @@ -93,6 +100,8 @@
wrapAttributes, \
wrapConditionalBodies, \
# wrapEnumCases, \
wrapLoopBodies, \
wrapMultilineConditionalAssignment, \
# wrapMultilineStatementBraces, \
wrapSingleLineComments, \
# wrapSwitchCases, \
Expand Down
8 changes: 6 additions & 2 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ excluded:
- go
- Pods
- vendor
- xcode

## Active rules

Expand All @@ -15,8 +16,8 @@ opt_in_rules:

disabled_rules:
- anonymous_argument_in_multiline_closure
- anyobject_protocol # Deprecated.
- balanced_xctest_lifecycle
- contrasted_opening_brace
- discouraged_none_name
- discouraged_object_literal
- discouraged_optional_collection # Too many false positives in implementations of system protocols.
Expand All @@ -40,10 +41,12 @@ disabled_rules:
- legacy_objc_type
- line_length
- missing_docs
- no_empty_block # To be fixed later.
- no_extension_access_modifier
- no_grouping_extension
- no_magic_numbers # Causes a lot of violations in tests.
- number_separator # Contradicts with SwiftFormat rule 'decimalgrouping'. There are not many numbers anyway in the source code.
- one_declaration_per_file
- prefer_nimble
- prefixed_toplevel_constant # Violations are mostly in test code.
- private_outlet
Expand All @@ -66,6 +69,8 @@ attributes:
closure_body_length:
warning: 40
error: 60
explicit_init:
include_bare_init: true
identifier_name:
excluded: ["id", "to", "Defaults"]
allowed_symbols: ["_"]
Expand All @@ -80,4 +85,3 @@ trailing_comma:
xct_specific_matcher:
matchers:
- two-argument-asserts

30 changes: 24 additions & 6 deletions pass.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
DC4914961E434301007FF592 /* LabelTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4914941E434301007FF592 /* LabelTableViewCell.swift */; };
DC4914991E434600007FF592 /* PasswordDetailTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4914981E434600007FF592 /* PasswordDetailTableViewController.swift */; };
DC5F385B1E56AADB00C69ACA /* PGPKeyArmorImportTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC5F385A1E56AADB00C69ACA /* PGPKeyArmorImportTableViewController.swift */; };
DC8963C01E38EEB900828B09 /* SSHKeyURLImportTableViewController..swift in Sources */ = {isa = PBXBuildFile; fileRef = DC8963BF1E38EEB900828B09 /* SSHKeyURLImportTableViewController..swift */; };
DC8963C01E38EEB900828B09 /* SSHKeyURLImportTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC8963BF1E38EEB900828B09 /* SSHKeyURLImportTableViewController.swift */; };
DC917BD71E2E8231000FDF54 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC917BD61E2E8231000FDF54 /* AppDelegate.swift */; };
DC917BDC1E2E8231000FDF54 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DC917BDA1E2E8231000FDF54 /* Main.storyboard */; };
DC917BDE1E2E8231000FDF54 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DC917BDD1E2E8231000FDF54 /* Assets.xcassets */; };
Expand Down Expand Up @@ -496,7 +496,7 @@
DC4914941E434301007FF592 /* LabelTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelTableViewCell.swift; sourceTree = "<group>"; };
DC4914981E434600007FF592 /* PasswordDetailTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordDetailTableViewController.swift; sourceTree = "<group>"; };
DC5F385A1E56AADB00C69ACA /* PGPKeyArmorImportTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PGPKeyArmorImportTableViewController.swift; sourceTree = "<group>"; };
DC8963BF1E38EEB900828B09 /* SSHKeyURLImportTableViewController..swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SSHKeyURLImportTableViewController..swift; sourceTree = "<group>"; };
DC8963BF1E38EEB900828B09 /* SSHKeyURLImportTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SSHKeyURLImportTableViewController.swift; sourceTree = "<group>"; };
DC917BD31E2E8231000FDF54 /* Pass.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Pass.app; sourceTree = BUILT_PRODUCTS_DIR; };
DC917BD61E2E8231000FDF54 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
DC917BDB1E2E8231000FDF54 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
Expand Down Expand Up @@ -982,7 +982,7 @@
DC037CA91E4B8EAE00609409 /* SpecialThanksTableViewController.swift */,
DCC441531E916382008A90C4 /* SSHKeyArmorImportTableViewController.swift */,
30650E7023F82AF8005CCD5E /* SSHKeyFileImportTableViewController.swift */,
DC8963BF1E38EEB900828B09 /* SSHKeyURLImportTableViewController..swift */,
DC8963BF1E38EEB900828B09 /* SSHKeyURLImportTableViewController.swift */,
);
path = Controllers;
sourceTree = "<group>";
Expand Down Expand Up @@ -1361,6 +1361,8 @@
9A1F47F826E5CF4B000C0E01 /* XCRemoteSwiftPackageReference "OneTimePassword" */,
30ED1775276F8842009BA876 /* XCRemoteSwiftPackageReference "objective-git-swift-package" */,
9A2C7D802782CB2F00BD9AF3 /* XCRemoteSwiftPackageReference "yubikit-ios" */,
307CA2312CF346D40099F6DE /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */,
307CA2322CF348260099F6DE /* XCRemoteSwiftPackageReference "SwiftFormat" */,
);
productRefGroup = DC917BD41E2E8231000FDF54 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -1478,7 +1480,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = ". \"${SRCROOT}/scripts/swiftformat.sh\"\n";
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";
};
308800C124EB0D3600E87ED3 /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -1497,7 +1499,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = ". \"${SRCROOT}/scripts/swiftlint.sh\"\n";
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\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 \"$SWIFTLINT_CMD\" 2>&1\nthen\n \"$SWIFTLINT_CMD\" lint --fix\n \"$SWIFTLINT_CMD\" lint\nelse\n echo \"warning: `swiftlint` command not found\"\nfi\n";
};
9A996C4726DDEAF100A4485D /* Remove SPM Duplicate Frameworks */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -1661,7 +1663,7 @@
DCC441541E916382008A90C4 /* SSHKeyArmorImportTableViewController.swift in Sources */,
306D970E24091CDD006C0E2E /* SwitchTableViewCell.swift in Sources */,
A2A61C201EEFABAD00CFE063 /* UtilsExtension.swift in Sources */,
DC8963C01E38EEB900828B09 /* SSHKeyURLImportTableViewController..swift in Sources */,
DC8963C01E38EEB900828B09 /* SSHKeyURLImportTableViewController.swift in Sources */,
DC30F83829BED4E2001EB12B /* PasswordGeneratorUISwitch.swift in Sources */,
9AFC87F025B514AD008D6060 /* PasswordDecryptor.swift in Sources */,
3066AD6823EE0D6500F65535 /* PGPKeyImporter.swift in Sources */,
Expand Down Expand Up @@ -2846,6 +2848,22 @@
minimumVersion = 0.99.2;
};
};
307CA2312CF346D40099F6DE /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/SimplyDanny/SwiftLintPlugins.git";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.57.0;
};
};
307CA2322CF348260099F6DE /* XCRemoteSwiftPackageReference "SwiftFormat" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/nicklockwood/SwiftFormat";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.55.2;
};
};
30A3000C26DA62F4002A734E /* XCRemoteSwiftPackageReference "Base32" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/mattrubin/Base32";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"originHash" : "cfd99fa2de57765d4ea0531870a48806df8e3971c39177b2ec90b24da2c77efb",
"pins" : [
{
"identity" : "base32",
Expand Down Expand Up @@ -53,6 +54,24 @@
"revision" : "8d59e4abba762d0f1e9aed161081f7b3fe21daa0"
}
},
{
"identity" : "swiftformat",
"kind" : "remoteSourceControl",
"location" : "https://github.com/nicklockwood/SwiftFormat",
"state" : {
"revision" : "eb55d16245567e99d18ea871a7609befc8210c46",
"version" : "0.55.2"
}
},
{
"identity" : "swiftlintplugins",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SimplyDanny/SwiftLintPlugins.git",
"state" : {
"revision" : "7c80ce6f142164b0201871e580b021d1b2c69804",
"version" : "0.57.0"
}
},
{
"identity" : "swiftyuserdefaults",
"kind" : "remoteSourceControl",
Expand All @@ -72,5 +91,5 @@
}
}
],
"version" : 2
"version" : 3
}
2 changes: 1 addition & 1 deletion pass/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

lazy var passcodeLockPresenter: PasscodeLockPresenter = .init(mainWindow: self.window)
lazy var passcodeLockPresenter = PasscodeLockPresenter(mainWindow: self.window)

func application(_: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
Expand Down
2 changes: 1 addition & 1 deletion pass/Controllers/AboutRepositoryTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController {
private static let VALUE_NOT_AVAILABLE = "ValueNotAvailable".localize()

private var needRefresh = false
private var indicator: UIActivityIndicatorView = .init(style: .medium)
private var indicator = UIActivityIndicatorView(style: .medium)

private let passwordStore = PasswordStore.shared

Expand Down
5 changes: 0 additions & 5 deletions pass/Controllers/BasicStaticTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ class BasicStaticTableViewController: UITableViewController, MFMailComposeViewCo
tableData[section].count
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

override func tableView(_: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cellData = tableData[indexPath.section][indexPath.row]
let cellDataStyle = cellData[CellDataKey.style] as? CellDataStyle
Expand Down
6 changes: 3 additions & 3 deletions pass/Controllers/KeyImporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ protocol KeyImporter {

extension KeyImporter {
static var isCurrentKeySource: Bool {
Defaults.gitSSHKeySource == Self.keySource
Defaults.gitSSHKeySource == keySource
}

static var menuLabel: String {
if isCurrentKeySource {
return "\(Self.label)"
return "\(label)"
}
return Self.label
return label
}
}
1 change: 1 addition & 0 deletions pass/Controllers/PGPKeyFIleImportTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class PGPKeyFileImportTableViewController: AutoCellHeightUITableViewController,
private var privateKey: String?

private enum KeyType { case none, `private`, `public` }

private var currentlyPicking = KeyType.none

@IBAction
Expand Down
2 changes: 1 addition & 1 deletion pass/Controllers/PGPKeyImporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ protocol PGPKeyImporter: KeyImporter {

extension PGPKeyImporter {
static var isCurrentKeySource: Bool {
Defaults.pgpKeySource == Self.keySource
Defaults.pgpKeySource == keySource
}

func doAfterImport() {}
Expand Down
2 changes: 1 addition & 1 deletion pass/Controllers/PasswordDetailTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
// preserve path so it can be reloaded even if the passwordEntity is deleted during the update process
private var passwordPath: String?

private lazy var editUIBarButtonItem: UIBarButtonItem = .init(barButtonSystemItem: .edit, target: self, action: #selector(pressEdit))
private lazy var editUIBarButtonItem = UIBarButtonItem(barButtonSystemItem: .edit, target: self, action: #selector(pressEdit))

private struct TableSection {
var type: PasswordDetailTableViewControllerSectionType
Expand Down
10 changes: 0 additions & 10 deletions pass/Views/PasswordDetailTitleTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,4 @@ class PasswordDetailTitleTableViewCell: UITableViewCell {
@IBOutlet var passwordImageImageView: UIImageView!
@IBOutlet var labelImageConstraint: NSLayoutConstraint!
@IBOutlet var labelCellConstraint: NSLayoutConstraint!

override func awakeFromNib() {
super.awakeFromNib()
}

override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)

// Configure the view for the selected state
}
}
Loading

0 comments on commit 80e5cf4

Please sign in to comment.