Android Studio lint工具所提示的需要注意的内容简要记录

Android lint部分:

Duplicated icons under different names 相同的icon 用了不同的名字

FrameLayout can be replaced with tag FrameLayout 可以被替换成 merge标签

Handler reference leaks handler 内存溢出问题 替换成静态 + 弱引用

Hardcoded reference to /sdcard 硬编码问题 尽量不使用硬编码(固定的字符串即为硬编码)

Icon densities validation 图标最好覆盖各个密度 比如mdpi hdpi xhdpi等。。。

Image without contentDescription 没设置图片的 内容属性 主要用于有障碍的人士使用

Inefficient layout weight 低效的 weight属性 最好在设置weight后 设置 width或者height为 0

Layout Inflation without a Parent 布局需要一个父布局

Missing allowBackup attribute Application中 缺少 allowBackup属性 设置 这个即可android:fullBackupContent’ to ‘true’ or ‘false’

Missing baselineAligned attribute 缺少基线属性

Missing commit() on SharedPreference editor 缺少commit 在不关心是否成功提交时 使用apply效率高于commit

Missing density folder 缺少 一些密度的文件夹 该提示是由于 少了某个密度的 drawable-xxdip文件夹

Missing inputType or hint EditText 缺少 输入类型和提示文字

Nested layout weights 嵌套的布局 都使用了 weight属性 这时最好去掉子布局不必要的weight 提高性能
Node can be replaced by a TextView with compound drawables 使用 TextView 自带的 drawable属性 代替 TextView+ImageView

Obsolete layout params 过时的 无用的布局参数 比如 LinearLayout中 出现 相对布局中的布局参数

Overdraw: Painting regions more than once 过度绘制 一般是由于 设置了多个background的情况

Overlapping items in RelativeLayout 可能重叠的子布局 在RelativeLayout中 比如设置了wrap_content 可能扩展覆盖其他布局

Padding and margin symmetry padding 和 margin 需要相互对称

Unused resources 没用过的资源 找到后删掉即可

Useless parent layout 无用的父布局

Using .gif format for bitmaps is discouraged 用gif 图片是被阻止的 。。。 但是有时候还是得用。。

Using dp instead of sp for text sizes 用sp代替 dp

Using left/right instead of start/end attributes 使用 start和end 代替 left right

class structure部分:

Field Can Be Local 字段能被设置成 局部变量 缩小其生命周期

Parameter can be converted to a local variable 类似于上面这个 参数可以被转化为局部变量
code maturity issues 部分 – 代码成熟度问题
一般是一些已经过时的方法 需要替换
code style issues: 代码风格问题
if statement may be replaced with && or || expression if 可以被替换成 && 或 || 简化代码

Unnecessary Interface Modifier 不必要的接口修改 比如 接口中的方法 默认为public 不需要填写也可以

control flow issues: 控制流问题

redundant if statement 冗余的if语句 说明 if语句可以简化 比如

if(fun()){
    return true;
}else{
    return false;
}
简化为 

return fun();

Unnecessary Return 不必要的 return 比如 返回值为 void 之后return了

Data flow issues : 数据流问题

Boolean MethodIs Always Inverted 没懂。。。
redundant local variable 冗余的局部变量 一般是 没用到的

declaration redundancy: 声明冗余

Access Static Via Instance 通过实例 访问静态成员。。。

actual method parameter is the same constant 实参是个常量 感觉没什么影响、、

declaration access can be weaker 声明访问权限可能较弱 也就是一些可以设置成 private的设置了 protected或者public 类似的情况

declaration can have final modifier 可以使用 final修饰 可提高效率

empty method 空方法。。。

method can be void 方法可以返回 void 一般是 返回值没有被用到的情况 会提示这个

method returns the same value 方法返回相同的值 也就是 无论如何方法都返回某个值 需要优化

redundant throws clause 冗余的异常抛出 一般是 既在方法里 抛出了 也在 方法上 抛出了。。。

unused declaration 无用的声明 一般是方法或属性声明了 但是没有使用 会有这个提示

unused method parameters 无用的方法参数

Error handling: 错误处理

empty catch block 空的 异常捕获 会提示
for loop replaceable with foreach 把for 替换成 foreach

javaDoc issues: 关于 注释 文档的。。。。
probable bugs:可能的bug

一些 可能产生bug的代码

properties files 配置文件的一些问题

比如 配置文件定义的一些属性没有使用到

Spelling 拼写的一些问题

verbose or redundant code constructs 冗长冗余的代码结构
xml文件的一些问题

类似于 java中的

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值