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

Add new type-safe ArrayInitRule #3914

Merged
merged 1 commit into from
Mar 23, 2022

Conversation

SimplyDanny
Copy link
Collaborator

The idea of this new Analyzer rule is to filter the calls of map before they are passed on to the classic ArrayInitRule which does the detailed checking of the lambda function block. The rule makes sure that only the map function is considered that is defined by the Sequence protocol.

This new rule provides a fix for #3749.

@SwiftLintBot
Copy link

SwiftLintBot commented Mar 22, 2022

12 Messages
📖 Linting Aerial with this PR took 0.98s vs 0.98s on master (0% slower)
📖 Linting Alamofire with this PR took 1.11s vs 1.11s on master (0% slower)
📖 Linting Firefox with this PR took 4.17s vs 4.13s on master (0% slower)
📖 Linting Kickstarter with this PR took 7.46s vs 7.42s on master (0% slower)
📖 Linting Moya with this PR took 4.39s vs 4.39s on master (0% slower)
📖 Linting Nimble with this PR took 0.4s vs 0.4s on master (0% slower)
📖 Linting Quick with this PR took 0.17s vs 0.17s on master (0% slower)
📖 Linting Realm with this PR took 9.88s vs 9.9s on master (0% faster)
📖 Linting SourceKitten with this PR took 0.33s vs 0.33s on master (0% slower)
📖 Linting Sourcery with this PR took 2.01s vs 2.02s on master (0% faster)
📖 Linting Swift with this PR took 3.15s vs 3.15s on master (0% slower)
📖 Linting WordPress with this PR took 7.42s vs 7.41s on master (0% slower)

Generated by 🚫 Danger

Copy link
Collaborator

@jpsim jpsim left a comment

Choose a reason for hiding this comment

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

Always great to see more analyzer rules!

import Foundation
import SourceKittenFramework

public struct TypesafeArrayInitRule: AnalyzerRule, ConfigurationProviderRule, OptInRule, AutomaticTestableRule {
Copy link
Collaborator

Choose a reason for hiding this comment

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

All analyzer rules are opt-in

Suggested change
public struct TypesafeArrayInitRule: AnalyzerRule, ConfigurationProviderRule, OptInRule, AutomaticTestableRule {
public struct TypesafeArrayInitRule: AnalyzerRule, ConfigurationProviderRule, AutomaticTestableRule {

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wonder whether redundant protocol conformances could be flagged by yet another analyzer rule. 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not a big deal, just redundant. I think a pre-typechecked lint rule would be sufficient though.

CHANGELOG.md Outdated Show resolved Hide resolved
@jpsim
Copy link
Collaborator

jpsim commented Mar 23, 2022

Feel free to merge after you've considered my feedback.

@jpsim jpsim mentioned this pull request Mar 23, 2022
2 tasks
The idea of this new Analyzer rule is to filter the calls of `map` before they are passed on to the classic ArrayInitRule which does the detailed checking of the lambda function block. The rule makes sure that only the `map` function is considered that is defined by the `Sequence` protocol.
@SimplyDanny SimplyDanny merged commit a801bbc into realm:master Mar 23, 2022
@SimplyDanny SimplyDanny deleted the typesafe-array-init-rule branch March 23, 2022 21:29
coffmark pushed a commit to coffmark/SwiftLint that referenced this pull request Apr 11, 2022
The idea of this new Analyzer rule is to filter the calls of `map` before they are passed on to the classic ArrayInitRule which does the detailed checking of the lambda function block. The rule makes sure that only the `map` function is considered that is defined by the `Sequence` protocol.
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.

3 participants