Skip to content

Commit

Permalink
Fix Scalastyle
Browse files Browse the repository at this point in the history
  • Loading branch information
peterneyens committed Jun 5, 2016
1 parent 00839fb commit 77f3de3
Show file tree
Hide file tree
Showing 30 changed files with 96 additions and 75 deletions.
4 changes: 3 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ lazy val commonSettings = Seq(
compilerPlugin("org.spire-math" %% "kind-projector" % "0.6.3")
),
parallelExecution in Test := false,
scalacOptions in (Compile, doc) := (scalacOptions in (Compile, doc)).value.filter(_ != "-Xfatal-warnings")
scalacOptions in (Compile, doc) := (scalacOptions in (Compile, doc)).value.filter(_ != "-Xfatal-warnings"),
// workaround for https://github.com/scalastyle/scalastyle-sbt-plugin/issues/47
(scalastyleSources in Compile) <++= unmanagedSourceDirectories in Compile
) ++ warnUnusedImport

lazy val tagName = Def.setting{
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Trivial.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ object Trivial {
type P3H1[F[_], A, B, C] = Trivial

implicit val manifest: Trivial = new Trivial {}
}
}
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Unapply.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private[cats] sealed abstract class Unapply2Instances extends Unapply3Instances
}

// the type we will instantiate when we find a type class instance
// for a type in the shape F[_[_],_] when we fix the right type,
// for a type in the shape F[_[_],_] when we fix the right type
type Aux2RightK[TC[_[_]], MA, F[_[_],_], AX[_], B] = Unapply[TC, MA] {
type M[X] = F[AX,X]
type A = B
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/Kleisli.scala
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ private trait KleisliSemigroup[F[_], A, B] extends Semigroup[Kleisli[F, A, B]] {
private trait KleisliMonoid[F[_], A, B] extends Monoid[Kleisli[F, A, B]] with KleisliSemigroup[F, A, B] {
implicit def FB: Monoid[F[B]]

override def empty = Kleisli[F, A, B](a => FB.empty)
override def empty: Kleisli[F, A, B] = Kleisli[F, A, B](a => FB.empty)
}

private trait KleisliSemigroupK[F[_]] extends SemigroupK[λ[α => Kleisli[F, α, α]]] {
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/scala/cats/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import cats.data.Xor
* Symbolic aliases for various types are defined here.
*/
package object cats {
// scalastyle:off number.of.types

type ~>[F[_], G[_]] = arrow.FunctionK[F, G]

Expand Down Expand Up @@ -64,4 +65,6 @@ package object cats {
val Semigroup = cats.kernel.Semigroup
val Monoid = cats.kernel.Monoid
val Group = cats.kernel.Group

// scalastyle:on number.of.types
}
2 changes: 2 additions & 0 deletions core/src/main/scala/cats/std/try.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import scala.util.{Failure, Success, Try}

trait TryInstances extends TryInstances1 {

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

override def map[A, B](ta: Try[A])(f: A => B): Try[B] = ta.map(f)
}
// 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/coproduct.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class CoproductOps[F[_], A](val fa: F[A]) extends AnyVal {
* {{{
* scala> import cats.data.Coproduct
* scala> import cats.Eval
* scala> import cats.syntax.coproduct._
* scala> import cats.syntax.coproduct._
* scala> List(1, 2, 3).leftc[Eval]
* res0: Coproduct[List, Eval, Int] = Coproduct(Left(List(1, 2, 3)))
* }}}
Expand All @@ -34,7 +34,7 @@ final class CoproductOps[F[_], A](val fa: F[A]) extends AnyVal {
* {{{
* scala> import cats.data.Coproduct
* scala> import cats.Eval
* scala> import cats.syntax.coproduct._
* scala> import cats.syntax.coproduct._
* scala> List(1, 2, 3).rightc[Eval]
* res0: Coproduct[Eval, List, Int] = Coproduct(Right(List(1, 2, 3)))
* }}}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/flatMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final class FlatMapOps[F[_], A](fa: F[A])(implicit F: FlatMap[F]) {
def >>=[B](f: A => F[B]): F[B] = F.flatMap(fa)(f)

/** Alias for [[followedBy]]. */
@inline final def >> [B](fb: F[B]): F[B] = followedBy(fb)
@inline final def >>[B](fb: F[B]): F[B] = followedBy(fb)

/** Sequentially compose two actions, discarding any value produced by the first. */
def followedBy[B](fb: F[B]): F[B] = F.flatMap(fa)(_ => fb)
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/monadCombine.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ final class SeparateOps[F[_], G[_, _], A, B](fgab: F[G[A, B]])(implicit F: Monad
* }}}
*/
def separate(implicit G: Bifoldable[G]): (F[A], F[B]) = F.separate(fgab)
}
}
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/option.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package syntax
import cats.data.{ Xor, Validated, ValidatedNel }

trait OptionSyntax {
final def none[A] = Option.empty[A]
final def none[A]: Option[A] = Option.empty[A]
implicit final def optionIdSyntax[A](a: A): OptionIdOps[A] = new OptionIdOps(a)
implicit final def optionSyntax[A](oa: Option[A]): OptionOps[A] = new OptionOps(oa)
}
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/scala/cats/syntax/package.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cats

package object syntax {
// scalastyle:off number.of.types
object all extends AllSyntax
object applicative extends ApplicativeSyntax
object applicativeError extends ApplicativeErrorSyntax
Expand Down Expand Up @@ -38,4 +39,5 @@ package object syntax {
object xor extends XorSyntax
object validated extends ValidatedSyntax
object writer extends WriterSyntax
// scalastyle:on number.of.types
}
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/transLift.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ object TLExtract {
}

implicit def extractId[MTS <: SingletonMT, MS <: SingletonM](implicit TL0: TransLift.Aux[MTS#MT, Trivial.PH1]): TLExtract[MTS, MS] = extract[MTS, MS, Trivial.PH1]
}
}
6 changes: 3 additions & 3 deletions free/src/main/scala/cats/free/Inject.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ sealed abstract class Inject[F[_], G[_]] {
}

private[free] sealed abstract class InjectInstances {
implicit def reflexiveInjectInstance[F[_]] =
implicit def reflexiveInjectInstance[F[_]]: Inject[F, F] =
new Inject[F, F] {
def inj[A](fa: F[A]): F[A] = fa

def prj[A](ga: F[A]): Option[F[A]] = Option(ga)
}

implicit def leftInjectInstance[F[_], G[_]] =
implicit def leftInjectInstance[F[_], G[_]]: Inject[F, Coproduct[F, G, ?]] =
new Inject[F, Coproduct[F, G, ?]] {
def inj[A](fa: F[A]): Coproduct[F, G, A] = Coproduct.leftc(fa)

def prj[A](ga: Coproduct[F, G, A]): Option[F[A]] = ga.run.fold(Option(_), _ => None)
}

implicit def rightInjectInstance[F[_], G[_], H[_]](implicit I: Inject[F, G]) =
implicit def rightInjectInstance[F[_], G[_], H[_]](implicit I: Inject[F, G]): Inject[F, Coproduct[H, G, ?]] =
new Inject[F, Coproduct[H, G, ?]] {
def inj[A](fa: F[A]): Coproduct[H, G, A] = Coproduct.rightc(I.inj(fa))

Expand Down
2 changes: 1 addition & 1 deletion kernel-laws/src/main/scala/cats/kernel/laws/BaseLaws.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.typelevel.discipline.Laws
import org.scalacheck.{Arbitrary, Prop}

object BaseLaws {
def apply[A : Eq : Arbitrary] = new BaseLaws[A] {
def apply[A : Eq : Arbitrary]: BaseLaws[A] = new BaseLaws[A] {
def Equ = Eq[A]
def Arb = implicitly[Arbitrary[A]]
}
Expand Down
20 changes: 10 additions & 10 deletions kernel-laws/src/main/scala/cats/kernel/laws/GroupLaws.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.scalacheck.{Arbitrary, Prop}
import org.scalacheck.Prop._

object GroupLaws {
def apply[A : Eq : Arbitrary] = new GroupLaws[A] {
def apply[A : Eq : Arbitrary]: GroupLaws[A] = new GroupLaws[A] {
def Equ = Eq[A]
def Arb = implicitly[Arbitrary[A]]
}
Expand All @@ -21,7 +21,7 @@ trait GroupLaws[A] extends Laws {

// groups

def semigroup(implicit A: Semigroup[A]) = new GroupProperties(
def semigroup(implicit A: Semigroup[A]): GroupProperties = new GroupProperties(
name = "semigroup",
parents = Nil,
Rules.serializable(A),
Expand All @@ -30,25 +30,25 @@ trait GroupLaws[A] extends Laws {
Rules.repeat2("combineN", "|+|")(A.combineN)(A.combine)
)

def band(implicit A: Band[A]) = new GroupProperties(
def band(implicit A: Band[A]): GroupProperties = new GroupProperties(
name = "band",
parents = List(semigroup),
Rules.idempotence(A.combine),
"isIdempotent" -> Semigroup.isIdempotent[A]
)

def commutativeSemigroup(implicit A: CommutativeSemigroup[A]) = new GroupProperties(
def commutativeSemigroup(implicit A: CommutativeSemigroup[A]): GroupProperties = new GroupProperties(
name = "commutative semigroup",
parents = List(semigroup),
Rules.commutative(A.combine)
)

def semilattice(implicit A: Semilattice[A]) = new GroupProperties(
def semilattice(implicit A: Semilattice[A]): GroupProperties = new GroupProperties(
name = "semilattice",
parents = List(band, commutativeSemigroup)
)

def monoid(implicit A: Monoid[A]) = new GroupProperties(
def monoid(implicit A: Monoid[A]): GroupProperties = new GroupProperties(
name = "monoid",
parents = List(semigroup),
Rules.leftIdentity(A.empty)(A.combine),
Expand All @@ -58,25 +58,25 @@ trait GroupLaws[A] extends Laws {
Rules.isId("isEmpty", A.empty)(A.isEmpty)
)

def commutativeMonoid(implicit A: CommutativeMonoid[A]) = new GroupProperties(
def commutativeMonoid(implicit A: CommutativeMonoid[A]): GroupProperties = new GroupProperties(
name = "commutative monoid",
parents = List(monoid, commutativeSemigroup)
)

def boundedSemilattice(implicit A: BoundedSemilattice[A]) = new GroupProperties(
def boundedSemilattice(implicit A: BoundedSemilattice[A]): GroupProperties = new GroupProperties(
name = "boundedSemilattice",
parents = List(commutativeMonoid, semilattice)
)

def group(implicit A: Group[A]) = new GroupProperties(
def group(implicit A: Group[A]): GroupProperties = new GroupProperties(
name = "group",
parents = List(monoid),
Rules.leftInverse(A.empty)(A.combine)(A.inverse),
Rules.rightInverse(A.empty)(A.combine)(A.inverse),
Rules.consistentInverse("remove")(A.remove)(A.combine)(A.inverse)
)

def commutativeGroup(implicit A: CommutativeGroup[A]) = new GroupProperties(
def commutativeGroup(implicit A: CommutativeGroup[A]): GroupProperties = new GroupProperties(
name = "commutative group",
parents = List(group, commutativeMonoid)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ private[laws] object IsSerializable {
import java.io._
val baos = new ByteArrayOutputStream()
val oos = new ObjectOutputStream(baos)
// scalastyle:off null
var ois: ObjectInputStream = null
// scalastyle:off on
try {
oos.writeObject(m)
oos.close()
Expand All @@ -32,7 +34,9 @@ private[laws] object IsSerializable {
Result(status = Exception(t))
} finally {
oos.close()
// scalastyle:off null
if (ois != null) ois.close()
// scalastyle:on null
}
}
}
8 changes: 4 additions & 4 deletions kernel-laws/src/main/scala/cats/kernel/laws/OrderLaws.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.scalacheck.Prop._
import cats.kernel.std.boolean._

object OrderLaws {
def apply[A: Eq: Arbitrary] = new OrderLaws[A] {
def apply[A: Eq: Arbitrary]: OrderLaws[A] = new OrderLaws[A] {
def Equ = Eq[A]
def Arb = implicitly[Arbitrary[A]]
}
Expand All @@ -20,7 +20,7 @@ trait OrderLaws[A] extends Laws {
implicit def Equ: Eq[A]
implicit def Arb: Arbitrary[A]

def eqv = new OrderProperties(
def eqv: OrderProperties = new OrderProperties(
name = "eq",
parent = None,
Rules.serializable(Equ),
Expand All @@ -38,7 +38,7 @@ trait OrderLaws[A] extends Laws {
}
)

def partialOrder(implicit A: PartialOrder[A]) = new OrderProperties(
def partialOrder(implicit A: PartialOrder[A]): OrderProperties = new OrderProperties(
name = "partialOrder",
parent = Some(eqv),
Rules.serializable(A),
Expand All @@ -62,7 +62,7 @@ trait OrderLaws[A] extends Laws {
}
)

def order(implicit A: Order[A]) = new OrderProperties(
def order(implicit A: Order[A]): OrderProperties = new OrderProperties(
name = "order",
parent = Some(partialOrder),
"totality" -> forAll { (x: A, y: A) =>
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/main/scala/cats/kernel/Order.scala
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ object Order extends OrderFunctions[Order] {
/**
* Access an implicit `Order[A]`.
*/
@inline final def apply[A](implicit ev: Order[A]) = ev
@inline final def apply[A](implicit ev: Order[A]): Order[A] = ev

/**
* Convert an implicit `Order[B]` to an `Order[A]` using the given
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/main/scala/cats/kernel/PartialOrder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ object PartialOrder extends PartialOrderFunctions[PartialOrder] {
/**
* Access an implicit `PartialOrder[A]`.
*/
@inline final def apply[A](implicit ev: PartialOrder[A]) = ev
@inline final def apply[A](implicit ev: PartialOrder[A]): PartialOrder[A] = ev

/**
* Convert an implicit `PartialOrder[B]` to an `PartialOrder[A]` using the given
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/main/scala/cats/kernel/Semigroup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ object Semigroup extends SemigroupFunctions[Semigroup] {
/**
* Access an implicit `Semigroup[A]`.
*/
@inline final def apply[A](implicit ev: Semigroup[A]) = ev
@inline final def apply[A](implicit ev: Semigroup[A]): Semigroup[A] = ev
}
2 changes: 2 additions & 0 deletions kernel/src/main/scala/cats/kernel/std/Util.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ object StaticMethods {
wrapMutableMap(m)
}

// 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 @@ -85,4 +86,5 @@ object StaticMethods {
}
true
}
// scalastyle:on magic.number
}
2 changes: 2 additions & 0 deletions kernel/src/main/scala/cats/kernel/std/bigInt.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package cats.kernel
package std

// scalastyle:off package.object.name
package object bigInt extends BigIntInstances
// scalastyle:on package.object.name

trait BigIntInstances {
implicit val catsKernelStdOrderForBigInt: Order[BigInt] =
Expand Down
12 changes: 6 additions & 6 deletions kernel/src/main/scala/cats/kernel/std/byte.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class ByteOrder extends Order[Byte] {
def compare(x: Byte, y: Byte): Int =
if (x < y) -1 else if (x > y) 1 else 0

override def eqv(x: Byte, y: Byte) = x == y
override def neqv(x: Byte, y: Byte) = x != y
override def gt(x: Byte, y: Byte) = x > y
override def gteqv(x: Byte, y: Byte) = x >= y
override def lt(x: Byte, y: Byte) = x < y
override def lteqv(x: Byte, y: Byte) = x <= y
override def eqv(x: Byte, y: Byte): Boolean = x == y
override def neqv(x: Byte, y: Byte): Boolean = x != y
override def gt(x: Byte, y: Byte): Boolean = x > y
override def gteqv(x: Byte, y: Byte): Boolean = x >= y
override def lt(x: Byte, y: Byte): Boolean = x < y
override def lteqv(x: Byte, y: Byte): Boolean = x <= y

override def min(x: Byte, y: Byte): Byte =
java.lang.Math.min(x.toInt, y.toInt).toByte
Expand Down
14 changes: 7 additions & 7 deletions kernel/src/main/scala/cats/kernel/std/char.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ trait CharInstances {
}

class CharOrder extends Order[Char] {
def compare(x: Char, y: Char) =
def compare(x: Char, y: Char): Int =
if (x < y) -1 else if (x > y) 1 else 0
override def eqv(x:Char, y:Char) = x == y
override def neqv(x:Char, y:Char) = x != y
override def gt(x: Char, y: Char) = x > y
override def gteqv(x: Char, y: Char) = x >= y
override def lt(x: Char, y: Char) = x < y
override def lteqv(x: Char, y: Char) = x <= y
override def eqv(x:Char, y:Char): Boolean = x == y
override def neqv(x:Char, y:Char): Boolean = x != y
override def gt(x: Char, y: Char): Boolean = x > y
override def gteqv(x: Char, y: Char): Boolean = x >= y
override def lt(x: Char, y: Char): Boolean = x < y
override def lteqv(x: Char, y: Char): Boolean = x <= y
}
Loading

0 comments on commit 77f3de3

Please sign in to comment.