Skip to content

[UnusedImportRule] Handle comments after the import statement#2993

Merged
jpsim merged 8 commits into
masterfrom
unusedimportrule-handle-comments-after-the-import-statement
Dec 18, 2019
Merged

[UnusedImportRule] Handle comments after the import statement#2993
jpsim merged 8 commits into
masterfrom
unusedimportrule-handle-comments-after-the-import-statement

Conversation

@jpsim

@jpsim jpsim commented Dec 17, 2019

Copy link
Copy Markdown
Collaborator

Fixes #2990

@SwiftLintBot

SwiftLintBot commented Dec 17, 2019

Copy link
Copy Markdown
12 Messages
📖 Linting Aerial with this PR took 1.23s vs 1.21s on master (1% slower)
📖 Linting Alamofire with this PR took 2.21s vs 2.22s on master (0% faster)
📖 Linting Firefox with this PR took 8.95s vs 8.82s on master (1% slower)
📖 Linting Kickstarter with this PR took 14.34s vs 14.33s on master (0% slower)
📖 Linting Moya with this PR took 1.17s vs 1.13s on master (3% slower)
📖 Linting Nimble with this PR took 1.36s vs 1.38s on master (1% faster)
📖 Linting Quick with this PR took 0.54s vs 0.53s on master (1% slower)
📖 Linting Realm with this PR took 2.38s vs 2.35s on master (1% slower)
📖 Linting SourceKitten with this PR took 0.99s vs 0.98s on master (1% slower)
📖 Linting Sourcery with this PR took 6.65s vs 6.64s on master (0% slower)
📖 Linting Swift with this PR took 12.14s vs 12.15s on master (0% faster)
📖 Linting WordPress with this PR took 14.63s vs 14.55s on master (0% slower)

Generated by 🚫 Danger

Comment thread Source/SwiftLintFramework/Rules/Lint/UnusedImportRule.swift Outdated
@kastiglione

Copy link
Copy Markdown
Contributor

I replied here #2993 (comment) but that thread is marked resolved so may not be visible @jpsim.

@kastiglione kastiglione left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

// https://bugs.swift.org/browse/SR-11099
// When we require Swift 5.2 or later to build SwiftLint we can switch this back.
// let pattern = #"^(@.+\s+)?import\s+\#(module)\b.*?\n"#
let pattern = "^(@.+\\s+)?import\\s+\(module)\\b.*?\\n"

@kastiglione kastiglione Dec 18, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In surprised that \n needs escaping

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Unescaped in efc7504.

@jpsim jpsim merged commit 9ecefbd into master Dec 18, 2019
@jpsim jpsim deleted the unusedimportrule-handle-comments-after-the-import-statement branch December 18, 2019 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unused imports crashes on import statements with trailing comment

3 participants