tomasbjerre / violations-lib

Java library for parsing report files from static code analysis.
Apache License 2.0
148 stars 39 forks source link

JUnit Message contains the whole stacktrace #173

Closed oers closed 1 year ago

oers commented 1 year ago

I am using the jenkins violation to gitlab plugin. I noticed that violation.message contains the message as a combination of the failure message and the whole content. In may case that is the complete stacktrace of the assertion.

I found no way to limit the output of {{{violation.message}}} to one line (which would be enough in my case)

Would it be possible to just put the into violation.message and the rest into specifics?

tomasbjerre commented 1 year ago

This can be fixed by switching Mustache to Handlebars, here: https://github.com/tomasbjerre/violation-comments-lib/blob/master/src/main/java/se/bjurr/violations/comments/lib/ViolationRenderer.java

And a user of the tool can use a Handlebars helper to substring the message.

oers commented 1 year ago

Can i do this via coniguration? Or would I need to "compile" my own version of the plugin?

tomasbjerre commented 1 year ago

I implemented this here now: https://github.com/tomasbjerre/violation-comments-lib

Hopefully one of the StringHelpers will solve your issue: https://github.com/jknack/handlebars.java/blob/master/handlebars/src/main/java/com/github/jknack/handlebars/helper/StringHelpers.java

What tool do you use? I would prefer releasing only that tool to begin with. And have it battle tested before releasing all other tools.

oers commented 1 year ago

I am using the Jenkins Violations to Gitlab Plugin.

tomasbjerre commented 1 year ago

Releasing it now as 2.58. Open issue again if not working.

oers commented 1 year ago

Thx. I will test it after my holiday.

oers commented 1 year ago

Worked for me with {{{substring violation.message 0 300 }}}, which is not exactly limit to n number of lines. But enough.

Maybe you should reflect this change in the api/possibilities in the README.

Thank you very much for your effort.