使用Checkstyle的Android代码分析

时间:2018-06-20 04:52:21

标签: android checkstyle

我正在使用FindBugs,PMD和Checkstyle检查我的代码,以改善代码库并确定潜在的漏洞以及设计缺陷。但是我在找出问题到底出在哪里时遇到了麻烦?我在代码中使用了Lambda表达式。

错误说明

'member def modifier' have incorrect indentation level 8, expected level should be 4.   34
'member def modifier' have incorrect indentation level 8, expected level should be 4.   37
'member def modifier' have incorrect indentation level 8, expected level should be 4.   39
'method def modifier' have incorrect indentation level 8, expected level should be 4.   42
'method def' child have incorrect indentation level 16, expected level should be 8. 44
'method def' child have incorrect indentation level 16, expected level should be 8. 46
'method def' child have incorrect indentation level 16, expected level should be 8. 47
'method def' child have incorrect indentation level 16, expected level should be 8. 48
'method def' child have incorrect indentation level 16, expected level should be 8. 50
'method def' child have incorrect indentation level 16, expected level should be 8. 52

RegisterActivity

public class RegisterActivity extends DaggerAppCompatActivity implements LifecycleOwner {

        @Inject :**line number 34**
        public RegisterViewModel mRegisterViewModel;

        private ProgressDialog progressDialog; **line number 37**

        private ActivityRegisterBinding mBinding;
  

我添加了我的活动,该活动在特定行显示错误,但是我   无法找出我的代码中到底是什么问题。

2 个答案:

答案 0 :(得分:1)

您是否尝试过使用错误日志中指定的缩进?

尝试这个solution

[我想发表评论,但由于声誉欠佳,我被拒绝享有这种特权。因此,我不得不发表答案]

答案 1 :(得分:1)

那些是Java缩进违规的,我不认为这会对项目产生任何影响。
@themrhornet solution推荐的解决方案!应该可以使用,因为android IDE有自己的规则

打开首选项(在Mac上为cmd +,在Windows上为ctrl + alt + s),然后转到编辑器->代码样式-> Java。在选项卡和缩进空间上,可以将缩进设置为8。