Code smells wrong package

intellij
java

(Dondon Dev) #1

hello, i am new in sonar technology.
I would like to ask to solved my issue
I got stuck in sonar critical with message “Package declaration should match source file directory”

Any help would be appreciated
Thank you


(Michael Gumowski) #2

Hello,

The issues raised by rule S1598 seems legit to me according to this:

It seems to me that even if your code is going to compile, your classes won’t be able to be correctly loaded if placed in folder having name with dot, instead of the corresponding folder with subfolders structure.

Regards,
Michael


(Dondon Dev) #6

Hello,

I’ve already fix this issue :smiley:
it was because the package seem not correct.
the package format should be like this
/src/main/java/com/my/package
but, in my project it goes like this
/src/main/java/com.my.package

XD


(Michael Gumowski) #7

Thank you for coming back to us. Happy to know the issue was legit. Anyway, your case made me think that the definition of the rule, as well as the issue which is raise should be improved to cover this case. With a more explicit message.

I updated the rule description to explicitly mention this case (RSPEC-1598) and created a new ticket in SonarJava to update the issue message in such scenario (SONARJAVA-2861).

Cheers,
Michael