lint(Scout): minor linting

This commit is contained in:
Cilly Leang 2026-02-18 03:15:33 +11:00
parent e4ab9f936d
commit e50bb66c40
Signed by: cilly
GPG key ID: 6500251E087653C9
5 changed files with 12 additions and 12 deletions

View file

@ -1,3 +1,5 @@
@file:Suppress("EnumValuesSoftDeprecate")
package moe.lava.awoocord.scout.parsing
import android.content.Context
@ -41,7 +43,7 @@ class AuthorTypeNode(val type: AuthorType): AnswerNode() {
}
fun getFilterRule(str: String): ParserRule {
val regex = Pattern.compile("^\\s*?(${str}):", 64);
val regex = Pattern.compile("^\\s*?(${str}):", 64)
return SimpleParserRule(regex) { _, _, obj ->
ParseSpec(FilterNode(FilterTypeExtension.AUTHOR_TYPE, str), obj)
}

View file

@ -20,9 +20,7 @@ class DateNode(private val date: Long?, private val unparsed: String) : AnswerNo
val fmt = SimpleDateFormat("yyyy-MM-dd", Locale.US)
val regex: Pattern = Pattern.compile("^\\d{4}-\\d{2}-\\d{2}", Pattern.UNICODE_CASE)
fun getDateRule(): ParserRule {
return SimpleParserRule(regex) { matcher, parser, obj ->
checkNotNull(matcher) { "matcher" }
checkNotNull(parser) { "parser" }
return SimpleParserRule(regex) { matcher, _, obj ->
val match = matcher.group()
val date = fmt.parse(match)
val node = DateNode(date?.time, match)
@ -31,7 +29,7 @@ class DateNode(private val date: Long?, private val unparsed: String) : AnswerNo
}
private fun getFilterRule(str: String, type: FilterType): ParserRule {
val regex = Pattern.compile("^\\s*?(${str}):", 64);
val regex = Pattern.compile("^\\s*?(${str}):", 64)
return SimpleParserRule(regex) { _, _, obj ->
ParseSpec(FilterNode(type, str), obj)
}
@ -44,7 +42,7 @@ class DateNode(private val date: Long?, private val unparsed: String) : AnswerNo
override fun getValidFilters(): Set<FilterType> = FilterTypeExtension.dates.toSet()
override fun isValid(searchData: SearchData?): Boolean = date != null
override fun getText(): CharSequence? = unparsed
override fun getText(): CharSequence = unparsed
private val snowflake: String?
get() = date?.let { SnowflakeUtils.fromTimestamp(date).toString() }

View file

@ -1,7 +1,9 @@
package moe.lava.awoocord.scout.parsing
import android.content.Context
import com.discord.simpleast.core.parser.*
import com.discord.simpleast.core.parser.ParseSpec
import com.discord.simpleast.core.parser.Parser
import com.discord.simpleast.core.parser.Rule
import com.discord.utilities.search.query.node.QueryNode
import java.util.regex.Matcher
import java.util.regex.Pattern
@ -16,12 +18,10 @@ internal class SimpleParserRule(
) -> ParseSpec<Context, Any?>
) : ParserRule(regex) {
override fun parse(
matcher: Matcher?,
matcher: Matcher,
parser: Parser<Context, in QueryNode, in Any?>,
obj: Any?
): ParseSpec<Context, in Any?> {
checkNotNull(matcher) { "matcher" }
checkNotNull(parser) { "parser" }
return parseMethod(matcher, parser, obj)
}
}

View file

@ -24,7 +24,7 @@ class SortNode(private val text: String): AnswerNode() {
}
fun getFilterRule(str: String): ParserRule {
val regex = Pattern.compile("^\\s*?(${str}):", 64);
val regex = Pattern.compile("^\\s*?(${str}):", 64)
return SimpleParserRule(regex) { _, _, obj ->
ParseSpec(FilterNode(FilterTypeExtension.SORT, str), obj)
}

View file

@ -22,7 +22,7 @@ class UserIdNode(private val userID: String) : AnswerNode() {
override fun getValidFilters() = setOf(FilterType.FROM, FilterType.MENTIONS)
override fun isValid(searchData: SearchData?) = true
override fun getText() = userID.toString()
override fun getText() = userID
override fun updateQuery(
builder: SearchQuery.Builder?,