Skip to content

joaompfe/scalafix-rules

Repository files navigation

Scalafix Rules WIP!!!

Linters

UnsafeIterableOps

List(1).head /* assert: UnsafeIterableOps
^^^^^^^^^^^^
  .head is unsafe, consider .headOption */

List(1).tail /* assert: UnsafeIterableOps
^^^^^^^^^^^^
  .tail is unsafe, consider .drop(1) */

List(1).minBy(identity) /* assert: UnsafeIterableOps
^^^^^^^^^^^^^
  .minBy is unsafe, consider .minByOption */

Rewrites

OptionBool

val x: Option[Boolean] = ???

- x.fold(true)(f)
+ a x.forall(f)

- x.fold(false)(f)
+ x.exists(f)

Backlog

  • name boolean arguments, except in standard functions such as Option#getOrElse
  • name arguments in applications with more than X arguments (and sort them alphabetically optionally)
  • rewrite trivial cases of UnsafeIterableOps such as if (xs.empty) None else Some(xs.minBy(f)), if (xs.size == 1) None else Some(xs.min)
  • suspicious sort before fold where the associativity of the operator isn't obvious

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages