Rename Java interface rule doesn't account for enclosing interface name

Template for a good bug report, formatted with Markdown:

  • versions used (SonarQube, Scanner, Plugin, and any relevant extension): Enterprise Edition Version 7.9.1 (build 27448)
  • error observed (wrap logs/code around triple quote ``` for proper formatting)
  • steps to reproduce

I think this kind of code is a false positive…

public interface SomethingContract {
  interface Presenter extends ViperContract.Presenter<View, Router> {
  • potential workaround

We’d have to rename things the way we shouldn’t have to?

We reference the presenter like this: SomethingContract.Presenter instead of as just “Presenter” so it’s very clear, but Sonarqube is flagging the interface as an issue.

Anyone else do something different for this case?

Hello @kenyee,

You are referring to RSPEC-114, right?

What you are discussing sounds strange to me, this rule is about respecting a convention everywhere (that you can adapt to your needs by the way), I’m not sure to understand why the context in which it is declared/used should influence it.
Even if it will always be used with a prefix, seeing something like:

class MyClass implements SomethingContract.presenter {

is strange to me, it still makes sense to respect the convention.

Did I miss something?

Actually, it’s this one: squid:S2176
“Class names should not shadow interfaces or superclasses”
" While it’s perfectly legal to give a class the same simple name as a class in another package that it extends or interface it implements, it’s confusing and could cause problems in the future.

Noncompliant Code Example

public class Foo implements a.b.Foo { // Noncompliant

public class FooJr implements a.b.Foo {

but I don’t see it in that Java rules list?

Okay, make more sense when we are speaking about the same rule. The rule is here.

Which version of the Java analyzer are you using? Because this issue seems really close to SONARJAVA-3280 and fixed in version 6.1.

In addition, this exact code:

interface SomethingContract {
  interface Presenter extends ViperContract.Presenter {
    // ...

interface ViperContract {
  interface Presenter {


was raising an issue in version 6.0, but not anymore!

Our admins told me we’re on Java analyzer 5.13.1.

They’re looking into upgrading to 6.1. Thanks :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.