Skip to content

Commit

Permalink
Merge pull request #3945 from danicheg/scalastyle-cleanup
Browse files Browse the repository at this point in the history
Cleanup ScalaStyle things
  • Loading branch information
djspiewak authored Jul 29, 2021
2 parents b31940b + 2bfd744 commit ed9b0fd
Show file tree
Hide file tree
Showing 19 changed files with 11 additions and 50 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ To build Cats you should have
* `console`: launch a REPL
* `test`: run the tests
* `unidoc`: generate the documentation
* `scalastyle`: run the style-checker on the code
* `fmt`: run formatting of the code
* `validate`: run tests, style-checker, and doc generation

#### Scala and Scala.js
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Eval.scala
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ final class Later[A](f: () => A) extends Eval.Leaf[A] {
// expensive to store, consider using `Always`.)
lazy val value: A = {
val result = thunk()
thunk = null // scalastyle:off
thunk = null
result
}

Expand Down
16 changes: 0 additions & 16 deletions core/src/main/scala/cats/data/Chain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ sealed abstract class Chain[+A] {
this match {
case non: Chain.NonEmpty[A] =>
var c: NonEmpty[A] = non
// scalastyle:off null
var rights: Chain.NonEmpty[A] = null
var result: (A, Chain[A]) = null
while (result eq null) {
Expand Down Expand Up @@ -50,7 +49,6 @@ sealed abstract class Chain[+A] {
result = (seq.head, next)
}
}
// scalastyle:on null
Some(result)
case _ => None
}
Expand All @@ -62,7 +60,6 @@ sealed abstract class Chain[+A] {
this match {
case non: Chain.NonEmpty[A] =>
var c: NonEmpty[A] = non
// scalastyle:off null
var lefts: NonEmpty[A] = null
var result: (Chain[A], A) = null
while (result eq null) {
Expand Down Expand Up @@ -90,7 +87,6 @@ sealed abstract class Chain[+A] {
result = (pre, seq.last)
}
}
// scalastyle:on null
Some(result)
case _ => None
}
Expand Down Expand Up @@ -491,7 +487,6 @@ sealed abstract class Chain[+A] {
/**
* Applies the supplied function to each element, left to right, but stops when true is returned
*/
// scalastyle:off null return cyclomatic.complexity
final private def foreachUntil(f: A => Boolean): Unit =
this match {
case non: Chain.NonEmpty[A] =>
Expand Down Expand Up @@ -531,7 +526,6 @@ sealed abstract class Chain[+A] {
}
case _ => ()
}
// scalastyle:on null return cyclomatic.complexity

final def iterator: Iterator[A] =
this match {
Expand Down Expand Up @@ -599,9 +593,7 @@ sealed abstract class Chain[+A] {
val iterX = iterator
val iterY = that.iterator
while (iterX.hasNext && iterY.hasNext) {
// scalastyle:off return
if (!A.eqv(iterX.next(), iterY.next())) return false
// scalastyle:on return
}

iterX.hasNext == iterY.hasNext
Expand Down Expand Up @@ -877,7 +869,6 @@ object Chain extends ChainInstances {
loop(0, as.size).value
}

// scalastyle:off null
private class ChainIterator[A](self: NonEmpty[A]) extends Iterator[A] {
def this(chain: Chain[A]) =
this(chain match {
Expand Down Expand Up @@ -930,9 +921,7 @@ object Chain extends ChainInstances {
go
}
}
// scalastyle:on null

// scalastyle:off null
private class ChainReverseIterator[A](self: NonEmpty[A]) extends Iterator[A] {
def this(chain: Chain[A]) =
this(chain match {
Expand Down Expand Up @@ -985,7 +974,6 @@ object Chain extends ChainInstances {
go
}
}
// scalastyle:on null
}

sealed abstract private[data] class ChainInstances extends ChainInstances1 {
Expand Down Expand Up @@ -1109,9 +1097,7 @@ sealed abstract private[data] class ChainInstances extends ChainInstances1 {
val iterY = y.iterator
while (iterX.hasNext && iterY.hasNext) {
val n = A0.compare(iterX.next(), iterY.next())
// scalastyle:off return
if (n != 0) return n
// scalastyle:on return
}

if (iterX.hasNext) 1
Expand Down Expand Up @@ -1184,9 +1170,7 @@ private[data] trait ChainPartialOrder[A] extends PartialOrder[Chain[A]] {
val iterY = y.iterator
while (iterX.hasNext && iterY.hasNext) {
val n = A.partialCompare(iterX.next(), iterY.next())
// scalastyle:off return
if (n != 0.0) return n
// scalastyle:on return
}

if (iterX.hasNext) 1.0
Expand Down
4 changes: 0 additions & 4 deletions core/src/main/scala/cats/data/Ior.scala
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,6 @@ sealed abstract class Ior[+A, +B] extends Product with Serializable {
* res3: Ior[String, Int] = Both(abc,579)
* }}}
*/
// scalastyle:off cyclomatic.complexity
final def combine[AA >: A, BB >: B](that: AA Ior BB)(implicit AA: Semigroup[AA], BB: Semigroup[BB]): AA Ior BB =
this match {
case Ior.Left(a1) =>
Expand All @@ -752,7 +751,6 @@ sealed abstract class Ior[+A, +B] extends Product with Serializable {
case Ior.Both(a2, b2) => Ior.Both(AA.combine(a1, a2), BB.combine(b1, b2))
}
}
// scalastyle:on cyclomatic.complexity

final def ===[AA >: A, BB >: B](that: AA Ior BB)(implicit AA: Eq[AA], BB: Eq[BB]): Boolean =
fold(
Expand Down Expand Up @@ -883,7 +881,6 @@ sealed abstract private[data] class IorInstances extends IorInstances0 {
override def bimap[A, B, C, D](fab: A Ior B)(f: A => C, g: B => D): C Ior D = fab.bimap(f, g)
}

// scalastyle:off cyclomatic.complexity
implicit def catsDataParallelForIor[E](implicit E: Semigroup[E]): Parallel.Aux[Ior[E, *], Ior[E, *]] =
new Parallel[Ior[E, *]] {
type F[x] = Ior[E, x]
Expand Down Expand Up @@ -920,7 +917,6 @@ sealed abstract private[data] class IorInstances extends IorInstances0 {

lazy val monad: Monad[Ior[E, *]] = Monad[Ior[E, *]]
}
// scalastyle:on cyclomatic.complexity

}

Expand Down
2 changes: 0 additions & 2 deletions core/src/main/scala/cats/data/Validated.scala
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,6 @@ sealed abstract private[data] class ValidatedInstances2 {
def eqv(x: Validated[A, B], y: Validated[A, B]): Boolean = x === y
}

// scalastyle:off method.length
implicit def catsDataTraverseFunctorForValidated[E]: Traverse[Validated[E, *]] =
new Traverse[Validated[E, *]] {

Expand Down Expand Up @@ -1032,7 +1031,6 @@ sealed abstract private[data] class ValidatedInstances2 {

override def isEmpty[A](fa: Validated[E, A]): Boolean = fa.isInvalid
}
// scalastyle:off method.length
}

private[data] class ValidatedApplicative[E: Semigroup] extends CommutativeApplicative[Validated[E, *]] {
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/scala/cats/instances/either.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ trait EitherInstances extends cats.kernel.instances.EitherInstances {
}
}

// scalastyle:off method.length
implicit def catsStdInstancesForEither[A]
: MonadError[Either[A, *], A] with Traverse[Either[A, *]] with Align[Either[A, *]] =
new MonadError[Either[A, *], A] with Traverse[Either[A, *]] with Align[Either[A, *]] {
Expand Down Expand Up @@ -177,7 +176,6 @@ trait EitherInstances extends cats.kernel.instances.EitherInstances {
}

}
// scalastyle:on method.length

implicit def catsStdSemigroupKForEither[L]: SemigroupK[Either[L, *]] =
new SemigroupK[Either[L, *]] {
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/scala/cats/instances/map.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ trait MapInstances extends cats.kernel.instances.MapInstances {
.mkString("Map(", ", ", ")")
}

// scalastyle:off method.length
implicit def catsStdInstancesForMap[K]: UnorderedTraverse[Map[K, *]] with FlatMap[Map[K, *]] with Align[Map[K, *]] =
new UnorderedTraverse[Map[K, *]] with FlatMap[Map[K, *]] with Align[Map[K, *]] {

Expand Down Expand Up @@ -110,7 +109,6 @@ trait MapInstances extends cats.kernel.instances.MapInstances {
.result()
}
}
// scalastyle:on method.length

}

Expand Down
1 change: 0 additions & 1 deletion core/src/main/scala/cats/instances/sortedMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ trait SortedMapInstances extends SortedMapInstances2 {
implicit def catsStdShowForSortedMap[A, B](orderA: Order[A], showA: Show[A], showB: Show[B]): Show[SortedMap[A, B]] =
catsStdShowForSortedMap(showA, showB)

// scalastyle:off method.length
implicit def catsStdInstancesForSortedMap[K]
: Traverse[SortedMap[K, *]] with FlatMap[SortedMap[K, *]] with Align[SortedMap[K, *]] =
new Traverse[SortedMap[K, *]] with FlatMap[SortedMap[K, *]] with Align[SortedMap[K, *]] {
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/scala/cats/instances/try.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import scala.annotation.tailrec

trait TryInstances extends TryInstances1 {

// scalastyle:off method.length
implicit def catsStdInstancesForTry: MonadThrow[Try] with CoflatMap[Try] with Traverse[Try] with Monad[Try] =
new TryCoflatMap with MonadThrow[Try] with Traverse[Try] with Monad[Try] {
def pure[A](x: A): Try[A] = Success(x)
Expand Down Expand Up @@ -143,7 +142,6 @@ trait TryInstances extends TryInstances1 {

override def catchNonFatalEval[A](a: Eval[A])(implicit ev: Throwable <:< Throwable): Try[A] = Try(a.value)
}
// scalastyle:on method.length

implicit def catsStdShowForTry[A](implicit A: Show[A]): Show[Try[A]] =
new Show[Try[A]] {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/syntax/either.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ trait EitherSyntax {
implicit final def catsSyntaxEither[A, B](eab: Either[A, B]): EitherOps[A, B] = new EitherOps(eab)

implicit final def catsSyntaxEitherObject(either: Either.type): EitherObjectOps =
new EitherObjectOps(either) // scalastyle:off ensure.single.space.after.token
new EitherObjectOps(either)

implicit final def catsSyntaxLeft[A, B](left: Left[A, B]): LeftOps[A, B] = new LeftOps(left)

Expand Down Expand Up @@ -334,7 +334,7 @@ final class EitherOps[A, B](private val eab: Either[A, B]) extends AnyVal {
def liftTo[F[_]](implicit F: ApplicativeError[F, _ >: A]): F[B] = F.fromEither(eab)
}

final class EitherObjectOps(private val either: Either.type) extends AnyVal { // scalastyle:off ensure.single.space.after.token
final class EitherObjectOps(private val either: Either.type) extends AnyVal {
def left[A, B](a: A): Either[A, B] = Left(a)

def right[A, B](b: B): Either[A, B] = Right(b)
Expand Down
2 changes: 0 additions & 2 deletions free/src/main/scala/cats/free/FreeApplicative.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ sealed abstract class FreeApplicative[F[_], A] extends Product with Serializable
* Interprets/Runs the sequence of operations using the semantics of `Applicative` G[_].
* Tail recursive.
*/
// scalastyle:off method.length
final def foldMap[G[_]](f: F ~> G)(implicit G: Applicative[G]): G[A] = {
import FreeApplicative._
// the remaining arguments to G[A => B]'s
Expand Down Expand Up @@ -127,7 +126,6 @@ sealed abstract class FreeApplicative[F[_], A] extends Product with Serializable

loop().asInstanceOf[G[A]]
}
// scalastyle:on method.length

/**
* Interpret/run the operations using the semantics of `Applicative[F]`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ object SerializableLaws {

val baos = new ByteArrayOutputStream()
val oos = new ObjectOutputStream(baos)
var ois: ObjectInputStream = null // scalastyle:ignore null
var ois: ObjectInputStream = null
try {
oos.writeObject(a)
oos.close()
Expand All @@ -44,7 +44,7 @@ object SerializableLaws {
Result(status = Exception(t))
} finally {
oos.close()
if (ois != null) ois.close() // scalastyle:ignore null
if (ois != null) ois.close()
}
}
} else Prop(_ => Result(status = Proof))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,9 @@ private[kernel] class HashCompat {

val it = xs.iterator
var h = seqSeed
// scalastyle:off
if (!it.hasNext) return finalizeHash(h, 0)
// scalastyle:on
val x0 = it.next()
// scalastyle:off
if (!it.hasNext) return finalizeHash(mix(h, A.hash(x0)), 1)
// scalastyle:on
val x1 = it.next()

val initial = A.hash(x0)
Expand All @@ -90,9 +86,7 @@ private[kernel] class HashCompat {
h = mix(h, A.hash(it.next()))
i += 1
}
// scalastyle:off
return finalizeHash(h, i)
// scalastyle:on
}
prev = hash
i += 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cats.kernel
package instances

package object arraySeq extends ArraySeqInstances // scalastyle:ignore package.object.name
package object arraySeq extends ArraySeqInstances
2 changes: 1 addition & 1 deletion kernel/src/main/scala/cats/kernel/Comparison.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object Comparison {
def fromInt(int: Int): Comparison =
if (int > 0) Comparison.GreaterThan
else if (int == 0) Comparison.EqualTo
else Comparison.LessThan // scalastyle:ignore ensure.single.space.after.token
else Comparison.LessThan

def fromDouble(double: Double): Option[Comparison] =
if (double.isNaN) None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ object StaticMethods extends cats.kernel.compat.HashCompat {
override def iterator: Iterator[A] = m.iterator
}

// scalastyle:off return
def iteratorCompare[A](xs: Iterator[A], ys: Iterator[A])(implicit ev: Order[A]): Int = {
while (true) {
if (xs.hasNext) {
Expand Down Expand Up @@ -86,7 +85,6 @@ object StaticMethods extends cats.kernel.compat.HashCompat {
}
true
}
// scalastyle:on return

def combineNIterable[A, R](b: mutable.Builder[A, R], x: Iterable[A], n: Int): R = {
var i = n
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cats.kernel
package instances

package object bigDecimal extends BigDecimalInstances // scalastyle:ignore package.object.name
package object bigDecimal extends BigDecimalInstances
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cats.kernel
package instances

package object bigInt extends BigIntInstances // scalastyle:ignore package.object.name
package object bigInt extends BigIntInstances
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cats.kernel
package instances

package object bitSet extends BitSetInstances // scalastyle:ignore package.object.name
package object bitSet extends BitSetInstances

0 comments on commit ed9b0fd

Please sign in to comment.