如何为最终值创建检查样式规则

时间:2019-11-14 15:14:28

标签: android checkstyle

我想为常量创建一个checkstyle规则。我的问题是如何在此规则中设置范围。让我们看看吧:

我有此代码:

getattr

checkstyle.xml

public class foo {

    //all are memeberName for checkstyle
    private final int NUMBER = 10; // violation is member
    private int mNumber = 3;

    private void bar(){
        final String text = "foo"; // violation is final
        String txt = "example";
    }
}

如何使用成员规则excet final var并将此规则添加到类常量中?

这是我对checkstyle的依赖:checkstyle'com.puppycrawl.tools:checkstyle:8.26'

谢谢