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 unusedPrivateDeclaration rule #284

Merged
merged 4 commits into from
Aug 7, 2024

Conversation

mannylopez
Copy link
Contributor

@mannylopez mannylopez commented Aug 1, 2024

Summary

This PR adds rule unusedPrivateDeclaration to remove unused private and fileprivate properties, functions, and typealiases.

// WRONG: Includes private declarations that are unused
struct Planet {
  var ageInBillionYears: Double {
    ageInMillionYears / 1000
  }

  private var ageInMillionsOfYears: Double
  private typealias Dependencies = UniverseBuilderProviding // unused
  private var mass: Double // unused
  private func distance(to: Planet) { } // unused
}

// RIGHT
struct Planet {
  var ageInBillionsOfYears: Double {
    ageInMillionYears / 1000
  }

  private var ageInMillionYears: Double
}

Reasoning

Improves readability since the code has no effect and should be removed for clarity.

README.md Outdated Show resolved Hide resolved
Copy link
Member

@calda calda left a comment

Choose a reason for hiding this comment

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

Excited about this one, nice work @mannylopez!

@calda calda enabled auto-merge (squash) August 7, 2024 16:49
@calda calda merged commit 633fc25 into master Aug 7, 2024
5 checks passed
@calda calda deleted the manny-lopez--add-unusedPrivateDeclaration branch August 7, 2024 16:50
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