您的位置:首页 > 移动开发 > Android开发

如何在android sdutio提交(SVN)代码后完善代码(根据代码检查器完善)

2017-05-09 15:31 316 查看
用SVN提交代码后代码检查器提示的代码完善

1.Access can be package-private

删除“public”就可以,但如果是类有这个提示,则需要编译进行相应的取舍。

2.Access can be private

需要把“public”改为private

Access Levels
Modifier    Class   Package  Subclass World
public         Y        Y       Y       Y
protected      Y        Y       Y       N
no modifier    Y        Y       N       N
private        Y        N       N       N


3.A newer version of com.android.support:support-v4 than 25.1.0 is available: 25.2.0

建议升级版本,根据提示更改就好

4.Old buildToolsVersion 25.0.0; recommended version is 25.0.2 or later

当前的buildToolsVersion是旧版本,建议升级

5.Avoid using + in version numbers; can lead to unpredictable and unrepeatable builds (com.android.tools.build:gradle:2.3.+)

有了”+“即不确定版本,建议指定一个版本,具体哪个版本,参考主项目的build.gradle文件

6. This `ScrollView` layout or its `LinearLayout` parent is useless; transfer the `background`
attribute to the other view

母布局`LinearLayout`无用,具体看页面具体完善

7.When you define `paddingLeft` you should
probably also define `paddingRight` for right-to-left symmetry

目前发现`paddingLeft`和`paddingRight`只要是只用一个,都会有这个提示,把另一个设置为0dp这个提示会消失

8.[Accessibility]
Missing `contentDescription` attribute on image

`contentDescription`为视力有障碍的人增加对控件的解释,增加这个属性,提示就会消失

9.Consider adding `android:layout_toEndOf="@+id/tv_ini_gtit_1"` to better support right-to-left
layouts

建议增加“android:layout_toEndOf”属性

10.Use "`start`" instead of "`left`" to ensure correct behavior in right-to-left locales

当我们的minSdkVersion>=17时,使用start/end来代替left/right;当minSdkVersion<17时,旧的平台不支持RTL,start/end属性是未知的,会被忽略,所以要同时使用start/end和left/right。

11.Consider adding `android:paddingStart="10dp"`
to better support right-to-left layouts

具体还是"`start`" 和"`left`"的原因,可以参考上一条

12.Nested weights are bad for performance

嵌套权重对性能不好,建议进行完善

13.Do not place Android context classes in static fields; this is a memory leak (and also breaks
Instant Run)

不要将Android上下文类放在静态字段中,这是内存泄漏(也会中断即时运行)

把context的static删除,然后调试下就好

14. '@param str' tag description is missing

把注解的“@”删除就好

15. 'if'
statement can be simplified

if的代码可以简化

16. 'for'
loop replaceable with 'foreach'

for(int
i = 0 ; i < 100 ; i++) 改为 for(数据类型 遍历后的数据:遍历数据源)

17.Method
invocation 'xxx' may produce 'java.lang.NullPointerException'

调用‘xxx’方法,有可能会报空指针异常

18.Result of 'xxx' is ignored

结果'xxx'被忽略
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: