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 UnusedDeclarationRule #2814

Merged
merged 4 commits into from
Jul 19, 2019
Merged

Add UnusedDeclarationRule #2814

merged 4 commits into from
Jul 19, 2019

Conversation

jpsim
Copy link
Collaborator

@jpsim jpsim commented Jul 18, 2019

This PR adds a new unused_declaration analyzer rule to lint for unused declarations.
By default, detects unused fileprivate, private and internal declarations.
Configure the rule with include_public_and_open: true to also detect unused public and open declarations.

Completely remove the unused_private_declaration rule.

This is built on the work enabling collecting rule infrastructure in #2714.

@SwiftLintBot
Copy link

SwiftLintBot commented Jul 18, 2019

1 Warning
⚠️ Big PR
12 Messages
📖 Linting Aerial with this PR took 4.17s vs 2.78s on master (50% slower)
📖 Linting Alamofire with this PR took 7.63s vs 5.45s on master (39% slower)
📖 Linting Firefox with this PR took 20.36s vs 13.85s on master (47% slower)
📖 Linting Kickstarter with this PR took 26.92s vs 24.65s on master (9% slower)
📖 Linting Moya with this PR took 2.73s vs 2.66s on master (2% slower)
📖 Linting Nimble with this PR took 2.46s vs 2.27s on master (8% slower)
📖 Linting Quick with this PR took 0.94s vs 0.79s on master (18% slower)
📖 Linting Realm with this PR took 4.05s vs 4.02s on master (0% slower)
📖 Linting SourceKitten with this PR took 1.51s vs 1.54s on master (1% faster)
📖 Linting Sourcery with this PR took 4.96s vs 4.94s on master (0% slower)
📖 Linting Swift with this PR took 37.82s vs 38.02s on master (0% faster)
📖 Linting WordPress with this PR took 31.1s vs 31.27s on master (0% faster)

Generated by 🚫 Danger

Copy link
Collaborator

@keith keith left a comment

Choose a reason for hiding this comment

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

amazing!


// Classes marked as @UIApplicationMain are used by the operating system as the entry point into the app.
if let annotatedDecl = cursorInfo["key.annotated_decl"] as? String,
annotatedDecl.contains("@UIApplicationMain") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we add @objcMembers in this same spot?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good question. You could still have unused @objcMembers classes though.

I'm inclined to still treat those as violations until someone requests otherwise.

@jpsim jpsim force-pushed the unused-declaration-rule branch from 6381063 to 69bc07b Compare July 18, 2019 22:05
@jpsim jpsim changed the base branch from emw_2431_collecting_rule to master July 18, 2019 22:05
@jpsim jpsim force-pushed the unused-declaration-rule branch from e2ec411 to 9a4a8c7 Compare July 18, 2019 22:27
@jpsim jpsim merged commit e63e8ca into master Jul 19, 2019
@jpsim jpsim deleted the unused-declaration-rule branch July 19, 2019 01:23
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