Skip to content

Commit

Permalink
Fixes https://bit.ly/35zc6ZE sonarcloud warning
Browse files Browse the repository at this point in the history
  • Loading branch information
asm0dey committed Jan 12, 2021
1 parent 28a1b9b commit 6023d99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
14 changes: 6 additions & 8 deletions src/main/kotlin/staks/base.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,13 @@ class StaxBuilder<T>(override val reader: XMLEventReader, func: StaxBuilder<T>.(
return builder()
}

override val value: () -> T get() = throw IllegalStateException("Root builder should not process anything!")
override val isSingular: Boolean
get() = throw IllegalStateException("Root builder should not process anything!")
private fun getDoNotCall() = IllegalStateException("Root builder should not process anything!")

override fun matches(event: XMLEvent): Boolean =
throw IllegalStateException("Root builder should not process anything!")

override fun process(ev: XMLEvent): Unit = throw IllegalStateException("Root builder should not process anything!")
override fun reset(): Unit = throw IllegalStateException("Root builder should not process anything!")
override val value: () -> T get() = throw getDoNotCall()
override val isSingular: Boolean get() = throw getDoNotCall()
override fun matches(event: XMLEvent): Boolean = throw getDoNotCall()
override fun process(ev: XMLEvent): Unit = throw getDoNotCall()
override fun reset(): Unit = throw getDoNotCall()

}

Expand Down
11 changes: 6 additions & 5 deletions src/test/kotlin/staks/BaseKtTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ class BaseKtTest : FunSpec({
test("handler calls to StaxBuilder should fail") {
staks<Unit>("<root/>".byteInputStream()) {
val ev = reader.nextEvent()
expect { isSingular }.toThrow<IllegalStateException>().message.toBe("Root builder should not process anything!")
expect { matches(ev) }.toThrow<IllegalStateException>().message.toBe("Root builder should not process anything!")
expect { process(ev) }.toThrow<IllegalStateException>().message.toBe("Root builder should not process anything!")
expect { reset() }.toThrow<IllegalStateException>().message.toBe("Root builder should not process anything!")
expect { value() }.toThrow<IllegalStateException>().message.toBe("Root builder should not process anything!")
val errorMessage = "Root builder should not process anything!"
expect { isSingular }.toThrow<IllegalStateException>().message toBe errorMessage
expect { matches(ev) }.toThrow<IllegalStateException>().message toBe errorMessage
expect { process(ev) }.toThrow<IllegalStateException>().message toBe errorMessage
expect { reset() }.toThrow<IllegalStateException>().message toBe errorMessage
expect { value() }.toThrow<IllegalStateException>().message toBe errorMessage
;
{}
}
Expand Down

0 comments on commit 6023d99

Please sign in to comment.