GithubHelp home page GithubHelp logo

wiringbits / wiringbits-scala-newbie-warts Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 0.0 19 KB

A collection of WartRemover warts for Scala newbies used by Wiringbits

License: MIT License

Scala 100.00%
scala wartremover cats-effect

wiringbits-scala-newbie-warts's Introduction

Wiringbits Scala Newbie Warts

Custom WartRemover warts from Wiringbits.

The collection intends to prevent common mistakes by developers that aren't very familiar with Scala.

For example, invoking UnsafeRunSync from cats-effect can lead to pretty bad application's behavior, with this library, you can prevent developers from invoking this method.

What's included

Cats Effect 2 Warts

  • net.wiringbits.warts.UnsafeRunSync: Emits a warning when unsafeRunSync is invoked.
  • net.wiringbits.warts.UnsafeRunAsyncAndForget: Emits a warning when unsafeRunAsyncAndForget is invoked.
  • net.wiringbits.warts.UnsafeRunAsync: Emits a warning when unsafeRunAsync is invoked.
  • net.wiringbits.warts.UnsafeRunCancelable: Emits a warning when unsafeRunCancelable is invoked.
  • net.wiringbits.warts.UnsafeRunTimed: Emits a warning when unsafeRunTimed is invoked.
  • net.wiringbits.warts.UnsafeToFuture: Emits a warning when unsafeToFuture is invoked.

Cats Effect 3 Warts

  • net.wiringbits.warts.UnsafeRunSync: Emits a warning when unsafeRunSync is invoked.
  • net.wiringbits.warts.UnsafeRunAndForget: Emits a warning when unsafeRunAndForget is invoked.
  • net.wiringbits.warts.UnsafeRunAsync: Emits a warning when unsafeRunAsync is invoked.
  • net.wiringbits.warts.UnsafeRunAsyncOutcome: Emits a warning when unsafeRunAsyncOutcome is invoked.
  • net.wiringbits.warts.UnsafeRunCancelable: Emits a warning when unsafeRunCancelable is invoked.
  • net.wiringbits.warts.UnsafeRunTimed: Emits a warning when unsafeRunTimed is invoked.
  • net.wiringbits.warts.UnsafeToFuture: Emits a warning when unsafeToFuture is invoked.
  • net.wiringbits.warts.UnsafeToFutureCancelable: Emits a warning when unsafeToFutureCancelable is invoked.

Usage

  • Be sure to use wartremover in your project.
  • Add the dependencies you are interested in:
// choose the modules you are interested in
lazy val wiringbitsWarts = List(
  "cats-effect-warts", // cats-effect 3
  "cats-effect2-warts" // cats-effect 2
)
libraryDependencies ++= wiringbitsWarts.map { customWart =>
  "net.wiringbits" %% customWart % "0.2.0" // pick the latest version
}
wartremoverClasspaths ++= {
  (Compile / dependencyClasspath).value.files
    .find(item => wiringbitsWarts.exists(item.name.contains))
    .map(_.toURI.toString)
    .toList
}
  • Enable the warts:
wartremoverWarnings += Wart.custom("net.wiringbits.warts.UnsafeRunSync")
  • Enable all unsafe warts:
wartremoverWarnings += Wart.custom("net.wiringbits.warts.Unsafe")

It is recommended to turn these warnings into errors when building the project in the CI.

wiringbits-scala-newbie-warts's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

wiringbits-scala-newbie-warts's Issues

add support for other unsafe operations on IO (cats effect 3)

unsafeRunAsync
unsafeRunAsyncOutcome
unsafeRunAndForget
unsafeToFuture
unsafeToFutureCancelable
unsafeRunCancelable

maybe could define a Seq and define them all like the docs say for the built in warts like (Warts.unsafe)
Maybe something like :
net.wiringbits.warts.CatsEffectWarts.unsafe and the unsafe Seq would have the unsafeRunSync plus the others mentioned above.

Let's add warts for invoking IO.pure when the argument is a function

IO.pure expects a constant, computing a value through a function could easily deal to exceptions being thrown, hence, I'd include a wart to catch that case, for example:

def unsafe[T]: T

IO.pure(unsafe)

This is a pattern that I have saw in new scala developers which could be easily caught with a wart.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.