File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Sources/SwiftDependencyAuditLib
Tests/SwiftDependencyAuditTests Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,11 @@ public actor ImportScanner {
3535 }
3636 }
3737 ZeroOrMore ( . whitespace)
38+ // Handle trailing comments
39+ ZeroOrMore {
40+ " // "
41+ ZeroOrMore ( . anyNonNewline)
42+ }
3843 Anchor . endOfLine
3944 }
4045
Original file line number Diff line number Diff line change @@ -192,4 +192,19 @@ struct ImportScannerTests {
192192 let testableImport = imports. first { $0. moduleName == " TestableModule " }
193193 #expect( testableImport? . isTestable == true )
194194 }
195+
196+ @Test ( " Trailing comments on imports " )
197+ func testTrailingCommentsOnImports( ) async throws {
198+ let scanner = ImportScanner ( )
199+ let content = """
200+ import RegularModule // A trailing comment
201+ """
202+
203+ let imports = await scanner. scanContent ( content)
204+
205+ // Foundation should be filtered out, leaving 6 custom modules
206+ #expect( imports. count == 1 )
207+ let moduleNames = Set ( imports. map { $0. moduleName } )
208+ #expect( moduleNames. contains ( " RegularModule " ) )
209+ }
195210}
You can’t perform that action at this time.
0 commit comments