Skip to content

Commit

Permalink
#684 Sonar/Codacy code quality updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dk1844 committed Oct 21, 2022
1 parent c5e7a36 commit e366788
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions admin/src/main/scala/za/co/absa/spline/admin/DateTimeUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package za.co.absa.spline.admin
import java.time.format.{DateTimeFormatter, DateTimeFormatterBuilder}
import java.time.temporal.ChronoField
import java.time.{ZoneId, ZonedDateTime}

import scala.util.{Failure, Success, Try}
import scala.util.control.NonFatal

object DateTimeUtils {
Expand All @@ -28,7 +28,7 @@ object DateTimeUtils {
"^" +
"""([\dT:.+\-]+?)""".r + // local datetime
"""(Z|[+\-]\d\d:\d\d)?""".r + // timezone offset
"""(?:\[([\w/\-+]+)])?""".r + // timezone name
"""(?:\[([\w/+\-]+)])?""".r + // timezone name
"$").r

private val ZonedDateTimeFormatter = new DateTimeFormatterBuilder()
Expand All @@ -42,7 +42,7 @@ object DateTimeUtils {
.toFormatter();

def parseZonedDateTime(s: String, defaultZoneId: ZoneId = ZoneId.systemDefault): ZonedDateTime =
try {
Try {
val ZonedDateTimeRegexp(ldt, tzOffset, tzId) = s
val maybeTzIds = Seq(tzId, tzOffset).map(Option.apply)

Expand All @@ -53,8 +53,8 @@ object DateTimeUtils {
.getOrElse(defaultZoneId)

ZonedDateTime.parse(ldt, ZonedDateTimeFormatter.withZone(tz))

} catch {
case NonFatal(e) => throw new IllegalArgumentException(s"Cannot parse zoned datetime: $s", e)
} match {
case Success(zonedTime) => zonedTime
case Failure(nfe@NonFatal(_)) => throw new IllegalArgumentException(s"Cannot parse zoned datetime: $s", nfe)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ class ArangoManagerImplSpec

object ArangoManagerImplSpec {
private def newManager(
drmMock: DataRetentionManager = null,
clock: Clock = null,
migratorMock: Migrator = null,
foxxManagerMock: FoxxManager = null,
dbVersionManagerMock: DatabaseVersionManager = null,
appDbVersion: SemanticVersion = null
drmMock: DataRetentionManager = null, // NOSONAR
clock: Clock = null, // NOSONAR
migratorMock: Migrator = null, // NOSONAR
foxxManagerMock: FoxxManager = null, // NOSONAR
dbVersionManagerMock: DatabaseVersionManager = null, // NOSONAR
appDbVersion: SemanticVersion = null // NOSONAR
)(implicit ec: ExecutionContext): ArangoManagerImpl = {
new ArangoManagerImpl(
mock[ArangoDatabaseAsync],
Expand Down

0 comments on commit e366788

Please sign in to comment.