Get Rule from ActiveRules

Hi all,

I hope you’re doing well !

Is it possible to get a Rule (org.sonar.api.rules.Rule) from ActiveRule (org.sonar.api.batch.rule.ActiveRule) ?

I’ve tried to get it from the RuleKey but It only returns the string value

activeRule.ruleKey().rule();

Thanks in advance !

Hi @radwane

I don’t think it is possible. What is your use case?

From a Sensor point of view, only active rules should matters. Fetching entire rules details from server can be very costly.

++

1 Like

Hi @Julien_HENRY

Thanks a lot for your reply!

Before, I was using RulesProfile where I could get a rules from my profile, then I execute the validation part and finally the saving part with saveMeasure, but it’s okay now while using ActiveRules I execute the validation part and the saving part within my rule using SensorContext.newMeasure.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.