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

Update scalafmt-core to 3.7.15 #343

Merged
merged 3 commits into from
Oct 30, 2023
Merged
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
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Scala Steward: Reformat with scalafmt 3.7.15
b88124837b4632490181bbe02aa345a0292a9808
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.7.14"
version = "3.7.15"
maxColumn = 120
align.preset = most
align.multiline = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,35 @@ import org.apache.commons.lang3.StringUtils.{equalsAny, startsWithAny}
import zio.Chunk
import zio.prelude.{AssertionError, Validator}

object IndexPatternValidator extends Validator[String]( pattern => {
def containsAny(string: String, params: Chunk[String]): Boolean =
params.exists(StringUtils.contains(string, _))
object IndexPatternValidator
extends Validator[String](pattern => {
def containsAny(string: String, params: Chunk[String]): Boolean =
params.exists(StringUtils.contains(string, _))

def isValid(pattern: String): Boolean =
pattern.toLowerCase == pattern &&
!startsWithAny(pattern, "+") &&
pattern.nonEmpty &&
!containsAny(string = pattern, params = Chunk("?", "\"", "<", ">", "|", " ", ",", "#", ":")) &&
!equalsAny(pattern, ".", "..") &&
pattern.getBytes().length <= 255
def isValid(pattern: String): Boolean =
pattern.toLowerCase == pattern &&
!startsWithAny(pattern, "+") &&
pattern.nonEmpty &&
!containsAny(string = pattern, params = Chunk("?", "\"", "<", ">", "|", " ", ",", "#", ":")) &&
!equalsAny(pattern, ".", "..") &&
pattern.getBytes().length <= 255

if (isValid(pattern)) {
Right(())
} else {
Left(
AssertionError.Failure(
s"""
| - Must be lower case only
| - Cannot include \\, /, ?, ", <, >, |, ` `(space character), `,`(comma), #.
| - Cannot include ":"(since 7.0).
| - Cannot be empty
| - Cannot start with +.
| - Cannot be `.` or `..`.
| - Cannot be longer than 255 bytes (note it is bytes, so multi-byte characters will count towards the 255 limit faster).
| - Patterns starting with . are deprecated, except for hidden indices and internal indices managed by plugins.
|""".stripMargin
if (isValid(pattern)) {
Right(())
} else {
Left(
AssertionError.Failure(
s"""
| - Must be lower case only
| - Cannot include \\, /, ?, ", <, >, |, ` `(space character), `,`(comma), #.
| - Cannot include ":"(since 7.0).
| - Cannot be empty
| - Cannot start with +.
| - Cannot be `.` or `..`.
| - Cannot be longer than 255 bytes (note it is bytes, so multi-byte characters will count towards the 255 limit faster).
| - Patterns starting with . are deprecated, except for hidden indices and internal indices managed by plugins.
|""".stripMargin
)
)
)
}
})
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,3 @@ object MultiIndex {
def patterns(pattern: IndexPattern, patterns: IndexPattern*): MultiIndex =
MultiIndex(Chunk.fromIterable(pattern.toString +: patterns.map(IndexPattern.unwrap)))
}