Skip to content
This repository has been archived by the owner on Nov 11, 2021. It is now read-only.

UseOptionForeachNotPatMatch false positive? #57

Open
benblack86 opened this issue Apr 19, 2017 · 0 comments
Open

UseOptionForeachNotPatMatch false positive? #57

benblack86 opened this issue Apr 19, 2017 · 0 comments

Comments

@benblack86
Copy link

Can't write this code using foreach since it is using tailrec. Can't think of another way to write this without using null.

  @tailrec
  final def tick(name: String, time: FiniteDuration): Unit =
    Option(times.putIfAbsent(name, time)) match { // linter:ignore UseOptionForeachNotPatMatch
      case None =>
      case Some(oldValue) =>
        if (!times.replace(name, oldValue, oldValue + time)) {
          tick(name, time)
        }
    }
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant