orphan-finder


License

License

GroupId

GroupId

io.methvin
ArtifactId

ArtifactId

orphan-finder_2.13.1
Last Version

Last Version

0.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

orphan-finder
orphan-finder
Project URL

Project URL

https://github.com/gmethvin/orphan-finder
Project Organization

Project Organization

Greg Methvin
Source Code Management

Source Code Management

https://github.com/gmethvin/orphan-finder

Download orphan-finder_2.13.1

How to add to project

<!-- https://jarcasting.com/artifacts/io.methvin/orphan-finder_2.13.1/ -->
<dependency>
    <groupId>io.methvin</groupId>
    <artifactId>orphan-finder_2.13.1</artifactId>
    <version>0.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/io.methvin/orphan-finder_2.13.1/
implementation 'io.methvin:orphan-finder_2.13.1:0.0.3'
// https://jarcasting.com/artifacts/io.methvin/orphan-finder_2.13.1/
implementation ("io.methvin:orphan-finder_2.13.1:0.0.3")
'io.methvin:orphan-finder_2.13.1:jar:0.0.3'
<dependency org="io.methvin" name="orphan-finder_2.13.1" rev="0.0.3">
  <artifact name="orphan-finder_2.13.1" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.methvin', module='orphan-finder_2.13.1', version='0.0.3')
)
libraryDependencies += "io.methvin" % "orphan-finder_2.13.1" % "0.0.3"
[io.methvin/orphan-finder_2.13.1 "0.0.3"]

Dependencies

compile (2)

Group / Artifact Type Version
org.scala-lang : scala-compiler jar 2.13.1
org.scala-lang : scala-library jar 2.13.1

Project Modules

There are no modules declared in this project.

orphan-finder

Travis CI

A Scala compiler plugin for finding orphan expressions in Scala code. An orphan expression of type T occurs when the result of an expression of type T is discarded. For example, an orphan Future occurs when a Future result is not assigned to a value, returned, or otherwise transformed. This can often indicate a bug in the code.

Currently, the implementation simply checks for statements within blocks matching the configured type(s). Note that this does not cover the cases already covered by the -Ywarn-value-discard compiler option.

The demo module in this repository shows an example of warnings emitted. The output looks something like:

[warn] /Users/greg/projects/orphan-finder/demo/src/main/scala/io/methvin/orphanfinder/Demo.scala:12:11: Orphan scala.concurrent.Future found!
[warn]     Future("hello")
[warn]           ^
[warn] /Users/greg/projects/orphan-finder/demo/src/main/scala/io/methvin/orphanfinder/Demo.scala:15:57: Orphan scala.concurrent.Future found!
[warn]     Future(throw new RuntimeException("hello")).recover {
[warn]                                                         ^

Usage

To use this plugin, add the following to build.sbt:

inThisBuild(Seq(
  autoCompilerPlugins := true,
  addCompilerPlugin("io.methvin" %% "orphan-finder" % orphanFinderVersion cross CrossVersion.full),
  scalacOptions ++= Seq(
    // Configure the orphan types you want to warn about
    "-P:orphan-finder:class:scala.concurrent.Future"
  )
))

where orphanFinderVersion is the version you wish to use. The latest is: Maven.

Versions

Version
0.0.3