From adc19cf109a88560ceed4a4df284cb5daef9e11a Mon Sep 17 00:00:00 2001 From: Lucas Burson Date: Sun, 28 Aug 2022 15:01:20 -0500 Subject: [PATCH] Apply scalafmt and require scalafmtCheck during CI build --- .github/workflows/scala.yml | 2 +- app/org/maproulette/data/SnapshotManager.scala | 1 - app/org/maproulette/filters/Filters.scala | 2 +- app/org/maproulette/filters/HttpLoggingFilter.scala | 6 +++--- .../framework/controller/FollowController.scala | 1 - .../framework/controller/NotificationController.scala | 2 -- .../framework/controller/TaskBundleController.scala | 1 - .../framework/controller/TaskReviewController.scala | 6 +----- .../controller/TaskReviewMetricsController.scala | 7 +------ .../framework/controller/TeamController.scala | 1 - .../framework/controller/UserController.scala | 8 +------- .../framework/mixins/SearchParametersMixin.scala | 1 - .../maproulette/framework/mixins/TaskFilterMixin.scala | 2 -- .../maproulette/framework/mixins/TaskParserMixin.scala | 1 - app/org/maproulette/framework/model/TaskLogEntry.scala | 2 +- .../repository/ChallengeSnapshotRespository.scala | 1 - .../framework/repository/TaskRepository.scala | 1 - .../framework/repository/TaskReviewRepository.scala | 6 ++++-- app/org/maproulette/framework/service/GrantService.scala | 1 - app/org/maproulette/framework/service/GroupService.scala | 1 - .../framework/service/NotificationService.scala | 1 - .../framework/service/TaskClusterService.scala | 2 +- app/org/maproulette/framework/service/TeamService.scala | 1 - app/org/maproulette/models/dal/ChallengeDAL.scala | 3 +-- app/org/maproulette/models/dal/TaskDAL.scala | 9 +-------- app/org/maproulette/provider/EmailProvider.scala | 1 - app/org/maproulette/session/TaskPropertySearch.scala | 1 - .../framework/repository/TaskClusterRepositorySpec.scala | 1 - .../framework/repository/TaskHistoryRepositorySpec.scala | 1 - .../framework/repository/TaskReviewRepositorySpec.scala | 1 - .../repository/UserSavedObjectsRepositorySpec.scala | 5 +---- .../framework/service/ChallengeSnapshotServiceSpec.scala | 1 - .../framework/service/TaskReviewServiceSpec.scala | 5 +---- 33 files changed, 18 insertions(+), 67 deletions(-) diff --git a/.github/workflows/scala.yml b/.github/workflows/scala.yml index 23a01ad0d..fd80bec9b 100644 --- a/.github/workflows/scala.yml +++ b/.github/workflows/scala.yml @@ -83,7 +83,7 @@ jobs: - name: Run sbt compile env: CI: true - run: sbt -Dsbt.log.format=false compile + run: sbt -Dsbt.log.format=false scalafmtCheckAll compile - name: Create the dev.conf run: | touch ./conf/dev.conf diff --git a/app/org/maproulette/data/SnapshotManager.scala b/app/org/maproulette/data/SnapshotManager.scala index a7b39ceeb..269497608 100644 --- a/app/org/maproulette/data/SnapshotManager.scala +++ b/app/org/maproulette/data/SnapshotManager.scala @@ -4,7 +4,6 @@ */ package org.maproulette.data - import anorm.SqlParser._ import anorm._ import javax.inject.{Inject, Singleton} diff --git a/app/org/maproulette/filters/Filters.scala b/app/org/maproulette/filters/Filters.scala index 3e02fa411..5ec12e717 100644 --- a/app/org/maproulette/filters/Filters.scala +++ b/app/org/maproulette/filters/Filters.scala @@ -13,4 +13,4 @@ import play.filters.gzip.GzipFilter * @author cuthbertm */ class Filters @Inject() (corsFilter: CORSFilter, gzipFilter: GzipFilter) - extends DefaultHttpFilters(corsFilter, gzipFilter) + extends DefaultHttpFilters(corsFilter, gzipFilter) diff --git a/app/org/maproulette/filters/HttpLoggingFilter.scala b/app/org/maproulette/filters/HttpLoggingFilter.scala index 5ebc040c7..37a32f4d8 100644 --- a/app/org/maproulette/filters/HttpLoggingFilter.scala +++ b/app/org/maproulette/filters/HttpLoggingFilter.scala @@ -14,9 +14,9 @@ import scala.concurrent.Future import scala.concurrent.ExecutionContext /** - * Filter to provide an http request log at the service side. The HttpLoggingFilter is enabled by default within - * application.conf but will create no output until logback is set to the debug or trace levels. - */ + * Filter to provide an http request log at the service side. The HttpLoggingFilter is enabled by default within + * application.conf but will create no output until logback is set to the debug or trace levels. + */ class HttpLoggingFilter @Inject() (implicit val mat: Materializer, ec: ExecutionContext) extends Filter { def apply( diff --git a/app/org/maproulette/framework/controller/FollowController.scala b/app/org/maproulette/framework/controller/FollowController.scala index 97bc93e53..dfd630147 100644 --- a/app/org/maproulette/framework/controller/FollowController.scala +++ b/app/org/maproulette/framework/controller/FollowController.scala @@ -5,7 +5,6 @@ package org.maproulette.framework.controller - import javax.inject.Inject import org.maproulette.data.ActionManager import org.maproulette.exception.NotFoundException diff --git a/app/org/maproulette/framework/controller/NotificationController.scala b/app/org/maproulette/framework/controller/NotificationController.scala index 27df32dda..8bf966e51 100644 --- a/app/org/maproulette/framework/controller/NotificationController.scala +++ b/app/org/maproulette/framework/controller/NotificationController.scala @@ -15,7 +15,6 @@ import org.maproulette.utils.{Crypto, Utils} import play.api.libs.json._ import play.api.mvc._ - /** * @author nrotstan */ @@ -28,7 +27,6 @@ class NotificationController @Inject() ( ) extends AbstractController(components) with DefaultWrites { - implicit val notificationSubscriptionReads = NotificationSubscriptions.notificationSubscriptionReads implicit val notificationSubscriptionWrites = diff --git a/app/org/maproulette/framework/controller/TaskBundleController.scala b/app/org/maproulette/framework/controller/TaskBundleController.scala index caf22f3f7..9ace5d417 100644 --- a/app/org/maproulette/framework/controller/TaskBundleController.scala +++ b/app/org/maproulette/framework/controller/TaskBundleController.scala @@ -5,7 +5,6 @@ package org.maproulette.framework.controller - import javax.inject.Inject import org.maproulette.exception.InvalidException import org.maproulette.data._ diff --git a/app/org/maproulette/framework/controller/TaskReviewController.scala b/app/org/maproulette/framework/controller/TaskReviewController.scala index 38802aa5b..35907d9ab 100644 --- a/app/org/maproulette/framework/controller/TaskReviewController.scala +++ b/app/org/maproulette/framework/controller/TaskReviewController.scala @@ -12,11 +12,7 @@ import org.maproulette.framework.psql.Paging import org.maproulette.framework.model.{Challenge, ChallengeListing, Project, User, Tag, Task} import org.maproulette.framework.mixins.{ParentMixin, TagsControllerMixin} import org.maproulette.framework.repository.TaskRepository -import org.maproulette.session.{ - SessionManager, - SearchParameters, - SearchLocation -} +import org.maproulette.session.{SessionManager, SearchParameters, SearchLocation} import org.maproulette.utils.Utils import play.api.mvc._ import play.api.libs.json._ diff --git a/app/org/maproulette/framework/controller/TaskReviewMetricsController.scala b/app/org/maproulette/framework/controller/TaskReviewMetricsController.scala index 2a5da41a5..4965cd28b 100644 --- a/app/org/maproulette/framework/controller/TaskReviewMetricsController.scala +++ b/app/org/maproulette/framework/controller/TaskReviewMetricsController.scala @@ -14,12 +14,7 @@ import org.maproulette.framework.service.{ UserService } import org.maproulette.framework.psql.Paging -import org.maproulette.framework.model.{ - Challenge, - User, - ReviewMetrics, - Task -} +import org.maproulette.framework.model.{Challenge, User, ReviewMetrics, Task} import org.maproulette.session.{SessionManager, SearchParameters, SearchTaskParameters} import org.maproulette.utils.Utils import play.api.mvc._ diff --git a/app/org/maproulette/framework/controller/TeamController.scala b/app/org/maproulette/framework/controller/TeamController.scala index 887e10e9c..c2cf2e995 100644 --- a/app/org/maproulette/framework/controller/TeamController.scala +++ b/app/org/maproulette/framework/controller/TeamController.scala @@ -5,7 +5,6 @@ package org.maproulette.framework.controller - import javax.inject.Inject import org.maproulette.data.ActionManager import org.maproulette.exception.{MPExceptionUtil, StatusMessage} diff --git a/app/org/maproulette/framework/controller/UserController.scala b/app/org/maproulette/framework/controller/UserController.scala index 129e2f3da..386832d09 100644 --- a/app/org/maproulette/framework/controller/UserController.scala +++ b/app/org/maproulette/framework/controller/UserController.scala @@ -6,13 +6,7 @@ package org.maproulette.framework.controller import javax.inject.Inject import org.maproulette.exception.{InvalidException, NotFoundException, StatusMessage} -import org.maproulette.framework.model.{ - Challenge, - User, - UserSettings, - GrantTarget, - Task -} +import org.maproulette.framework.model.{Challenge, User, UserSettings, GrantTarget, Task} import org.maproulette.framework.psql.Paging import org.maproulette.framework.service.ServiceManager import org.maproulette.framework.mixins.ParentMixin diff --git a/app/org/maproulette/framework/mixins/SearchParametersMixin.scala b/app/org/maproulette/framework/mixins/SearchParametersMixin.scala index b9cf931d1..9dad049cd 100644 --- a/app/org/maproulette/framework/mixins/SearchParametersMixin.scala +++ b/app/org/maproulette/framework/mixins/SearchParametersMixin.scala @@ -12,7 +12,6 @@ import org.maproulette.framework.psql.{AND, OR} import org.maproulette.framework.model.{TaskReview, Project, Challenge, Task} import play.api.libs.json.JsDefined - trait SearchParametersMixin { /** diff --git a/app/org/maproulette/framework/mixins/TaskFilterMixin.scala b/app/org/maproulette/framework/mixins/TaskFilterMixin.scala index a78e227f8..5fa78ba7c 100644 --- a/app/org/maproulette/framework/mixins/TaskFilterMixin.scala +++ b/app/org/maproulette/framework/mixins/TaskFilterMixin.scala @@ -4,13 +4,11 @@ */ package org.maproulette.framework.mixins - import org.maproulette.framework.model.{User, Challenge, Project} import org.maproulette.framework.psql.{Query, _} import org.maproulette.framework.psql.filter._ import org.maproulette.data.Actions - /** * TaskFilterMixin provides task related methods */ diff --git a/app/org/maproulette/framework/mixins/TaskParserMixin.scala b/app/org/maproulette/framework/mixins/TaskParserMixin.scala index dafbc3e2b..5665cc289 100644 --- a/app/org/maproulette/framework/mixins/TaskParserMixin.scala +++ b/app/org/maproulette/framework/mixins/TaskParserMixin.scala @@ -10,7 +10,6 @@ import org.joda.time.DateTime import org.maproulette.framework.model.{TaskReview, TaskReviewFields, TaskWithReview, Task} - /** * TaskParserMixin provides task parsers */ diff --git a/app/org/maproulette/framework/model/TaskLogEntry.scala b/app/org/maproulette/framework/model/TaskLogEntry.scala index 07ab62cdc..17a180174 100644 --- a/app/org/maproulette/framework/model/TaskLogEntry.scala +++ b/app/org/maproulette/framework/model/TaskLogEntry.scala @@ -26,7 +26,7 @@ case class TaskLogEntry( reviewRequestedBy: Option[Int], reviewedBy: Option[Int], comment: Option[String], - errorTags: Option[String], + errorTags: Option[String] ) {} object TaskLogEntry { diff --git a/app/org/maproulette/framework/repository/ChallengeSnapshotRespository.scala b/app/org/maproulette/framework/repository/ChallengeSnapshotRespository.scala index b1854c6c3..0d9dccdaf 100644 --- a/app/org/maproulette/framework/repository/ChallengeSnapshotRespository.scala +++ b/app/org/maproulette/framework/repository/ChallengeSnapshotRespository.scala @@ -5,7 +5,6 @@ package org.maproulette.framework.repository - import javax.inject.{Inject, Singleton} import org.maproulette.framework.psql.Query import org.maproulette.framework.psql.filter.BaseParameter diff --git a/app/org/maproulette/framework/repository/TaskRepository.scala b/app/org/maproulette/framework/repository/TaskRepository.scala index be9fdca4e..ce4d194dd 100644 --- a/app/org/maproulette/framework/repository/TaskRepository.scala +++ b/app/org/maproulette/framework/repository/TaskRepository.scala @@ -5,7 +5,6 @@ package org.maproulette.framework.repository - import anorm.SqlParser.{get, scalar, str} import anorm.ToParameterValue import anorm._, postgresql._ diff --git a/app/org/maproulette/framework/repository/TaskReviewRepository.scala b/app/org/maproulette/framework/repository/TaskReviewRepository.scala index b902f8ffb..43a499025 100644 --- a/app/org/maproulette/framework/repository/TaskReviewRepository.scala +++ b/app/org/maproulette/framework/repository/TaskReviewRepository.scala @@ -80,12 +80,14 @@ class TaskReviewRepository @Inject() ( .executeUpdate() for (task <- taskList) { - var querystring = """UPDATE task_review SET review_claimed_by = {userId}, review_claimed_at = NOW(), review_started_at = NOW() + var querystring = + """UPDATE task_review SET review_claimed_by = {userId}, review_claimed_at = NOW(), review_started_at = NOW() WHERE task_id = {taskId} AND review_claimed_at IS NULL""" //don't reset review_started_at if task has already been reviewed if (!task.review.reviewedAt.isEmpty) { - querystring = """UPDATE task_review SET review_claimed_by = {userId}, review_claimed_at = NOW() + querystring = + """UPDATE task_review SET review_claimed_by = {userId}, review_claimed_at = NOW() WHERE task_id = {taskId} AND review_claimed_at IS NULL""" } diff --git a/app/org/maproulette/framework/service/GrantService.scala b/app/org/maproulette/framework/service/GrantService.scala index 7e4a4fd47..6d9866c16 100644 --- a/app/org/maproulette/framework/service/GrantService.scala +++ b/app/org/maproulette/framework/service/GrantService.scala @@ -5,7 +5,6 @@ package org.maproulette.framework.service - import javax.inject.{Inject, Singleton} import org.maproulette.Config import org.maproulette.exception.InvalidException diff --git a/app/org/maproulette/framework/service/GroupService.scala b/app/org/maproulette/framework/service/GroupService.scala index 67b86fda1..33d8867f0 100644 --- a/app/org/maproulette/framework/service/GroupService.scala +++ b/app/org/maproulette/framework/service/GroupService.scala @@ -5,7 +5,6 @@ package org.maproulette.framework.service - import javax.inject.{Inject, Singleton} import org.maproulette.framework.model.{Group, GroupMember, MemberObject} import org.maproulette.data.{ItemType} diff --git a/app/org/maproulette/framework/service/NotificationService.scala b/app/org/maproulette/framework/service/NotificationService.scala index 9f5a38dec..3a325f13c 100644 --- a/app/org/maproulette/framework/service/NotificationService.scala +++ b/app/org/maproulette/framework/service/NotificationService.scala @@ -5,7 +5,6 @@ package org.maproulette.framework.service - import javax.inject.{Inject, Singleton} import org.maproulette.exception.{InvalidException, NotFoundException} import org.maproulette.data.{UserType} diff --git a/app/org/maproulette/framework/service/TaskClusterService.scala b/app/org/maproulette/framework/service/TaskClusterService.scala index 50bc6cb18..abc2cf704 100644 --- a/app/org/maproulette/framework/service/TaskClusterService.scala +++ b/app/org/maproulette/framework/service/TaskClusterService.scala @@ -38,7 +38,7 @@ class TaskClusterService @Inject() (repository: TaskClusterRepository) numberOfPoints: Int = this.repository.DEFAULT_NUMBER_OF_POINTS ): List[TaskCluster] = { val filtered = this.filterOnSearchParameters(params)(false) - val query = this.filterOutDeletedParents(filtered) + val query = this.filterOutDeletedParents(filtered) this.repository.queryTaskClusters(query, numberOfPoints, params) } diff --git a/app/org/maproulette/framework/service/TeamService.scala b/app/org/maproulette/framework/service/TeamService.scala index e468feec3..991b31a9f 100644 --- a/app/org/maproulette/framework/service/TeamService.scala +++ b/app/org/maproulette/framework/service/TeamService.scala @@ -5,7 +5,6 @@ package org.maproulette.framework.service - import javax.inject.{Inject, Singleton} import org.maproulette.exception.{InvalidException, NotFoundException} import org.maproulette.framework.model._ diff --git a/app/org/maproulette/models/dal/ChallengeDAL.scala b/app/org/maproulette/models/dal/ChallengeDAL.scala index 014e4cfff..5e8eb8a31 100644 --- a/app/org/maproulette/models/dal/ChallengeDAL.scala +++ b/app/org/maproulette/models/dal/ChallengeDAL.scala @@ -1428,7 +1428,7 @@ class ChallengeDAL @Inject() ( * @param c an implicit connection */ def moveChallenges(newParent: Long, challengeIds: List[Long], user: User)( - implicit c: Option[Connection] = None + implicit c: Option[Connection] = None ): List[Long] = { this.permission.hasAdminAccess(ProjectType(), user)(newParent) this.serviceManager.project.retrieve(newParent) match { @@ -1469,7 +1469,6 @@ class ChallengeDAL @Inject() ( movedChallengeIds.toList } - /** * Update the popularity score of the given challenge following completion of a task. * Challenge popularity p is calculated with the simple formula p = (p + t) / 2 where diff --git a/app/org/maproulette/models/dal/TaskDAL.scala b/app/org/maproulette/models/dal/TaskDAL.scala index 34f126405..738a38d14 100644 --- a/app/org/maproulette/models/dal/TaskDAL.scala +++ b/app/org/maproulette/models/dal/TaskDAL.scala @@ -17,14 +17,7 @@ import org.locationtech.jts.geom.Envelope import org.maproulette.Config import org.maproulette.data._ import org.maproulette.exception.{InvalidException, NotFoundException} -import org.maproulette.framework.model.{ - Challenge, - Project, - StatusActions, - User, - GrantTarget, - Task -} +import org.maproulette.framework.model.{Challenge, Project, StatusActions, User, GrantTarget, Task} import org.maproulette.framework.psql.filter.{BaseParameter, SubQueryFilter} import org.maproulette.framework.psql.{Order, Paging, Query} import org.maproulette.framework.repository.{ProjectRepository, TaskRepository} diff --git a/app/org/maproulette/provider/EmailProvider.scala b/app/org/maproulette/provider/EmailProvider.scala index 8104f0d1c..946762a2b 100644 --- a/app/org/maproulette/provider/EmailProvider.scala +++ b/app/org/maproulette/provider/EmailProvider.scala @@ -17,7 +17,6 @@ import org.maproulette.framework.model.{UserNotification, UserNotificationEmail} @Singleton class EmailProvider @Inject() (mailerClient: MailerClient, config: Config) { - def emailNotification(toAddress: String, notification: UserNotificationEmail) = { val notificationName = UserNotification.notificationTypeMap.get(notification.notificationType).get diff --git a/app/org/maproulette/session/TaskPropertySearch.scala b/app/org/maproulette/session/TaskPropertySearch.scala index 5eeb307eb..9dc4c0b7a 100644 --- a/app/org/maproulette/session/TaskPropertySearch.scala +++ b/app/org/maproulette/session/TaskPropertySearch.scala @@ -4,7 +4,6 @@ */ package org.maproulette.session - import org.maproulette.exception.InvalidException /** diff --git a/test/org/maproulette/framework/repository/TaskClusterRepositorySpec.scala b/test/org/maproulette/framework/repository/TaskClusterRepositorySpec.scala index 946f20e21..4d697e6e9 100644 --- a/test/org/maproulette/framework/repository/TaskClusterRepositorySpec.scala +++ b/test/org/maproulette/framework/repository/TaskClusterRepositorySpec.scala @@ -5,7 +5,6 @@ package org.maproulette.framework.repository - import org.maproulette.framework.model.{User, Task} import org.maproulette.framework.util.{TaskTag, FrameworkHelper} import org.maproulette.framework.psql.Query diff --git a/test/org/maproulette/framework/repository/TaskHistoryRepositorySpec.scala b/test/org/maproulette/framework/repository/TaskHistoryRepositorySpec.scala index 8613861a4..5f43af9a8 100644 --- a/test/org/maproulette/framework/repository/TaskHistoryRepositorySpec.scala +++ b/test/org/maproulette/framework/repository/TaskHistoryRepositorySpec.scala @@ -5,7 +5,6 @@ package org.maproulette.framework.repository - import org.maproulette.data.{Actions, TaskItem, ActionManager, TaskStatusSet} import org.maproulette.framework.model.{User, TaskLogEntry, Task} import org.maproulette.framework.util.{TaskTag, FrameworkHelper} diff --git a/test/org/maproulette/framework/repository/TaskReviewRepositorySpec.scala b/test/org/maproulette/framework/repository/TaskReviewRepositorySpec.scala index 4af9e748f..36231d456 100644 --- a/test/org/maproulette/framework/repository/TaskReviewRepositorySpec.scala +++ b/test/org/maproulette/framework/repository/TaskReviewRepositorySpec.scala @@ -5,7 +5,6 @@ package org.maproulette.framework.repository - import org.maproulette.framework.model.User import org.maproulette.framework.util.{TaskReviewTag, FrameworkHelper} import play.api.Application diff --git a/test/org/maproulette/framework/repository/UserSavedObjectsRepositorySpec.scala b/test/org/maproulette/framework/repository/UserSavedObjectsRepositorySpec.scala index 1d8925950..08bdb4b9f 100644 --- a/test/org/maproulette/framework/repository/UserSavedObjectsRepositorySpec.scala +++ b/test/org/maproulette/framework/repository/UserSavedObjectsRepositorySpec.scala @@ -6,10 +6,7 @@ package org.maproulette.framework.repository import org.maproulette.framework.model.User -import org.maproulette.framework.util.{ - FrameworkHelper, - UserSavedObjectsRepoTag -} +import org.maproulette.framework.util.{FrameworkHelper, UserSavedObjectsRepoTag} import play.api.Application /** diff --git a/test/org/maproulette/framework/service/ChallengeSnapshotServiceSpec.scala b/test/org/maproulette/framework/service/ChallengeSnapshotServiceSpec.scala index 4c1ae5061..6c5d5483d 100644 --- a/test/org/maproulette/framework/service/ChallengeSnapshotServiceSpec.scala +++ b/test/org/maproulette/framework/service/ChallengeSnapshotServiceSpec.scala @@ -5,7 +5,6 @@ package org.maproulette.framework.service - import org.maproulette.framework.util.{ChallengeSnapshotTag, FrameworkHelper} import org.maproulette.data.SnapshotManager import play.api.Application diff --git a/test/org/maproulette/framework/service/TaskReviewServiceSpec.scala b/test/org/maproulette/framework/service/TaskReviewServiceSpec.scala index 382e6137d..c5e927d81 100644 --- a/test/org/maproulette/framework/service/TaskReviewServiceSpec.scala +++ b/test/org/maproulette/framework/service/TaskReviewServiceSpec.scala @@ -10,10 +10,7 @@ import java.util.concurrent.TimeUnit import scala.concurrent.duration.FiniteDuration import play.api.libs.json.Json -import org.maproulette.session.{ - SearchParameters, - SearchTaskParameters -} +import org.maproulette.session.{SearchParameters, SearchTaskParameters} import org.maproulette.framework.model._ import org.maproulette.framework.util.{TaskReviewTag, FrameworkHelper} import org.maproulette.models.dal.{ChallengeDAL, TaskDAL}