-
Notifications
You must be signed in to change notification settings - Fork 216
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 RemovableMatchChecker #62
Conversation
👍 I have a suggestion for one more case:
|
Sounds good. But I found some bug of the checker. |
Conflicts: src/main/scala/org/scalastyle/scalariform/RemovableMatchChecker.scala
I don't think that this is the right approach for Scalastyle. For instance we can never guarantee that someone won't create a function called map or foreach, which this would then apply to. I think this sort of check would be better as a compiler plugin or similar. |
I've now added this check to Linter (a static analysis compiler plugin): HairyFotr/linter@ae17ec4 |
Ok, I got it. @HairyFotr |
This check fits better into Linter than into Scalastyle. If you really wish to add this rule to Scalastyle, then you can add it as an external rule. See #25. This isn't implemented at the minute, but would be fairly easy to do. |
Co-authored-by: Michael Wizner <mwz@users.noreply.github.com>
Add checker to detect whether match statement is removable or not.
This checker finds removable "match" statements for collections.
Effective Scala suggests to use pattern matching directly in function definitions if possible.
For example, the checker accepts
but rejects
This helps to write pattern matchings clearly.