Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update swiftlint to 0.57.0 #49

Merged
merged 2 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
uses: swift-actions/setup-swift@v2.1.0
- name: Install SwiftLint
run: |
curl -L https://github.com/realm/SwiftLint/releases/download/0.54.0/swiftlint_linux.zip -o swiftlint.zip
curl -L https://github.com/realm/SwiftLint/releases/download/0.57.0/swiftlint_linux.zip -o swiftlint.zip
unzip swiftlint.zip -d swiftlint
./swiftlint/swiftlint --version
- name: Run SwiftLint
Expand Down
8 changes: 4 additions & 4 deletions Sources/SwiftBeanCountTax/TaxCalculator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public enum TaxCalculator {
return try issuers.compactMap { issuer throws -> TaxSlip? in
let issuerTaxSlipRelevantAccounts = taxSlipRelevantAccounts.filter { $0.metaData[MetaDataKeys.issuer] ?? "" == issuer }
// collect all transactions which have a posting to a split account AND an account for this issuer
var splitTransactions = taxYearTransactions.filter { $0.postings.contains { issuerTaxSlipRelevantAccounts.map { $0.name }.contains($0.accountName) }
&& $0.postings.contains { splitAccounts.map { $0.0 }.contains($0.accountName.fullName) }
var splitTransactions = taxYearTransactions.filter { $0.postings.contains { issuerTaxSlipRelevantAccounts.map(\.name).contains($0.accountName) }
&& $0.postings.contains { splitAccounts.map(\.0).contains($0.accountName.fullName) }
}
let entries = issuerTaxSlipRelevantAccounts.flatMap { account -> [TaxSlipEntry] in
let postings = taxYearTransactions.flatMap { $0.postings.filter { $0.accountName == account.name } }
Expand All @@ -146,10 +146,10 @@ public enum TaxCalculator {
// split accounts
entries.append(contentsOf: splitAccounts.compactMap { splitAccount -> TaxSlipEntry? in
// filter splitTransactions for transactions for the current account, and get the posting to the split account
let splitPostings = splitTransactions.filter { [account.name.fullName, splitAccount.0].allSatisfy($0.postings.map { $0.accountName.fullName }.contains) }
let splitPostings = splitTransactions.filter { [account.name.fullName, splitAccount.0].allSatisfy($0.postings.map(\.accountName.fullName).contains) }
.flatMap { $0.postings.filter { $0.accountName.fullName == splitAccount.0 } }
// rmove the processed transactions - otherwise when a transaction has multiple accounts and a split account, it would be counted multiple times
splitTransactions.removeAll { [account.name.fullName, splitAccount.0].allSatisfy($0.postings.map { $0.accountName.fullName }.contains) }
splitTransactions.removeAll { [account.name.fullName, splitAccount.0].allSatisfy($0.postings.map(\.accountName.fullName).contains) }
if let (value, originalValue) = getValues(commodity: commodity, postings: splitPostings) {
return TaxSlipEntry(symbol: symbol, name: name, box: splitAccount.1, value: value, originalValue: originalValue)
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/SwiftBeanCountTax/TaxSlip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public struct TaxSlip: Identifiable {

/// Boxes which have a value on the slip
public var boxes: [String] {
Array(Set(entries.map { $0.box })).sorted(by: boxNumberSort)
Array(Set(entries.map(\.box))).sorted(by: boxNumberSort)
}

/// If a slip is split by symbols (e.g. stocks), this contains the list of symbols, otherwise is is empty
Expand Down Expand Up @@ -166,7 +166,7 @@ extension TaxSlipRow: CustomStringConvertible {
}

public var description: String {
"\(displayName != nil ? "\(displayName!):\n" : "")\(values.sorted(by: rowValueBoxNumberSort).map { $0.description }.joined(separator: "\n") )"
"\(displayName != nil ? "\(displayName!):\n" : "")\(values.sorted(by: rowValueBoxNumberSort).map(\.description).joined(separator: "\n") )"
}
}

Expand All @@ -193,7 +193,7 @@ extension TaxSlip: CustomStringConvertible {
}

public var description: String {
"\(header)\n\(rows.map { $0.description }.joined(separator: "\n"))\(symbols.isEmpty ? "" : "\nSum:\n\(sumRow.description)")"
"\(header)\n\(rows.map(\.description).joined(separator: "\n"))\(symbols.isEmpty ? "" : "\nSum:\n\(sumRow.description)")"
}
}

Expand Down
Loading