From e862f52d1fa99fa47c550bde1b07ee294c824a8c Mon Sep 17 00:00:00 2001 From: Jeff May Date: Wed, 9 Nov 2022 11:45:11 -0800 Subject: [PATCH] Use stricter scalacOptions (#111) --- build.sbt | 26 +++++++++++++++++-- .../src/main/scala/data/ExtractValue.scala | 2 +- core-v1/src/main/scala/data/Justified.scala | 6 ++--- core-v1/src/main/scala/dsl/BuildExprDsl.scala | 1 + .../scala/dsl/ExprHListDslImplicits.scala | 2 -- .../main/scala/dsl/WrappedBuildExprDsl.scala | 2 -- .../scala/engine/ImmutableCachingEngine.scala | 2 +- .../src/main/scala/engine/SimpleEngine.scala | 5 +--- .../src/main/scala/lens/JavaBeanCompat.scala | 20 +++++++------- .../main/scala/lens/ValidDataPathKey.scala | 2 +- 10 files changed, 43 insertions(+), 25 deletions(-) diff --git a/build.sbt b/build.sbt index 3f18934a6..93d105832 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,7 @@ ThisBuild / organization := "com.rallyhealth" ThisBuild / organizationName := "Rally Health" ThisBuild / homepage := Some(url("https://github.com/jeffmay/vapors")) ThisBuild / scmInfo := Some( - ScmInfo(url("https://github.com/jeffmay/vapors"), "scm:git:git@github.com:jeffmay/vapors.git") + ScmInfo(url("https://github.com/jeffmay/vapors"), "scm:git:git@github.com:jeffmay/vapors.git"), ) ThisBuild / versionScheme := Some("early-semver") ThisBuild / scalaVersion := Dependencies.Scala_2_13 @@ -18,10 +18,32 @@ ThisBuild / scalacOptions ++= Seq( "-language:higherKinds", "-language:implicitConversions", "-language:experimental.macros", - "-Xfatal-warnings", + "-opt-warnings:at-inline-failed-summary", + "-unchecked", + "-Xlint:doc-detached", + "-Xlint:eta-sam", + "-Xlint:eta-zero", + "-Xlint:deprecation", + "-Xlint:nonlocal-return", + "-Xlint:nullary-unit", + "-Xlint:package-object-classes", + "-Xlint:private-shadow", + "-Xlint:implicit-not-found", + "-Xlint:type-parameter-shadow", + "-Xlint:valpattern", "-Xlog-implicits", + "-Werror", + "-Wself-implicit", + "-Wunused:privates", + "-Wunused:locals", + "-Wvalue-discard", "-Ymacro-annotations", ) +ThisBuild / Compile / scalacOptions --= Seq( + "-Wunused:privates", + "-Wunused:locals", + "-Wvalue-discard", +) // reload sbt when the build files change Global / onChangedBuildSource := ReloadOnSourceChanges diff --git a/core-v1/src/main/scala/data/ExtractValue.scala b/core-v1/src/main/scala/data/ExtractValue.scala index c03c6ac02..b0d4d7f53 100644 --- a/core-v1/src/main/scala/data/ExtractValue.scala +++ b/core-v1/src/main/scala/data/ExtractValue.scala @@ -36,7 +36,7 @@ object ExtractValue { def from[T](implicit extractor: ExtractValue[T, V]): ExtractValue[T, V] = extractor } - implicit def conforms[A, B](implicit ev: A <:< B): ExtractValue[A, B] = ev.apply + implicit def conforms[A, B](implicit ev: A <:< B): ExtractValue[A, B] = ev(_) implicit def extracted[W[_] : Extract, V]: ExtractValue[W[V], V] = Extract[W].extract(_) } diff --git a/core-v1/src/main/scala/data/Justified.scala b/core-v1/src/main/scala/data/Justified.scala index 0b1a24cdf..0131bd1fc 100644 --- a/core-v1/src/main/scala/data/Justified.scala +++ b/core-v1/src/main/scala/data/Justified.scala @@ -2,8 +2,8 @@ package com.rallyhealth.vapors.v1 package data -import algebra.{EqualComparable, SizeComparable, SizeComparison} -import dsl.{WrapConst, WrapContained, WrapFact, WrapQuantifier, WrapRegexMatches, WrapSelected} +import algebra.{EqualComparable, SizeComparable} +import dsl._ import lens.{DataPath, VariantLens} import logic.Logic import math._ @@ -11,7 +11,7 @@ import time.CountTime import cats.data.{NonEmptySeq, NonEmptySet} import cats.implicits._ -import cats.{Applicative, Eq, Eval, Foldable, Functor, Order, Semigroupal, Traverse, TraverseFilter} +import cats.{Applicative, Eq, Eval, Foldable, Order, Semigroupal, Traverse} import scala.annotation.nowarn import scala.collection.Factory diff --git a/core-v1/src/main/scala/dsl/BuildExprDsl.scala b/core-v1/src/main/scala/dsl/BuildExprDsl.scala index cf93ecaea..1c6e5490b 100644 --- a/core-v1/src/main/scala/dsl/BuildExprDsl.scala +++ b/core-v1/src/main/scala/dsl/BuildExprDsl.scala @@ -118,6 +118,7 @@ trait BuildExprDsl """You should use the using().thenReturn(...) DSL method instead. You should prefer put your declaration of dependency on definitions close to where you actually use them.""", + "1.0.0-M1", ) final def usingDefinitions[I, O]( definitions: Expr.Definition[I, OP]*, diff --git a/core-v1/src/main/scala/dsl/ExprHListDslImplicits.scala b/core-v1/src/main/scala/dsl/ExprHListDslImplicits.scala index a08d8d8c7..6e5bdb8a3 100644 --- a/core-v1/src/main/scala/dsl/ExprHListDslImplicits.scala +++ b/core-v1/src/main/scala/dsl/ExprHListDslImplicits.scala @@ -5,8 +5,6 @@ package dsl import cats.{Align, Functor, FunctorFilter} import shapeless.{::, HList, HNil} -import scala.collection.Factory - /** * A marker trait for determining which set of implicits to inherit. * diff --git a/core-v1/src/main/scala/dsl/WrappedBuildExprDsl.scala b/core-v1/src/main/scala/dsl/WrappedBuildExprDsl.scala index fb3739722..3e3056d90 100644 --- a/core-v1/src/main/scala/dsl/WrappedBuildExprDsl.scala +++ b/core-v1/src/main/scala/dsl/WrappedBuildExprDsl.scala @@ -12,8 +12,6 @@ import cats.{FlatMap, Foldable, Functor, Id, Order, Reducible, Traverse} import izumi.reflect.Tag import shapeless.{Generic, HList, Nat, Typeable} -import scala.util.matching.Regex - trait WrappedBuildExprDsl extends BuildExprDsl { self: DslTypes with WrappedExprHListDslImplicits with OutputTypeImplicits => diff --git a/core-v1/src/main/scala/engine/ImmutableCachingEngine.scala b/core-v1/src/main/scala/engine/ImmutableCachingEngine.scala index 1ee130701..118d3b18a 100644 --- a/core-v1/src/main/scala/engine/ImmutableCachingEngine.scala +++ b/core-v1/src/main/scala/engine/ImmutableCachingEngine.scala @@ -14,7 +14,7 @@ import logic.{Conjunction, Disjunction, Negation} import cats.arrow.Arrow import cats.data.NonEmptyVector import cats.{Applicative, Eval, FlatMap, Foldable, Functor, Monad, SemigroupK, Traverse} -import shapeless.{HList, HMap, TypeCase, Typeable} +import shapeless.{HList, HMap} import scala.annotation.tailrec diff --git a/core-v1/src/main/scala/engine/SimpleEngine.scala b/core-v1/src/main/scala/engine/SimpleEngine.scala index 25813646b..c6c12455b 100644 --- a/core-v1/src/main/scala/engine/SimpleEngine.scala +++ b/core-v1/src/main/scala/engine/SimpleEngine.scala @@ -11,10 +11,7 @@ import lens.CollectInto import logic.{Conjunction, Disjunction, Negation} import cats.{Applicative, Eval, FlatMap, Foldable, Functor, SemigroupK, Traverse} -import shapeless.{HList, TypeCase, Typeable} - -import scala.collection.MapView -import scala.collection.immutable.IntMap +import shapeless.HList /** * A vapors [[Expr]] interpreter that just builds a simple function without providing any post-processing. diff --git a/core-v1/src/main/scala/lens/JavaBeanCompat.scala b/core-v1/src/main/scala/lens/JavaBeanCompat.scala index a28914a2e..9ab49689a 100644 --- a/core-v1/src/main/scala/lens/JavaBeanCompat.scala +++ b/core-v1/src/main/scala/lens/JavaBeanCompat.scala @@ -8,15 +8,17 @@ object JavaBeanCompat { private final val GETTER_PREFIXES = Set("get") def unbeanify(name: String): String = { - for (prefix <- GETTER_PREFIXES) { - if (name.startsWith(prefix) && name.length > prefix.length) { - val firstChar = name.charAt(prefix.length) - if (firstChar.isUpper) { - val restOfName = name.substring(prefix.length + 1) - return s"${firstChar.toLower}$restOfName" + val unbeanified = GETTER_PREFIXES.collectFirst(Function.unlift { prefix => + Option + .when(name.startsWith(prefix) && name.length > prefix.length) { + val firstChar = name.charAt(prefix.length) + Option.when(firstChar.isUpper) { + val restOfName = name.substring(prefix.length + 1) + s"${firstChar.toLower}$restOfName" + } } - } - } - name + .flatten + }) + unbeanified.getOrElse(name) } } diff --git a/core-v1/src/main/scala/lens/ValidDataPathKey.scala b/core-v1/src/main/scala/lens/ValidDataPathKey.scala index b76b5c6b5..f3dfdcfc0 100644 --- a/core-v1/src/main/scala/lens/ValidDataPathKey.scala +++ b/core-v1/src/main/scala/lens/ValidDataPathKey.scala @@ -33,7 +33,7 @@ object ValidDataPathKey { ToInt[N].apply().toString } - implicit val string: ValidDataPathKey[String] = identity[String] + implicit val string: ValidDataPathKey[String] = identity(_) implicit val int: ValidDataPathKey[Int] = _.toString