Comments (6)
I checked out SwiftLint's source to debug the issue a bit and found the cause: SwiftLintCore.SwiftVersion
does not compare string versions reliably, preventing version-specific workarounds from being applied.
SwiftLint/Source/SwiftLintCore/Models/SwiftVersion.swift
Lines 5 to 17 in 6d2e582
For Swift 5.10, version-specific workarounds are not applied correctly. Specifically, LintableFilesVisitor.parallel
is assigned true
instead of false
when SwiftVersion.current < .fiveDotSix
returns an incorrect value.
SwiftLint/Source/swiftlint/Helpers/LintableFilesVisitor.swift
Lines 99 to 108 in 6d2e582
I replaced SwiftVersion
with the following:
/// A value describing the version of the Swift compiler.
public struct SwiftVersion: RawRepresentable, Codable, Comparable, Sendable {
public typealias RawValue = String
public let rawValue: String
public init(rawValue: String) {
self.rawValue = rawValue
}
public static func < (lhs: SwiftVersion, rhs: SwiftVersion) -> Bool {
func versionComponents(from version: String) -> [Int] {
return version.components(separatedBy: ".").compactMap { Int($0) }
}
let lhsComponents = versionComponents(from: lhs.rawValue)
let rhsComponents = versionComponents(from: rhs.rawValue)
for (lhsComponent, rhsComponent) in zip(lhsComponents, rhsComponents) {
if lhsComponent < rhsComponent {
return true
} else if lhsComponent > rhsComponent {
return false
}
}
return lhsComponents.count < rhsComponents.count
}
}
Note: I used Claude to implement static func < (lhs:rhs:)
. I wanted to save time while troubleshooting. The implementation may or may not handle edge cases correctly. I only verified the implementation for my environment.
With the changes in place, I'm able to run swiftlint analyze
on a larger set of files. The run below was limited to 30 files. I also verified the result on a run with 350+ files.
Analyzing Swift files in current working directory
Collecting 'Modules/Sources/StyleGuide/_exported.swift' (1/30)
Collecting 'SomethingsWrong.swift' (2/30)
Collecting 'ToolbarMenuButton.swift' (3/30)
Collecting 'ShowInMusicMenuButton.swift' (4/30)
Collecting 'View+hidden.swift' (5/30)
Collecting 'View+foregroundStyle.swift' (6/30)
Collecting 'View+dimensionOverlay.swift' (7/30)
Collecting 'View+enabled.swift' (8/30)
Collecting 'View+firstTextCenterline.swift' (9/30)
Collecting 'HeaderTitle.swift' (10/30)
Collecting 'ExplicitTitle.swift' (11/30)
Collecting 'LabelStyle.swift' (12/30)
Collecting 'StyleGuide.swift' (13/30)
Collecting 'ActiveTrackIcon.swift' (14/30)
Collecting 'FontPreview.swift' (15/30)
Collecting 'CountsView.swift' (16/30)
Collecting 'NoSearchResults.swift' (17/30)
Collecting 'LibraryIcon.swift' (18/30)
Collecting 'PresentationState.swift' (19/30)
Collecting 'AlertPresentation.swift' (20/30)
Collecting 'ConfirmationDialogPresentation.swift' (21/30)
Collecting 'Symbol.swift' (22/30)
Collecting 'SearchControllerProxy.swift' (23/30)
Collecting 'EnvironmentAction.swift' (24/30)
Collecting 'Resolvable.swift' (25/30)
Collecting 'SearchableUIHostingController.swift' (26/30)
Collecting 'SearchScope.swift' (27/30)
Collecting 'RelativeTimeframe.swift' (28/30)
Collecting 'SimilarityResult.swift' (29/30)
Collecting 'Counts.swift' (30/30)
Analyzing 'Modules/Sources/StyleGuide/_exported.swift' (1/30)
Analyzing 'SomethingsWrong.swift' (2/30)
Analyzing 'ToolbarMenuButton.swift' (3/30)
Analyzing 'ShowInMusicMenuButton.swift' (4/30)
Analyzing 'View+hidden.swift' (5/30)
Analyzing 'View+foregroundStyle.swift' (6/30)
Analyzing 'View+dimensionOverlay.swift' (7/30)
Analyzing 'View+enabled.swift' (8/30)
Analyzing 'View+firstTextCenterline.swift' (9/30)
Analyzing 'HeaderTitle.swift' (10/30)
Analyzing 'ExplicitTitle.swift' (11/30)
Analyzing 'LabelStyle.swift' (12/30)
Analyzing 'StyleGuide.swift' (13/30)
Analyzing 'ActiveTrackIcon.swift' (14/30)
Analyzing 'FontPreview.swift' (15/30)
Analyzing 'CountsView.swift' (16/30)
Analyzing 'NoSearchResults.swift' (17/30)
Analyzing 'LibraryIcon.swift' (18/30)
Analyzing 'PresentationState.swift' (19/30)
Analyzing 'AlertPresentation.swift' (20/30)
Analyzing 'ConfirmationDialogPresentation.swift' (21/30)
Analyzing 'Symbol.swift' (22/30)
Analyzing 'SearchControllerProxy.swift' (23/30)
Analyzing 'EnvironmentAction.swift' (24/30)
Analyzing 'Resolvable.swift' (25/30)
Analyzing 'SearchableUIHostingController.swift' (26/30)
Analyzing 'SearchScope.swift' (27/30)
Analyzing 'RelativeTimeframe.swift' (28/30)
Analyzing 'SimilarityResult.swift' (29/30)
Analyzing 'Counts.swift' (30/30)
Done analyzing! Found 0 violations, 0 serious in 30 files.
from swiftlint.
Can the stop of analysis be associated with a specific file maybe?
from swiftlint.
Can the stop of analysis be associated with a specific file maybe?
I started my troubleshooting by adjusting included
and excluded
to find a problematic file. I started with a small number of files and gradually included more files until the issue occurred. I thought I found the problematic file. I added more files and noticed the issue again. I tested different combinations and realized I could move "problematic" files from excluded
to included
without triggering the issue. As long as I keep the file count very low, the command finished. As soon as I added an extra file, the command chokes.
from swiftlint.
Forget my previous question. You were obviously a little faster with the detailed report of your investigation. I didn't notice it while crafting my message.
Your reasoning makes a lot of sense. Looks like SwiftVersion
wasn't developed with version components >9 in mind or the implementors didn't expect such high numbers.
Would you like to open a PR to fix the comparison algorithm?
from swiftlint.
Yes, I will prepare a PR with a fix for the comparison algorithm. Appreciate the quick responses!
from swiftlint.
I'm seeing the exact same thing. For me it stops after 14 files, no matter what file that is.
from swiftlint.
Related Issues (20)
- [unused_declaration] Unused class/struct is not detected if it conforms to a protocol in extension
- Feature request: Add an (opt in) update check to SwiftLint HOT 2
- Dogfood Baselines internally HOT 5
- ShorthandOptionalBinding Rule not working? HOT 3
- Rule Request: Newline between function, array, dictionary, tuple parameters HOT 2
- There is a problem with allowed_symbols rule configuration after updating to 0.54.0 HOT 1
- 0.55.0 is broken without blzmod HOT 2
- 0.55.0: Static Over Final Class warning occurs on overridable class property HOT 6
- unneeded_override breaks fixes for "Automatic Initializer Inheritance" HOT 7
- [0.55.0] False positive on unused_enumerated with block + destructuring
- unneeded_synthesized_initializer removes needed initializers if there is any other initializer enclosed within conditional macro
- 0.55.0 not published to Bazel Central Registry HOT 2
- Latest releases (0.54.0 and 0.55.0) are not available via Homebrew HOT 6
- opening_brace triggers when the brace is preceded by a comment
- `trailing_closure` rule disagrees with Swift 5.8 forward-scan matching HOT 3
- Upgrading to 0.55.1 through Homebrew fails HOT 2
- MARK Rule hitting on "marketing"
- Report and Improvements on Swiftlint baseline HOT 8
- `opening_brace` fix is broken
- The baseline use absolute path instead of relative file in the baseline content to identify a file HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftlint.