SonarSources' java codestyle


I’d be interested if there is something written down about SonarSources’ own codestyles for Java.
I haven’t found a blog post and the Eclipse stuff within the toolset repository seems to only contain stuff like formatting and ordering.

What I’m specifically interested in is the the reasoning for when getters are prefixed with get and when without.

I thought it had something to do with interfaces, but then I found a get-getter in an interface.

I was asking myself this question when consuming the SonarQube-API to develop plugins, so I would be glad if I can find an answer to that :slight_smile:


To be honest, I don’t think we have clear rules about that. Older APIs were using getXXX syntax, following Java bean conventions. Then at some point we changed our mind and decided that it was making code ugly to read (especially in fluent builder style/method reference). But then later we also realized that some tools may still rely on Java bean naming convention.

All that to say that this is a “technical debt” that we have and that we will probably never fix for the sake of backward compatibility. And for new APIs we may introduce, well, I guess we should clarify that…

So for new APIs getXXX() will be used again?

I really liked the omitting of the get and thinking about the record JEP which also omits the get I was really thinking about using this style in my next fresh project :slight_smile:

I don’t know. As I said we have no clear rules.

Feel free to use the style you like in your project :wink: