Skip to content

Commit

Permalink
remove scalastyle plugin (#737)
Browse files Browse the repository at this point in the history
scalastyle is abandoned for +5 years, and is making it difficult to maintain updates
  • Loading branch information
larshagencognite authored Jul 3, 2024
1 parent 6d308a4 commit 2fe95e9
Show file tree
Hide file tree
Showing 26 changed files with 18 additions and 156 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/scala.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:
# run: sbt test
run: |
cat /dev/null | sbt -Dsbt.log.noformat=true ++2.13 dependencyLockCheck
cat /dev/null | sbt -Dsbt.log.noformat=true -J-Xmx2G -J-XX:+UseG1GC ++2.13 scalastyle test:scalastyle scalafmtCheck coverage test coverageReport
cat /dev/null | sbt -Dsbt.log.noformat=true -J-Xmx2G -J-XX:+UseG1GC ++2.13 scalafmtCheck coverage test coverageReport
- name: Upload test coverage report
uses: codecov/codecov-action@v3
Expand Down
10 changes: 0 additions & 10 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,6 @@ scalacOptions --= (CrossVersion.partialVersion(scalaVersion.value) match {
List.empty[String]
})

scalastyleFailOnWarning := true

lazy val mainScalastyle = taskKey[Unit]("mainScalastyle")
lazy val testScalastyle = taskKey[Unit]("testScalastyle")

mainScalastyle := (Compile / scalastyle).toTask("").value
testScalastyle := (Test / scalastyle).toTask("").value

Test / test := (Test / test).dependsOn(testScalastyle).value
Test / test := (Test / test).dependsOn(mainScalastyle).value
Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-oD")

// Scala 2.11 doesn't support mixed projects as ours, so just disable docs for that release.
Expand Down
1 change: 0 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.10.0")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2-1")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.4.4")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.0")
addSbtPlugin("au.com.onegeek" %% "sbt-dotenv" % "2.1.233")
addSbtPlugin("org.wartremover" % "sbt-wartremover" % "3.0.6")
Expand Down
93 changes: 0 additions & 93 deletions scalastyle-config.xml

This file was deleted.

2 changes: 0 additions & 2 deletions src/main/scala/com/cognite/sdk/scala/common/OAuth2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ object OAuth2 {
def getAuth: F[Auth] = commonGetAuth(cache, refreshSecondsBeforeExpiration)
}

