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

Same rule, different behaviour #6

Open
NeQuissimus opened this issue Sep 13, 2018 · 0 comments
Open

Same rule, different behaviour #6

NeQuissimus opened this issue Sep 13, 2018 · 0 comments

Comments

@NeQuissimus
Copy link

Bringing this over from scalacenter/scalafix#865

I have a code snippet in one of my tests (which is why I am allowing Option#get)

  def databaseConfig(labels: NonEmptyString): DatabaseConfig =
    DatabaseConfig(
      NonEmptyString.from(postgresUrl).toOption.get,
      NonEmptyString.from(postgresUser).toOption.get, // scalafix:ok Disable.get
      Password(NonEmptyString.from(postgresPassword).toOption.get), // scalafix:ok Disable.get
      Tables(labels)
    )

It seems to only work with this set of scalafix annotations.
I would have expected each and every one of the .get calls to need // scalafix:ok Disable.get.
If I place it on the first one, I get

[warn] /home/nequi/dev/project/src/test/scala/Spec.scala:60:69: warning: [UnusedScalafixSuppression] Unused Scalafix suppression. This can be removed
[warn]       NonEmptyString.from(postgresUrl).toOption.get, // scalafix:ok Disable.get

If I take them all away, I get

[error] /home/nequi/dev/project/src/test/scala/Spec.scala:61:50: error: [Disable.get] not a total function
[error]       NonEmptyString.from(postgresUser).toOption.get,
[error]                                                  ^^^
[error] /home/nequi/dev/project/src/test/scala/Spec.scala:62:63: error: [Disable.get] not a total function
[error]       Password(NonEmptyString.from(postgresPassword).toOption.get),

It seems rather confusing that the first call to .get is not caught and hence behaves differently from subsequent ones.
Note that I have only ever seen this in calls to .apply functions. If I were to apply the three values to vals beforehand, I would get Scalafix warnings for all three.

I am using Scalafix 0.6.0-M16 here. (I know it's not stable, but this is how I can send you issue reports :D)

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

No branches or pull requests

1 participant