Sonar rule - Reorder the modifiers for interface default methods
java, java-8, rule, sonarqube
Solution
The method declaration syntax for interfaces is covered in the JLS, section 9.4.
Briefly, method modifiers must precede the method header, which includes the method's return type. Your declaration has one method modifier `default` and its return type is `boolean` so there is no other possible arrangement in this declaration other than
default boolean isValid(/*parameters*/) { /*body*/ }
Therefore I think this must be a bug in Sonar.
Problem
I just started using Sonar and I have a project with JDK 8. The only problem I've got so far is: ``` Reorder the modifiers to comply with the Java Language Specification. ``` This is happening for my default methods in interfaces, like ``` default boolean isValid([params here]) { /*method body here*/ } ``` I know that this is really a minor issue, but I don't want to disable any rule, so how do you fix it? Thank you very much! p.s. I haven't found anything on Google, I know what this rule means(I have read its description), but I cannot figure out how to deal with default keyword. Update: It looks like a bug, I have reported it here, https://jira.codehaus.org/browse/SONARJAVA-590 Update 2: It seems it's already fixed and it will be available in 2.4 version.