Finding a New File Instantiation in Java

java
custom_rules

(Arun Rajendran) #1

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


(Michael Gumowski) #2

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?

Regards,
Michael