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

Forbid the usage of property #5122

Closed
BraisGabin opened this issue Jul 23, 2022 · 2 comments
Closed

Forbid the usage of property #5122

BraisGabin opened this issue Jul 23, 2022 · 2 comments

Comments

@BraisGabin
Copy link
Member

Expected Behavior of the rule

Forbid the usage of a property like the same way we have ForbiddenMethodCall.

Context

When you are using functions like combine, zip or similar ones Pair and Triple are really handy classes if then you continue using it with destructuring declarations. BUT if you access it data using first, second or third those classes are really bad because they give you 0 information about what you are accessing.

For that reason I think that forbid the usage of Pair.first, Pair.second, Triple.first... would be beneficial.

Example:

This is ok:

listOf("Robb", "Sansa", "Arya", "Brandon", "Rickon", "John")
  .zip("Grey Wind", "Lady", "Nymeria", "Summer", "Shaggy Dog", "Ghost")
  .map { (child, wolve) -> println("$child owns $wolve") }

This is not ok

listOf("Robb", "Sansa", "Arya", "Brandon", "Rickon", "John")
  .zip("Grey Wind", "Lady", "Nymeria", "Summer", "Shaggy Dog", "Ghost")
  .map { println("${it.first} owns ${it.second}") }

The reason of this proposal: #5058 (comment)

Related issue: #5015 we talked a bit about this topic there.

@github-actions
Copy link

This issue is stale because it has been open 90 days with no activity. Please comment or this will be closed in 7 days.

@github-actions github-actions bot added the stale label Oct 22, 2022
@cortinico
Copy link
Member

Closing as this was discussed here:
#5015
and effectively implement
#5078

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants