cannot access map during function
Answered
For the function `convertToMarkDown` https://github.com/madneal/sec-dog/blob/e63eb04aa9226bcc175d05f849edf6598bd9d233/src/main/kotlin/com/github/madneal/secdog/Checker.kt#L53
I tried to add a map save the `ad.titlle` which was a String like this.
fun convertToMarkDown(ads: List<Advisory>, packageName: String): String {
var result = StringBuilder().append("# $packageName\n")
var map = mutableMapOf<String, Boolean>()
for (ad in ads) {
map.put(ad.title, true)
println(map)
val aliases = ad.aliases.joinToString(",")
val refs = ad.referenceURLs.map { it -> "* $it " }.joinToString("\n")
var adString = """
The `println(map)` would print nothing. And if I debug the fuction, the map would not be accessed.
I tried to write a demo function
I have no idea why map operation does not work during the function inside the plugin.
Please sign in to leave a comment.
Hi,
Sorry, but the problem is unclear. At the first glance, it seems that the source and executed code are out of sync.
Please try to recompile your project and debug it again. If the issue still happens, prepare a branch with this code and a test project we can use to investigate it. Make sure, that projects do not require any additional setup steps, so we can check it out and run without any additional actions.
I have created a `map` branch for test https://github.com/madneal/sec-dog/blob/be23566e4f90f9021c7246dde1099823288ce344/src/test/kotlin/com/github/madneal/secdog/MyPluginTest.kt#L32
The weired is no matter what parameter I pass to the `packageName` parameter of `chcker.Check` method. Inside the method, the parameter seem to always be the parameter I passed fitst time. I am not sure if some cache or something broken. I try to invalidate cache, but doesn't work.
I'm sorry, but the tests cannot be run due to the following error:
em. There is nothing special configure. The project is created by the https://github.com/JetBrains/intellij-platform-plugin-template.
I am not sure if there is need to `Run Plugin` and `Run Verification` task.
Gradle JVM
I've changed Gradle JVM and it works, sorry.
Also, the plugin works as expected:
I don't know what can be the issue cause. Try to check out the project again from scratch.
It's so weired. I clone the project from the scratch and delete the `.idea` folder. But I find the problem still exists. Could you try to modify the `packageName` parameter to see if it changed inside the function `Check`.
I am so confused. Try to switch to junit5 for test https://github.com/madneal/sec-dog/blob/0046f10e482d3b181377a6cfcfab3e07ac141d05/src/test/kotlin/com/github/madneal/secdog/CheckerTest.kt#L10
It works!!! But I wonder why?
There is an issue in Gradle IntelliJ Plugin 1.5.3. It will be fixed in the next release.
Please use the "clean" task to force recompilation.