Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PIL-1155] Add lint and prePrChecks command #80

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package uk.gov.hmrc.pillar2.models.financial

import play.api.libs.json.Json
import play.api.libs.json.OFormat

import java.time.LocalDate
import play.api.libs.json.OFormat

final case class FinancialHistory(date: LocalDate, paymentType: String, amountPaid: BigDecimal, amountRepaid: BigDecimal)

Expand Down
27 changes: 15 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,31 @@ ThisBuild / majorVersion := 0
lazy val microservice = Project(appName, file("."))
.enablePlugins(play.sbt.PlayScala, SbtDistributablesPlugin)
.settings(
ScoverageKeys.coverageExcludedFiles :=
"<empty>;com.kenshoo.play.metrics.*;.*definition.*;prod.*;testOnlyDoNotUseInAppConf.*;.*stubs.*;.*models.*;" +
"app.*;.*BuildInfo.*;.*Routes.*;.*repositories.*;.*package.*;.*controllers.test.*;.*services.test.*;.*metrics.*",
ScoverageKeys.coverageMinimumStmtTotal := 80,
ScoverageKeys.coverageFailOnMinimum := true,
ScoverageKeys.coverageHighlighting := true,
PlayKeys.playDefaultPort := 10051,
Compile / scalafmtOnCompile := true,
Test / scalafmtOnCompile := true,
ScoverageKeys.coverageExcludedFiles :=
"<empty>;com.kenshoo.play.metrics.*;.*definition.*;prod.*;testOnlyDoNotUseInAppConf.*;.*stubs.*;.*models.*;" +
"app.*;.*BuildInfo.*;.*Routes.*;.*repositories.*;.*package.*;.*controllers.test.*;.*services.test.*;.*metrics.*",
ScoverageKeys.coverageMinimumStmtTotal := 80,
ScoverageKeys.coverageFailOnMinimum := true,
ScoverageKeys.coverageHighlighting := true,
PlayKeys.playDefaultPort := 10051,
Compile / scalafmtOnCompile := true,
Test / scalafmtOnCompile := true,
libraryDependencies ++= AppDependencies.compile ++ AppDependencies.test,
// https://www.scala-lang.org/2021/01/12/configuring-and-suppressing-warnings.html
// suppress warnings in generated routes files
scalacOptions += "-Wconf:src=routes/.*:s",
scalacOptions += "-Wconf:src=routes/.*:s"
)
.settings(
Compile / unmanagedResourceDirectories += baseDirectory.value / "resources",
Test / unmanagedSourceDirectories := (Test / baseDirectory)(base => Seq(base / "test", base / "test-common")).value,
Test / unmanagedResourceDirectories := Seq(baseDirectory.value / "test-resources"),
Test / unmanagedResourceDirectories := Seq(baseDirectory.value / "test-resources")
)
.settings(resolvers += Resolver.jcenterRepo)
.settings(CodeCoverageSettings.settings *)

addCommandAlias("prePrChecks", ";scalafmtCheckAll;scalafmtSbtCheck;scalafixAll --check")
addCommandAlias("lint", ";scalafmtAll;scalafmtSbt;scalafixAll")

