warn if a companion object of a case class is referenced in a stand-alone fashion#5
Open
jrudolph wants to merge 2 commits intojorgeortiz85:masterfrom
Open
warn if a companion object of a case class is referenced in a stand-alone fashion#5jrudolph wants to merge 2 commits intojorgeortiz85:masterfrom
jrudolph wants to merge 2 commits intojorgeortiz85:masterfrom
Conversation
…lone fashion This happens easily when writing actor based code where you often have a set of messages defined like this: case class Start(arg: Int) case object Stop If you now use `Start` without the argument in pattern matches (like in `receive`) or message sends (`self ! Start`) your code may fail silently because you are sending the companion object around which is rarely what you want to do.
Contributor
Author
|
Applying this to my own projects, this has still too many false positives. The problem is that there often is a valid use of companion objects i.e. as the constructor for the case class. Do you have an idea how you could check if the tree in question is in a parameter position of an |
|
Why not make this warning actor-specific? I agree there are too many legitimate uses otherwise. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This happens easily when writing actor based code where you often have a set of
messages defined like this:
case class Start(arg: Int)
case object Stop
If you now use
Startwithout the argument in pattern matches (like inreceive) ormessage sends (
self ! Start) your code may fail silently because you are sending thecompanion object around which is rarely what you want to do.