Skip to content

Commit

Permalink
fix: detekt issues
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeltonholo committed Dec 11, 2024
1 parent b94bfbd commit 835c608
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import dev.tonholo.s2c.domain.xml.XmlNode
import dev.tonholo.s2c.domain.xml.XmlParentNode
import dev.tonholo.s2c.domain.xml.XmlTextNode
import dev.tonholo.s2c.extensions.firstInstanceOf
import dev.tonholo.s2c.lexer.css.CssTokenizer
import dev.tonholo.s2c.lexer.css.CssTokenKind
import dev.tonholo.s2c.lexer.css.CssTokenizer
import dev.tonholo.s2c.parser.ast.AstParser
import dev.tonholo.s2c.parser.ast.css.syntax.node.StyleSheet

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.tonholo.s2c.extensions

import kotlin.math.max
import kotlin.math.roundToInt

private const val PERCENT = 100f

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ sealed class CssTokenKind(
data object Percentage : CssTokenKind(representation = "%")
data object HexDigit : CssTokenKind(representation = "")
data object String : CssTokenKind(representation = "")

// Missing end quote, mismatched quotes (missing start quote will yield one or more identifiers)
data object InvalidString : CssTokenKind(representation = "")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.tonholo.s2c.lexer.css

import dev.tonholo.s2c.extensions.EMPTY
import dev.tonholo.s2c.lexer.Tokenizer
import dev.tonholo.s2c.lexer.Token
import dev.tonholo.s2c.lexer.Tokenizer

internal class CssTokenizer : Tokenizer<CssTokenKind> {
private var offset = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ private fun Selector.PseudoClass.calculateSpecificity(): CssSpecificity {
"not",
"is",
"has",
"matches",
-> {
"matches" -> {
parameters
.maxOf { it.calculateSpecificity() }
.also {
Expand All @@ -122,8 +121,7 @@ private fun Selector.PseudoClass.calculateSpecificity(): CssSpecificity {
}

"nth-child",
"nth-last-child",
-> {
"nth-last-child" -> {
parameters
.maxOf { it.calculateSpecificity() }
.also {
Expand All @@ -136,8 +134,7 @@ private fun Selector.PseudoClass.calculateSpecificity(): CssSpecificity {
"before",
"after",
"first-line",
"first-letter",
-> {
"first-letter" -> {
c = 1
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package dev.tonholo.s2c.parser.ast.css.consumer

import dev.tonholo.s2c.lexer.css.CssTokenKind
import dev.tonholo.s2c.parser.ast.css.CssCombinator
import dev.tonholo.s2c.parser.ast.css.syntax.node.AtRule
import dev.tonholo.s2c.parser.ast.css.syntax.node.CssLocation
import dev.tonholo.s2c.parser.ast.css.syntax.node.CssNode
import dev.tonholo.s2c.parser.ast.css.syntax.node.Selector
import dev.tonholo.s2c.parser.ast.css.syntax.node.SelectorListItem
import dev.tonholo.s2c.parser.ast.iterator.AstParserIterator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ internal class CssIterator(
i++
}

(token.kind is CssTokenKind.WhiteSpace &&
prev?.kind in CssTokenKind.WhiteSpace.significantAdjacentTokens &&
next.kind in CssTokenKind.WhiteSpace.significantAdjacentTokens) -> i++
(
token.kind is CssTokenKind.WhiteSpace &&
prev?.kind in CssTokenKind.WhiteSpace.significantAdjacentTokens &&
next.kind in CssTokenKind.WhiteSpace.significantAdjacentTokens
) -> i++

token.kind is CssTokenKind.WhiteSpace -> {
removeLast()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ data class AtRulePrelude(
return buildString {
appendLine("AtRulePrelude(")
appendLine(
"location = ${location},".prependIndent(indentSize = 2),
"location = $location,".prependIndent(indentSize = 2),
)
appendLine(
"value = \"${value}\",".prependIndent(indentSize = 2),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ sealed class Block<T : CssComponentValueNode>(
override fun toString(): String {
return buildString {
appendLine("SimpleBlock(")
appendLine("location = ${location},".prependIndent(indentSize = 2))
appendLine("location = $location,".prependIndent(indentSize = 2))
appendLine(
"children = [".prependIndent(indentSize = 2),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ data class Declaration(
override fun toString(): String {
return buildString {
appendLine("Declaration(")
appendLine("location = ${location},".prependIndent(indentSize = 2))
appendLine("location = $location,".prependIndent(indentSize = 2))
appendLine("important = $important,".prependIndent(indentSize = 2))
appendLine("property = \"$property\",".prependIndent(indentSize = 2))
appendLine(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ data class AtRule(
override fun toString(): String {
return buildString {
appendLine("AtRule(")
appendLine("location = ${location},".prependIndent(indentSize = 2))
appendLine("location = $location,".prependIndent(indentSize = 2))
appendLine("name = \"$name\",".prependIndent(indentSize = 2))
appendLine("prelude = ${prelude},".prependIndent(indentSize = 2))
appendLine("block = ${block},".prependIndent(indentSize = 2))
appendLine("prelude = $prelude,".prependIndent(indentSize = 2))
appendLine("block = $block,".prependIndent(indentSize = 2))
append(")")
}
}
Expand All @@ -62,9 +62,9 @@ data class QualifiedRule(
override fun toString(): String {
return buildString {
appendLine("QualifiedRule(")
appendLine("location = ${location},".prependIndent(indentSize = 2))
appendLine("prelude = ${prelude},".prependIndent(indentSize = 2))
appendLine("block = ${block},".prependIndent(indentSize = 2))
appendLine("location = $location,".prependIndent(indentSize = 2))
appendLine("prelude = $prelude,".prependIndent(indentSize = 2))
appendLine("block = $block,".prependIndent(indentSize = 2))
append(")")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ data class SelectorListItem(
return buildString {
appendLine("SelectorListItem(")
appendLine(
"location = ${location},".prependIndent(indentSize = 2),
"location = $location,".prependIndent(indentSize = 2),
)
appendLine(
"selectors = [".prependIndent(indentSize = 2),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ data class StyleSheet(

override fun toString(): String = buildString {
appendLine("StyleSheet(")
appendLine("location = ${location},".prependIndent(indentSize = 2))
appendLine("location = $location,".prependIndent(indentSize = 2))
appendLine(
"children = [".prependIndent(indentSize = 2),
)
appendLine(children.joinToString { statement ->
statement
.toString()
.prependIndent(indentSize = 4)
})
appendLine(
children.joinToString { statement ->
statement
.toString()
.prependIndent(indentSize = 4)
},
)
appendLine("],".prependIndent(indentSize = 2))
append(")")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import dev.tonholo.s2c.lexer.TokenKind
*/
interface AstParserIterator<TTokenKind : TokenKind> {
fun hasNext(): Boolean

/**
* Returns the next token in the iteration.
*/
Expand Down

0 comments on commit 835c608

Please sign in to comment.