Scan Native query in JPA using SonarQube

442 views Asked by At

I have native queries in java files and i want to scan that queries for using sonarQube server.

Is there any way to do that?

1

There are 1 answers

0
G. Ann - SonarSource Team On BEST ANSWER

There are a few rules implemented in SonarJava that check the proper use of SQL-related Java objects, specifically

  • S2695 - "PreparedStatement" and "ResultSet" methods should be called with valid indicies
  • S2232 - "ResultSet.isLast()" should not be used
  • S2077 - SQL binding mechanisms should be used

But there are no rules that check the correctness of SQL statements themselves, and I'm not aware of any other plugins that offer such rules for Java.

If you really need this, then you'll have to go down the custom rule implementation route. There's a tutorial to get you started, and if you have specific development questions you can ask them in the SonarQube Google Group, or here, obviously.

Update
The Google Group has been replaced with https://community.sonarsource.com.