Skip to content

Handle module selectors in syntactic_sugar - #6953

Open
gxlactuss wants to merge 1 commit into
realm:mainfrom
gxlactuss:syntactic-sugar-module-selectors
Open

gxlactuss wants to merge 1 commit into
realm:mainfrom
gxlactuss:syntactic-sugar-module-selectors

Conversation

@gxlactuss

Copy link
Copy Markdown

Refs #6924.

syntactic_sugar only looked at the type name, so Foo::Array<Int> was reported and --fix rewrote it to [Int], even though Foo::Array is a different type. It also missed Swift::Array<Int>() in expressions, because the expression check read the first token (the module name) instead of the base name.

Now a type with a module selector other than Swift:: is skipped, and Swift:: is treated like Swift.. Generic arguments are still checked, so Foo::Array<Array<Int>> reports the inner Array<Int>.

I added non-triggering examples for Foo:: types and expressions, and triggering ones for Swift:: types and expressions. swift test --filter SyntacticSugarRuleGeneratedTests passes.

Types like `Foo::Array<Int>` come from another module, so they are no longer reported or corrected to `[Int]`. `Swift::Array<Int>()` in expressions is now reported like `Swift.Array<Int>()`.
@SwiftLintBot

Copy link
Copy Markdown
20 Messages
📖 Building this branch resulted in a binary size of 28771.79 KiB vs 28755.54 KiB when built on main (0% larger).
📖 Linting Aerial with this PR took 0.68 s vs 0.68 s on main (0% slower).
📖 Linting Alamofire with this PR took 0.97 s vs 0.98 s on main (1% faster).
📖 Linting Brave with this PR took 5.53 s vs 5.5 s on main (0% slower).
📖 Linting Brigade with this PR took 18.07 s vs 18.28 s on main (1% faster).
📖 Linting DuckDuckGo with this PR took 33.69 s vs 33.46 s on main (0% slower).
📖 Linting Firefox with this PR took 11.74 s vs 11.78 s on main (0% faster).
📖 Linting Kickstarter with this PR took 7.31 s vs 7.36 s on main (0% faster).
📖 Linting Moya with this PR took 0.38 s vs 0.38 s on main (0% slower).
📖 Linting NetNewsWire with this PR took 2.58 s vs 2.59 s on main (0% faster).
📖 Linting Nimble with this PR took 0.55 s vs 0.55 s on main (0% slower).
📖 Linting PocketCasts with this PR took 7.38 s vs 7.44 s on main (0% faster).
📖 Linting Quick with this PR took 0.36 s vs 0.36 s on main (0% slower).
📖 Linting Realm with this PR took 2.98 s vs 2.98 s on main (0% slower).
📖 Linting Sourcery with this PR took 1.63 s vs 1.61 s on main (1% slower).
📖 Linting Swift with this PR took 4.61 s vs 4.61 s on main (0% slower).
📖 Linting SwiftLintPerformanceTests with this PR took 0.18 s vs 0.19 s on main (5% faster).
📖 Linting VLC with this PR took 1.43 s vs 1.44 s on main (0% faster).
📖 Linting Wire with this PR took 16.56 s vs 16.61 s on main (0% faster).
📖 Linting WordPress with this PR took 10.67 s vs 10.67 s on main (0% slower).

Generated by 🚫 Danger

This branch has not been deployed

No deployments
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.

2 participants