IntelliJ - 如何让它警告我有关静态成员的隐式访问?

IntelliJ - How do I get it to warn me about implicit access of static members?

我如何配置 IntelliJ 以便在我尝试访问 class 的静态成员时发出警告,而没有在其前面键入 class 名称?

public class Car
{
    static int lastIDgiven = 0
    private int id;
    public Car()
    {
        id = lastIDgiven;
        incrementLastID();
    }
    static void incrementLastID()
    {
        lastIDgiven ++;
    }
}

在这个例子中,我希望 IntelliJ 警告我 "id = lastIDgiven;",并建议我将其更改为 "id = Car.lastIDgiven"。与 "incrementLastID()" 相同 - 我希望它建议 "Car.incrementLastID()"。在 incrementLastID() 中也一样,当我输入 "lastIDgiven++" 时(即使它在静态方法中)。

IntelliJ 有很多设置,尤其是用于检查的设置,但我找不到这个特定的设置 - 只有 "access static member via instance reference" 检查,它与 "someCar.lastIDgiven".[=11= 这样的东西相关]

我希望 IntelliJ 就此特定行为向我发出警告,因为在以这种方式调用它时并不能立即清楚 field/method 是静态的,而且我喜欢让程序警告我混淆代码。

那么,有这个的设置选项吗?

是的,IntelliJ IDEA 对此进行了检查,称为不合格的静态访问

Reports static method calls or field accesses that are not qualified with the class name of the static method. This is legal if the static method or field is in the same class as the call, but may be confusing.