Skip to content
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
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Scala Steward: Reformat with scalafmt 3.7.17
64d75796ea0483a6708ad2ada181eea9256e6bdd

# Scala Steward: Reformat with scalafmt 3.10.7
094d8602fd0dd6794e2ee330820d302442c4924a
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=3.7.17
version=3.10.7
runner.dialect = scala213
maxColumn = 100
6 changes: 4 additions & 2 deletions apps/checker/app/matchers/LanguageToolMatcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class LanguageToolFactory(
private def getLTRulesFromXML(rules: List[LTRuleXML]): Try[List[AbstractPatternRule]] =
rules match {
case Nil => Success(Nil)
case r => {
case r => {
val loader = new PatternRuleLoader()
getXMLStreamFromLTRules(rules) flatMap { xmlStream =>
{
Expand Down Expand Up @@ -173,7 +173,9 @@ class LanguageToolFactory(
additionalMessage: String = ""
) =
new Exception(
s"Error applying LanguageTool rule `${ruleId}`: ${e.getMessage} ${if (additionalMessage.nonEmpty) additionalMessage
s"Error applying LanguageTool rule `${ruleId}`: ${e.getMessage} ${if (
additionalMessage.nonEmpty
) additionalMessage
else ""}".trim,
e
)
Expand Down
4 changes: 2 additions & 2 deletions apps/checker/app/services/MatcherPool.scala
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class MatcherPool(
private def getMatchesForJob(job: MatcherPoolJob): Future[(MatcherPoolJob, List[RuleMatch])] = {
val maybeMatchesForJob = for {
matchers <- job match {
case categoryJob: MatcherPoolCategoryJob => getMatchersForJob(categoryJob)
case categoryJob: MatcherPoolCategoryJob => getMatchersForJob(categoryJob)
case singleMatcherJob: MatcherPoolSingleMatcherJob =>
Success(List(singleMatcherJob.matcher))
}
Expand Down Expand Up @@ -378,7 +378,7 @@ class MatcherPool(
*/
private def getApplicableCategories(query: Check) =
(query.categoryIds, query.excludeCategoryIds) match {
case (Some(ids), _) if ids.nonEmpty => ids
case (Some(ids), _) if ids.nonEmpty => ids
case (_, Some(excludeIds)) if excludeIds.nonEmpty =>
getCurrentCategories.map(_.id).filter(!excludeIds.contains(_))
case _ => getCurrentCategories.map(_.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class MatcherProvisionerService(
bucketRuleResource.getRulesLastModified match {
case Right(date) if date.compareTo(lastModified) > 0 => updateRulesFromBucket()
case Right(_) => logger.info("No rule update needed")
case Left(error) =>
case Left(error) =>
logger.error(s"Could not get last modified from S3", error)
cloudWatchClient.putMetric(Metrics.RulesNotFound)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ object AppSetup {
}

val config = ConfigurationLoader.load(identity, credsV2) {
case identity: AwsIdentity => SSMConfigurationLocation.default(identity)
case identity: AwsIdentity => SSMConfigurationLocation.default(identity)
case development: DevIdentity =>
SSMConfigurationLocation(s"/DEV/flexible/${development.app}", region)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ object LTRule {
rule.patternTokens.getOrElse(List[PatternToken]()).map(PatternToken.toLT).asJava
val language = Languages.getLanguageForShortCode(rule.languageShortcode.getOrElse("en-GB"))
val message = rule.suggestions match {
case Nil => rule.message
case Nil => rule.message
case suggestions =>
val ruleMessage = if (rule.message == "") "" else rule.message + ". "
ruleMessage.concat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ case class RuleMatch(
/** Map the range this match applies to through the given ranges, adjusting its range accordingly.
*/
def mapThroughSkippedRanges(skipRanges: List[TextRange]): RuleMatch = skipRanges match {
case Nil => this
case Nil => this
case skipRanges => {
val (newMatch, _) = skipRanges.foldLeft((this, List.empty[TextRange]))((acc, range) =>
acc match {
Expand Down
28 changes: 14 additions & 14 deletions apps/rule-manager/app/controllers/RulesController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class RulesController(
def refresh = APIAuthAction { implicit request =>
hasPermission(request.user, PermissionDefinition("manage_rules", "typerighter")) match {
case false => Unauthorized("You don't have permission to refresh rules")
case true =>
case true =>
val maybeWrittenRules = for {
dbRules <- sheetsRuleResource
.getRules()
Expand All @@ -53,7 +53,7 @@ class RulesController(
def refreshDictionaryRules() = APIAuthAction { implicit request =>
hasPermission(request.user, PermissionDefinition("manage_rules", "typerighter")) match {
case false => Unauthorized("You don't have permission to refresh dictionary rules")
case true =>
case true =>
val wordsOrError = dictionaryResource.getDictionaryWords()
val wordsToNotPublish = dictionaryResource.getWordsToNotPublish()

Expand Down Expand Up @@ -85,7 +85,7 @@ class RulesController(

def get(id: Int) = APIAuthAction {
RuleManager.getAllRuleData(id) match {
case None => NotFound("Rule not found matching ID")
case None => NotFound("Rule not found matching ID")
case Some(allRuleData) =>
Ok(Json.toJson(allRuleData))
}
Expand All @@ -94,15 +94,15 @@ class RulesController(
def publish(id: Int) = APIAuthAction { implicit request =>
hasPermission(request.user, PermissionDefinition("manage_rules", "typerighter")) match {
case false => Unauthorized("You don't have permission to publish rules")
case true =>
case true =>
PublishRuleForm.form
.bindFromRequest()
.fold(
form => BadRequest(Json.toJson(FormErrorEnvelope(form.errors))),
reason => {
DbRuleDraft.find(id) match {
case None => NotFound
case _ =>
case _ =>
RuleManager
.publishRule(id, request.user.email, reason, bucketRuleResource) match {
case Right(result) => Ok(Json.toJson(result))
Expand All @@ -118,7 +118,7 @@ class RulesController(
{
hasPermission(request.user, PermissionDefinition("manage_rules", "typerighter")) match {
case false => Unauthorized("You don't have permission to create rules")
case true =>
case true =>
CreateRuleForm.form
.bindFromRequest()
.fold(
Expand All @@ -140,7 +140,7 @@ class RulesController(
def update(id: Int) = APIAuthAction { implicit request =>
hasPermission(request.user, PermissionDefinition("manage_rules", "typerighter")) match {
case false => Unauthorized("You don't have permission to edit rules")
case true =>
case true =>
UpdateRuleForm.form
.bindFromRequest()
.fold(
Expand Down Expand Up @@ -171,7 +171,7 @@ class RulesController(
def batchUpdate() = APIAuthAction { implicit request =>
hasPermission(request.user, PermissionDefinition("manage_rules", "typerighter")) match {
case false => Unauthorized("You don't have permission to edit rules")
case true =>
case true =>
BatchUpdateRuleForm.form
.bindFromRequest()
.fold(
Expand Down Expand Up @@ -205,7 +205,7 @@ class RulesController(
def unpublish(id: Int): Action[AnyContent] = APIAuthAction { implicit request =>
hasPermission(request.user, PermissionDefinition("manage_rules", "typerighter")) match {
case false => Unauthorized("You don't have permission to unpublish rules")
case true =>
case true =>
RuleManager.unpublishRule(id, request.user.email, bucketRuleResource) match {
case Left(e: Throwable) => InternalServerError(e.getMessage)
case Right(allRuleData) => Ok(Json.toJson(allRuleData))
Expand All @@ -216,7 +216,7 @@ class RulesController(
def archive(id: Int): Action[AnyContent] = APIAuthAction { implicit request =>
hasPermission(request.user, PermissionDefinition("manage_rules", "typerighter")) match {
case false => Unauthorized("You don't have permission to archive rules")
case true =>
case true =>
RuleManager.archiveRule(id, request.user.email) match {
case Left(e: Throwable) => InternalServerError(e.getMessage)
case Right(allRuleData) => Ok(Json.toJson(allRuleData))
Expand All @@ -227,7 +227,7 @@ class RulesController(
def unarchive(id: Int): Action[AnyContent] = APIAuthAction { implicit request =>
hasPermission(request.user, PermissionDefinition("manage_rules", "typerighter")) match {
case false => Unauthorized("You don't have permission to unarchive rules")
case true =>
case true =>
RuleManager.unarchiveRule(id, request.user.email) match {
case Left(e: Throwable) => InternalServerError(e.getMessage)
case Right(allRuleData) => Ok(Json.toJson(allRuleData))
Expand All @@ -238,7 +238,7 @@ class RulesController(
def discardChanges(id: Int) = APIAuthAction { implicit request =>
hasPermission(request.user, PermissionDefinition("manage_rules", "typerighter")) match {
case false => Unauthorized("You don't have permission to edit rules")
case true =>
case true =>
revertDraftRule(id, request.user.email) match {
case Left(throwable) => InternalServerError(throwable.getMessage)
case Right(data) => Ok(Json.toJson(data))
Expand Down Expand Up @@ -283,7 +283,7 @@ class RulesController(
def csvImport() = APIAuthAction { implicit request =>
hasPermission(request.user, PermissionDefinition("manage_rules", "typerighter")) match {
case false => Unauthorized("You don't have permission to edit rules")
case true =>
case true =>
val rules = for {
formData <- request.body.asMultipartFormData.toRight("No form data found in request")
file <- formData.file("file").toRight("No file found in request")
Expand All @@ -307,7 +307,7 @@ class RulesController(
def archiveRulesByTag() = APIAuthAction { implicit request =>
hasPermission(request.user, PermissionDefinition("manage_rules", "typerighter")) match {
case false => Unauthorized("You don't have permission to edit rules")
case true =>
case true =>
val rules = for {
formData <- request.body.asMultipartFormData.toRight("No form data found in request")
tag = formData.dataParts.get("tag").flatMap(_.headOption)
Expand Down
8 changes: 4 additions & 4 deletions apps/rule-manager/app/controllers/TagsController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ class TagsController(

def get(id: Int) = APIAuthAction {
Tags.find(id) match {
case None => NotFound("Tag not found matching ID")
case None => NotFound("Tag not found matching ID")
case Some(tag) =>
Ok(Json.toJson(tag))
}
}

def delete(id: Int) = APIAuthAction {
Tags.find(id) match {
case None => NotFound("Tag not found matching ID")
case None => NotFound("Tag not found matching ID")
case Some(tag) =>
RuleTagDraft.destroyForTag(tag.id.get)
RuleTagLive.destroyForTag(tag.id.get)
Expand All @@ -55,7 +55,7 @@ class TagsController(
{
hasPermission(request.user, PermissionDefinition("manage_rules", "typerighter")) match {
case false => Unauthorized("You don't have permission to create tags")
case true =>
case true =>
TagForm.form
.bindFromRequest()
.fold(
Expand All @@ -77,7 +77,7 @@ class TagsController(
def update(id: Int) = APIAuthAction { implicit request =>
hasPermission(request.user, PermissionDefinition("manage_rules", "typerighter")) match {
case false => Unauthorized("You don't have permission to edit rules")
case true =>
case true =>
TagForm.form
.bindFromRequest()
.fold(
Expand Down
4 changes: 2 additions & 2 deletions apps/rule-manager/app/db/DbRuleDraft.scala
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ object DbRuleDraft extends SQLSyntaxSupport[DbRuleDraft] {

val condition =
searchClause.toList ++ tagFilterClause.toList ++ ruleTypeFilterClause.toList match {
case Nil => sqls.empty
case Nil => sqls.empty
case clauses =>
sqls"WHERE ${sqls.join(clauses, sqls"AND")}"
}
Expand Down Expand Up @@ -452,7 +452,7 @@ object DbRuleDraft extends SQLSyntaxSupport[DbRuleDraft] {

find(id) match {
case Some(rule) => Success(rule)
case None =>
case None =>
Failure(
new Exception(
s"Attempted to create a rule with id $id, but no result found attempting to read it back"
Expand Down
2 changes: 1 addition & 1 deletion apps/rule-manager/app/db/DbRuleLive.scala
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ object DbRuleLive extends SQLSyntaxSupport[DbRuleLive] {

findRevision(generatedKey.get, liveRule.revisionId) match {
case Some(rule) => rule
case None =>
case None =>
throw new Exception(
s"Attempted to create a rule with id $generatedKey, but no result found attempting to read it back"
)
Expand Down
2 changes: 1 addition & 1 deletion apps/rule-manager/app/db/RuleTagDraft.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ object RuleTagDraft extends SQLSyntaxSupport[RuleTagDraft] {
}.update().apply()
find(ruleId, tagId) match {
case Some(rule) => Success(rule)
case None =>
case None =>
Failure(
new Exception(
s"Attempted to create a tag with id $generatedKey, but no result found attempting to read it back"
Expand Down
2 changes: 1 addition & 1 deletion apps/rule-manager/app/db/RuleTagLive.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ object RuleTagLive extends SQLSyntaxSupport[RuleTagLive] {
}.update().apply()
find(externalId, revisionId, tagId) match {
case Some(ruleTagLive) => Success(ruleTagLive)
case None =>
case None =>
Failure(
new Exception(
s"Attempted to create a RuleTagLive with id $tagId, but no result found attempting to read it back"
Expand Down
2 changes: 1 addition & 1 deletion apps/rule-manager/app/db/Tags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ object Tags extends SQLSyntaxSupport[Tag] {
}.updateAndReturnGeneratedKey().apply()
find(generatedKey.toInt) match {
case Some(rule) => Success(rule)
case None =>
case None =>
Failure(
new Exception(
s"Attempted to create a tag with id $generatedKey, but no result found attempting to read it back"
Expand Down
4 changes: 2 additions & 2 deletions apps/rule-manager/app/model/CheckerRuleForm.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import scala.xml.XML
object RegexRuleForm {
val regexConstraint: Constraint[String] = Constraint("constraints.regexcheck") { regexStr =>
Try(regexStr.r) match {
case Success(_) => Valid
case Success(_) => Valid
case Failure(exception) =>
Invalid(
Seq(ValidationError(s"Error parsing the regular expression: ${exception.getMessage()}"))
Expand Down Expand Up @@ -58,7 +58,7 @@ object RegexRuleForm {
object LTRuleXMLForm {
val xmlConstraint: Constraint[String] = Constraint("constraints.xmlcheck") { xmlStr =>
Try(XML.loadString(xmlStr)) match {
case Success(_) => Valid
case Success(_) => Valid
case Failure(exception) =>
Invalid(Seq(ValidationError(s"Error parsing the XML: ${exception.getMessage()}")))
}
Expand Down
2 changes: 1 addition & 1 deletion apps/rule-manager/app/model/CreateRuleForm.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object CreateRuleForm {
case RuleType.languageToolCore => Nil
case RuleType.languageToolXML => Nil
case RuleType.dictionary => Nil
case _ =>
case _ =>
Seq(
ValidationError(
s"RuleType must be one of \"${RuleType.regex}\", \"${RuleType.languageToolXML}\", \"${RuleType.languageToolCore}\" or \"${RuleType.dictionary}\""
Expand Down
2 changes: 1 addition & 1 deletion apps/rule-manager/app/model/UpdateRuleForm.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object UpdateRuleForm {
case Some(RuleType.languageToolCore) => Nil
case Some(RuleType.languageToolXML) => Nil
case Some(RuleType.dictionary) => Nil
case _ =>
case _ =>
Seq(
ValidationError(
s"RuleType must be one of \"${RuleType.regex}\", \"${RuleType.languageToolXML}\", \"${RuleType.languageToolCore}\" or \"${RuleType.dictionary}\""
Expand Down
2 changes: 1 addition & 1 deletion apps/rule-manager/app/service/DictionaryResource.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DictionaryResource(s3: S3Client, bucketName: String, stage: String) {
})

words match {
case Success(words) => Right(words)
case Success(words) => Right(words)
case Failure(exception) =>
Left(Seq(FormError("dictionary-parse-error", exception.getMessage)))
}
Expand Down
2 changes: 1 addition & 1 deletion apps/rule-manager/app/utils/Dictionary.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object Dictionary {

def lemmaOrInflListToText(node: Node): Set[String] = {
node match {
case node if node.label == "lemma" => Set(node.text)
case node if node.label == "lemma" => Set(node.text)
case node if node.label == "infl_list" =>
node.child.filter(_.label == "infl").map(_.text).toSet
case _ => Set.empty
Expand Down
Loading
Loading