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 a rule to flag places where emptyList (and similar) can be used #2850

Closed
veyndan opened this issue Jul 5, 2020 · 3 comments · Fixed by #2864
Closed

Add a rule to flag places where emptyList (and similar) can be used #2850

veyndan opened this issue Jul 5, 2020 · 3 comments · Fixed by #2864
Assignees
Milestone

Comments

@veyndan
Copy link
Contributor

veyndan commented Jul 5, 2020

Kotlin provides the functions emptyArray, emptyList, emptyMap, emptySequence, and emptySet to improve the readability of instantiating an empty "collection".

Expected Behavior of the rule

The below can also be applied to the other "empty" variations.

Noncompliant Code

val strs = listOf<String>()

Compliant Code

val strs = emptyList<String>()
@schalkms
Copy link
Member

schalkms commented Jul 12, 2020

Okay, that's a good idea for a new rule.
@veyndan may I ask you to take a stab at this?

@veyndan
Copy link
Contributor Author

veyndan commented Jul 12, 2020

Sure thing! Feel free to assign me to this ticket 😄

@BraisGabin
Copy link
Member

Done!

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

Successfully merging a pull request may close this issue.

4 participants