Finding a New File Instantiation in Java

Hi, I need to write a custom rule to find any new File() is instantiated in java code

Ex Line of code :

File testFile = new File(tempDir +  "test_" + System.currentTimeMillis());

Please help me to give sampleSonarqube java Custom Rule code to find this new File instantiation

Hey @Arun_R

This should be a pretty straight forward rule.

  • What did you tried already?
  • Can you share the the code of your rule and your test case?