Code smells wrong package

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


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.


1 Like


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


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).


1 Like