Associate analyze java file and html file, what is the sonarlint's base directory?

Please provide

  • Operating system: Windows7 64bit, IDEA 2021.1 Community Edition
  • SonarLint plugin version: 7.4.0.60471
  • Programming language you’re coding in: java and html
  • Is connected mode used: yes
    • Connected to SonarCloud or SonarQube (and which version): connected to SonarQube 8.9.8.54436

And a thorough description of the problem / question:

In my project scenario, I need to write custom rules to find the referenced HTML file from the Java file, and then associate and match specific fields in the Java file with those in the HTML file. If the matching fails, an error message will pop up

After testing, this rule has been correctly written, and can pop up the error I expect by associating java with html File association. My testing included unit testing in Sonar Java (custom rule writing project) and analyzing the entire project using Sonarqube from the command line (mvn sonar: sonar…)

But when I use the sonarlint plugin, it seems that I cannot find the path to the. html file correctly. The path I set in the rules is/src/main/resources/, The error that pops up is not the mismatch I expected, but the error that the path cannot be found

May I ask if you have encountered such a problem and hope to help answer it? Thank you

Hi @yixuan004

How are you looking for the HTML file in your Sensor? Are you using the FileSystem::inputFile(Predicate) API to search for it? Or are you relying on FileSystem::baseDir() and then looking for the file using JDK APIs?

thank you and i use context.getInputFile().absolutePath() to solve this problem!