// scalastyle:off method.length
object ClientCredentialsProvider {
def apply[F[_]](
credentials: ClientCredentials,
Expand All @@ -169,7 +168,6 @@ object OAuth2 {
ConcurrentCachedObject(credentials.getAuth, initialToken)
.map(new ClientCredentialsProvider[F](_, refreshSecondsBeforeExpiration))
}
// scalastyle:on method.length

object SessionProvider {
def apply[F[_]](
Expand Down
10 changes: 5 additions & 5 deletions src/main/scala/com/cognite/sdk/scala/common/dataTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import io.circe.generic.semiauto.{deriveDecoder, deriveEncoder}
import sttp.model.Uri

import scala.annotation.nowarn
// scalastyle:off number.of.types

trait ResponseWithCursor {
val nextCursor: Option[String]
}
Expand Down Expand Up @@ -237,16 +237,16 @@ object Setter {
@SuppressWarnings(Array("org.wartremover.warts.Null"))
def fromOption[T](option: Option[T]): Option[Setter[T]] =
option match {
case null => Some(SetNull()) // scalastyle:ignore null
case null => Some(SetNull())
case None => None
case Some(null) => Some(SetNull()) // scalastyle:ignore null
case Some(null) => Some(SetNull())
case Some(value) => Some(SetValue(value))
}

@SuppressWarnings(Array("org.wartremover.warts.Null"))
def fromAny[T](optionValue: T): Option[Setter[T]] =
optionValue match {
case null => Some(SetNull()) // scalastyle:ignore null
case null => Some(SetNull())
case value => Some(SetValue(value))
}

Expand All @@ -270,7 +270,7 @@ object NonNullableSetter {
case None => None
case Some(value) =>
require(
value != null, // scalastyle:ignore null
value != null,
"Invalid null value for non-nullable field update"
)
Some(SetValue(value))
Expand Down
2 changes: 0 additions & 2 deletions src/main/scala/com/cognite/sdk/scala/common/filter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ trait PartitionedFilter[R, Fi, F[_]] extends PartitionedFilterF[R, Fi, F] {
}

object Filter {
// scalastyle:off parameter.number
def filterWithCursor[F[_], R, Fi](
requestSession: RequestSession[F],
filterUrl: Uri,
Expand Down Expand Up @@ -115,5 +114,4 @@ object Filter {
value => value
)
}
// scalastyle:off parameter.number
}
2 changes: 0 additions & 2 deletions src/main/scala/com/cognite/sdk/scala/v1/Client.scala
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ final case class RequestSession[F[_]: Monad: Trace](
def flatMap[R, R1](r: F[R], f: R => F[R1]): F[R1] = r.flatMap(f)
}

// scalastyle:off parameter.number
class GenericClient[F[_]: Trace](
applicationName: String,
val projectName: String,
Expand Down Expand Up @@ -192,7 +191,6 @@ class GenericClient[F[_]: Trace](
clientTag,
cdfVersion
)
// scalastyle:on parameter.number

import GenericClient._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import java.time.{LocalDate, ZonedDateTime}
import io.circe.{ACursor, Decoder, Encoder, Json}
import io.circe.syntax._

// scalastyle:off number.of.types

sealed abstract case class DataModelProperty[V](value: V)(implicit encoder: Encoder[V]) {
import io.circe.parser._
def encode: Json =
Expand Down Expand Up @@ -56,7 +54,6 @@ sealed abstract class ArrayPropertyType[V, P <: PrimitivePropertyType[V]](privat
}

// There are a lot of property types, but it can't be helped.
// scalastyle:off number.of.types
object PropertyType {

val values: Seq[PropertyType[_]] = Seq[PropertyType[_]](
Expand Down Expand Up @@ -149,4 +146,3 @@ object PropertyType {
extends ArrayPropertyType[String, PropertyType.Geography.type](PropertyType.Geography)
}
}
// scalastyle:on number.of.types
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ object PropertyDefinition {
}
}

// scalastyle:off cyclomatic.complexity
private def propertyTypeBasedPropertyDefaultValue(
propType: PropertyType,
defaultValueJson: Option[Json]
Expand Down Expand Up @@ -174,7 +173,6 @@ object PropertyDefinition {
}
defaultValue
}
// scalastyle:on cyclomatic.complexity

implicit val connectionDefinitionDecoder: Decoder[ConnectionDefinition] =
List[Decoder[ConnectionDefinition]](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ object InstanceDefinition {
case t => toInstancePropertyTypeOfNonList(propValue, t)
}

// scalastyle:off cyclomatic.complexity method.length
private def toInstancePropertyTypeOfList(
propValue: Json,
t: PropertyType
Expand Down Expand Up @@ -306,9 +305,7 @@ object InstanceDefinition {
)
)
}
// scalastyle:on cyclomatic.complexity method.length

// scalastyle:off cyclomatic.complexity method.length
private def toInstancePropertyTypeOfNonList(
propValue: Json,
t: PropertyType
Expand Down Expand Up @@ -375,5 +372,4 @@ object InstanceDefinition {
)
)
}
// scalastyle:on cyclomatic.complexity method.length
}
2 changes: 0 additions & 2 deletions src/main/scala/com/cognite/sdk/scala/v1/propertyMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ object PropertyMap {
case _ => dmp.`type`.decodeProperty(c.downField(prop))
}

// scalastyle:off cyclomatic.complexity
private def asStringValue(json: Json): Option[String] =
json match {
case js if js.isString => js.asString
Expand All @@ -102,5 +101,4 @@ object PropertyMap {
case js if js.isArray => js.asArray.map(_.mkString(","))
case js => Some(js.toString())
}
// scalastyle:on cyclomatic.complexity
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import java.time.Instant
import scala.collection.JavaConverters._ // Avoid scala.jdk to keep 2.12 compatibility without scala-collection-compat
import scala.util.control.NonFatal

// scalastyle:off number.of.methods
class DataPointsResource[F[_]](val requestSession: RequestSession[F])
extends WithRequestSession[F]
with BaseUrl {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ trait DataPointsResourceBehaviors extends Matchers with OptionValues with RetryW

def withTimeSeries(testCode: TimeSeries => Any): Unit

// scalastyle:off
def dataPointsResource(dataPoints: DataPointsResource[IO])(implicit IORuntime: IORuntime): Unit = {
it should "be possible to insert and delete numerical data points" in withTimeSeries {
timeSeries =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class FilterTest extends SdkTestSpec with OptionValues {

@SuppressWarnings(Array("org.wartremover.warts.Null", "org.wartremover.warts.Var", "org.wartremover.warts.AsInstanceOf"))
def filterWithCursor(batchSize: Int, limit: Option[Int])(test: Int => Any): Any = {
var hijackedRequest: FilterRequest[DummyFilter] = null // scalastyle:ignore
var hijackedRequest: FilterRequest[DummyFilter] = null
val requestHijacker = SttpBackendStub.synchronous.whenAnyRequest.thenRespondF(req => {
hijackedRequest = decode[FilterRequest[DummyFilter]](req.body.asInstanceOf[StringBody].s) match {
case Right(x) => x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ trait ReadBehaviours extends Matchers with OptionValues with RetryWhile { this:
}
}

// scalastyle:off
def readableWithRetrieve[R <: WithId[Long], W](
readable: Readable[R, IO] with RetrieveByIds[R, IO],
idsThatDoNotExist: Seq[Long],
Expand Down
12 changes: 6 additions & 6 deletions src/test/scala/com/cognite/sdk/scala/common/SdkTestSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ class LoggingSttpBackend[F[_], +P](delegate: SttpBackend[F, P]) extends SttpBack
responseMonad.map(try {
responseMonad.handleError(delegate.send(request)) {
case e: Exception =>
println(s"Exception when sending request: ${request.toString}, ${e.toString}") // scalastyle:ignore
println(s"Exception when sending request: ${request.toString}, ${e.toString}")
responseMonad.error(e)
}
} catch {
case NonFatal(e) =>
println(s"Exception when sending request: ${request.toString}, ${e.toString}") // scalastyle:ignore
println(s"Exception when sending request: ${request.toString}, ${e.toString}")
throw e
}) { response =>
println(s"request ${request.body.toString}") // scalastyle:ignore
println(s"response ${response.toString}") // scalastyle:ignore
println(s"request ${request.body.toString}")
println(s"response ${response.toString}")
if (response.isSuccess) {
println(s"For request: ${request.toString} got response: ${response.toString}") // scalastyle:ignore
println(s"For request: ${request.toString} got response: ${response.toString}")
} else {
println(s"For request: ${request.toString} got response: ${response.toString}") // scalastyle:ignore
println(s"For request: ${request.toString} got response: ${response.toString}")
}
response
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ trait StringDataPointsResourceBehaviors extends Matchers with OptionValues with

def withStringTimeSeries(testCode: TimeSeries => Any): Unit

// scalastyle:off
def stringDataPointsResource(dataPoints: DataPointsResource[IO])(implicit ioRuntime: IORuntime): Unit = {
it should "be possible to insert and delete string data points" in withStringTimeSeries {
stringTimeSeries =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import org.scalatest.matchers.should.Matchers

@SuppressWarnings(Array("org.wartremover.warts.NonUnitStatements", "org.wartremover.warts.SizeIs"))
trait WritableBehaviors extends Matchers with OptionValues { this: AnyFlatSpec =>
// scalastyle:off
def writable[R <: ToCreate[W] with WithId[PrimitiveId], W, PrimitiveId](
writable: Create[R, W, IO] with CreateOne[R, W, IO],
maybeDeletable: Option[DeleteByIds[IO, PrimitiveId]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// SPDX-License-Identifier: MIT
// From https://gist.github.com/Daenyth/28243952f1fcfac6e8ef838040e8638e/9167a51f41322c53de492186c7bfab609fe78f8d

// scalastyle:off

package com.cognite.sdk.scala.common.internal

import cats.effect.kernel.Outcome
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/com/cognite/sdk/scala/v1/AssetsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class AssetsTest extends SdkTestSpec with ReadBehaviours with WritableBehaviors
Asset(name = "scala-sdk-update-2", description = Some("description-2"), dataSetId = Some(testDataSet.id))
)
private val assetUpdates = Seq(
Asset(name = "scala-sdk-update-1-1", description = null, dataSetId = Some(testDataSet.id)), // scalastyle:ignore null
Asset(name = "scala-sdk-update-1-1", description = null, dataSetId = Some(testDataSet.id)),
Asset(name = "scala-sdk-update-2-1")
)
it should behave like updatable(
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/com/cognite/sdk/scala/v1/DataSetsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DataSetsTest extends SdkTestSpec with ReadBehaviours with WritableBehavior
)

private val datasetUpdates = Seq(
DataSet(description = Some("desc-1-1"), name = null), // scalastyle:ignore null
DataSet(description = Some("desc-1-1"), name = null),
DataSet(
description = Some("desc-2-1"),
metadata = Some(Map("a" -> "b"))
Expand Down
Loading

0 comments on commit 2fe95e9

Please sign in to comment.