Skip to content

libraries that define methods as inline appear to get linted by Scapegoat #944

@dontgitit

Description

@dontgitit

sample build.sbt:

lazy val literalThing = (project in file("literalThing")).settings(
  libraryDependencies ++= Seq(
    "com.comcast" %% "ip4s-core" % "3.6.0"
  )
)

literalThing/src/main/scala/Main.scala:

import com.comcast.ip4s.*

object Main {
  def main(args: Array[String]): Unit = {
    println(port"8080")
  }
}

produces the following when running literalThing/scapegoat:

[project directory]\shared\src\main\scala-3\Literals.scala: [scapegoat] [OptionGet] Use of Option.get
[error]   Using Option.get defeats the purpose of using Option in the first place. Use the following instead: Option.getOrElse, Option.fold, pattern matching or don't take the value out of the container and map over it to transform it.
[error]
[error] [scapegoat] Analysis complete: 1 errors 0 warns 0 infos

I'm guessing what's happening is that since the port interpolator is defined as inline, Scapegoat reports on it even though it's not actually part of the project's sources.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions