Hi everyone, I'm new to Konsist since the last dro...
# konsist
a
Hi everyone, I'm new to Konsist since the last droidcon and loving it so far. Recently I wanted to use Konsist (v0.17.3) to check non-default constructor method calls for
MutableSharedFlow
in my code. An example in simple words:
MutableSharedFlow()
is correct, but
MutableSharedFlow(replay = 1)
is incorrect. To test the filtering of non-default calls, I wrote the following code:
Copy code
val sut = Konsist.scopeFromProject()
    .files
    .withTextMatching(""".*MutableSharedFlow.*\(.+\)""".toRegex())

println(sut.size)
However, the result of
sut.size
is zero, but there are more than 10 occurrences in my files. I am curious to know if that is the right way to use regular expressions with Konsist because I couldn't find any examples of it in the docs. Could anyone help me with using regular expressions and Konsist?
For anyone reading, I noticed that this approach would work:
Copy code
val regex = Regex(""".*MutableSharedFlow.*\(.+\)""")
val sut = Konsist.scopeFromProject()
    .files
    .filter { file ->
        regex.containsMatchIn(file.text)
    }