lazy val it = project
.enablePlugins(play.sbt.PlayScala)
.dependsOn(microservice % "test->test")
Expand All @@ -47,4 +50,4 @@ inThisBuild(
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision
)
)
)
24 changes: 12 additions & 12 deletions project/AppDependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ object AppDependencies {
private val hmrcMongoVersion = "1.7.0"

val compile: Seq[ModuleID] = Seq(
"uk.gov.hmrc" %% "bootstrap-backend-play-30" % bootstrapVersion,
"uk.gov.hmrc.mongo" %% "hmrc-mongo-play-30" % hmrcMongoVersion,
"uk.gov.hmrc" %% "crypto-json-play-30" % "8.0.0"
"uk.gov.hmrc" %% "bootstrap-backend-play-30" % bootstrapVersion,
"uk.gov.hmrc.mongo" %% "hmrc-mongo-play-30" % hmrcMongoVersion,
"uk.gov.hmrc" %% "crypto-json-play-30" % "8.0.0"
)

val test: Seq[ModuleID] = Seq(
"org.scalatest" %% "scalatest" % "3.2.18" ,
"uk.gov.hmrc" %% "bootstrap-test-play-30" % bootstrapVersion,
"uk.gov.hmrc.mongo" %% "hmrc-mongo-test-play-30" % hmrcMongoVersion,
"org.mockito" % "mockito-core" % "5.11.0",
"org.scalatestplus" %% "mockito-4-11" % "3.2.18.0",
"org.scalatest" %% "scalatest" % "3.2.18",
"uk.gov.hmrc" %% "bootstrap-test-play-30" % bootstrapVersion,
"uk.gov.hmrc.mongo" %% "hmrc-mongo-test-play-30" % hmrcMongoVersion,
"org.mockito" % "mockito-core" % "5.11.0",
"org.scalatestplus" %% "mockito-4-11" % "3.2.18.0",
"org.scalatestplus" %% "scalatestplus-scalacheck" % "3.1.0.0-RC2",
"wolfendale" %% "scalacheck-gen-regexp" % "0.1.2",
"com.github.tomakehurst" % "wiremock-standalone" % "3.0.1",
"com.softwaremill.diffx" %% "diffx-core" % "0.9.0" ,
"com.softwaremill.diffx" %% "diffx-scalatest" % "0.9.0"
"wolfendale" %% "scalacheck-gen-regexp" % "0.1.2",
"com.github.tomakehurst" % "wiremock-standalone" % "3.0.1",
"com.softwaremill.diffx" %% "diffx-core" % "0.9.0",
"com.softwaremill.diffx" %% "diffx-scalatest" % "0.9.0"
).map(_ % Test)

val it: Seq[ModuleID] = Seq(
Expand Down
16 changes: 16 additions & 0 deletions test/uk/gov/hmrc/pillar2/connectors/ObligationConnectorSpec.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2024 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package uk.gov.hmrc.pillar2.connectors

import com.github.tomakehurst.wiremock.client.WireMock.{aResponse, get, urlEqualTo}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2024 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package uk.gov.hmrc.pillar2.controllers

import org.mockito.ArgumentMatchers.any
Expand Down
2 changes: 1 addition & 1 deletion test/uk/gov/hmrc/pillar2/generators/ModelGenerators.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package uk.gov.hmrc.pillar2.generators
import org.scalacheck.Arbitrary.arbitrary
import org.scalacheck.{Arbitrary, Gen}
import play.api.libs.json.{JsObject, JsValue, Json}
import uk.gov.hmrc.pillar2.models._
import uk.gov.hmrc.pillar2.models.audit._
import uk.gov.hmrc.pillar2.models.grs._
import uk.gov.hmrc.pillar2.models.hods._
Expand All @@ -28,7 +29,6 @@ import uk.gov.hmrc.pillar2.models.hods.subscription.common._
import uk.gov.hmrc.pillar2.models.hods.subscription.request.RequestDetail
import uk.gov.hmrc.pillar2.models.registration._
import uk.gov.hmrc.pillar2.models.subscription.{ReadSubscriptionRequestParameters, SubscriptionAddress, SubscriptionRequestParameters}
import uk.gov.hmrc.pillar2.models.{AccountStatus, AccountingPeriod, AccountingPeriodAmend, NonUKAddress, RowStatus, UKAddress, UserAnswers}

import java.time.{Instant, LocalDate}

Expand Down
4 changes: 2 additions & 2 deletions test/uk/gov/hmrc/pillar2/helpers/AllMocks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import org.scalatestplus.mockito.MockitoSugar
import uk.gov.hmrc.auth.core.{AuthConnector, AuthorisedFunctions}
import uk.gov.hmrc.http.HttpClient
import uk.gov.hmrc.pillar2.config.AppConfig
import uk.gov.hmrc.pillar2.connectors.{FinancialDataConnector, ObligationConnector, RegistrationConnector, RepaymentConnector, SubscriptionConnector}
import uk.gov.hmrc.pillar2.connectors._
import uk.gov.hmrc.pillar2.controllers.auth.AuthAction
import uk.gov.hmrc.pillar2.repositories.RegistrationCacheRepository
import uk.gov.hmrc.pillar2.service._
import uk.gov.hmrc.pillar2.service.audit.AuditService
import uk.gov.hmrc.pillar2.service.{FinancialService, RegistrationService, RepaymentService, SubscriptionService}
import uk.gov.hmrc.pillar2.utils.countryOptions.CountryOptions
import uk.gov.hmrc.play.audit.http.connector.AuditConnector

Expand Down