How to access Configuration from custom Java rule

How to access Configuration from custom Java rule

such as

SensorContext context;
Configuration configuration;

@Override
  public void visitMethod(MethodTree tree) {
    boolean myFlag = configuration.getBoolean("myFlag").orElse(false);
    context.reportIssue(this, tree, "some message");    
    super.visitMethod(tree);    
  }

Any code snippet will help to understand.

Hello @asishs

I don’t think it is currently possible, and in fact, I’m not sure it is the correct way to go. I would rather add a rule parameter to obtain such behavior.

Hope it helps.
Best,
Quentin

Hi @Quentin,

Yes, I have got it and successfully implemented.

Thank you.

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