Hi!
I am making my own plugin and I need to get some information stored in issue message to calculate metric.
For example: I need to check if there is a method that rise CyclomaticComplexity too high issue and if so, how high is that CC.
MeasureComputerContext.getIssues method returns Issues, but without message. Is there any other way of getting issues (preferably with messages) from MeasureComputer?
Hi!
Let’s keep that example I’ve posted.
It’s not not language-specific, It should be working on java, kotlin, C/C++ or C#. I want to get issues for a component, filter them by RuleKey, parse issue messages and then calculate metric using that.
I hope that clears it up a bit
Thanks!
Apologies for the delay in getting back to you, and thanks for your patience.
That interface intentionally doesn’t expose the message. There’s no other method on MeasureComputerContext that would give you issues with their text.
The reason it’s not exposed is that issue messages aren’t a stable contract: they’re user-facing text written by each analyzer, and the exact wording can change between analyzer versions. A plugin that parsed, say, a value out of “… is 17 which is greater than 10 authorized” would silently break the next time the analyzer tweaked the wording. So even if message() were available here, I’d strongly recommend against building on it for computing measures.
The cleaner path is to consume structured data rather than parsing a message. If the value you need already corresponds to an existing measure, you can read it via context.getMeasure(…). That’s exactly what MeasureComputer is designed for. If it doesn’t, could you share a bit more about what you’re ultimately trying to compute? That’d help us point you at the right approach (or tell us whether a gap needs filling somewhere).