Merge branch 'v5.8.4' into 'master'
上线合并 See merge request !32
Showing
129 changed files
with
2249 additions
and
280 deletions
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
-
一、关键问题与优化建议(仅限 Top 3)
1. 潜在的空指针异常(NullPointerException)风险
- 位置:
src/main/java/cn/com/glsx/dj/smartcarlife/controller/abnormalflow/AbnormalFlowDeclarationController.java - 问题描述:在
approveDeclaration方法中,直接链式调用了CommonUtil.getLoginUser().getUuid()。如果当前会话过期或上下文中未获取到用户信息,getLoginUser()返回null,将直接导致空指针异常(500错误),影响系统健壮性。 - 优化建议:在调用前增加对
CommonUtil.getLoginUser()的判空逻辑,或者参考项目中其他地方的写法(如GoodsOrderController中的Objects.requireNonNull(CommonUtil.getLoginUser())),并在为空时返回明确的未登录或鉴权失败错误提示。
2. 存在硬编码与魔法值(违反阿里巴巴Java开发规范)
- 位置:
-
AbnormalFlowDeclarationController.java:dto.setApprovalSource((byte) 1); -
ServiceMerchantController.java:pagination.getCondition().setIncludeDeleted("Y");
-
- 问题描述:代码中直接使用了魔法数字
1和魔法字符串"Y"。这违反了阿里巴巴Java开发手册中“不允许任何魔法值(即未经预先定义的常量)直接出现在代码中”的规定,严重降低了代码的可读性和可维护性。 - 优化建议:将
(byte) 1抽取为枚举(如ApprovalSourceEnum.HEADQUARTERS.getValue()),将"Y"抽取为全局常量(如Constants.YES),以明确其业务含义。
3. RPC大分页查询存在性能瓶颈与内存溢出风险
- 位置:
src/main/java/cn/com/glsx/dj/smartcarlife/controller/smartCarLife/ServiceMerchantController.java(约 633 行) - 问题描述:在导出数据的
queryAndExportData方法中,直接设置pagination.setPageSize(5000);。通过 Dubbo 等 RPC 框架一次性拉取 5000 条复杂的数据对象,极易触发 RPC 框架的 Payload 传输大小限制(Dubbo 默认通常为 8MB),且在高并发导出时会导致微服务内存飙升,增加 OOM 风险。 - 优化建议:对于全量或大量数据的导出,建议改用分批/滚动查询(如每次查询 500 条,循环拉取写入 Excel),或者利用 EasyExcel 的流式写入特性,边查边写,避免将大量对象同时加载到内存中。
二、评分明细
- 功能实现的正确性与健壮性(40分):35分
- 扣分项:由于未对上下文中获取的用户对象进行判空,存在潜在的
NullPointerException风险;部分深层嵌套的if-else(如CreateBusinessApproveController)略显臃肿,但逻辑基本正确。
- 扣分项:由于未对上下文中获取的用户对象进行判空,存在潜在的
- 安全性与潜在风险(30分):30分
- 得分项:未发现明显的 SQL 注入、XSS 等高危安全漏洞。权限控制(如
hasFinancialPermission())在多个新增接口中得到了正确应用。
- 得分项:未发现明显的 SQL 注入、XSS 等高危安全漏洞。权限控制(如
- 最佳实践与可维护性(20分):15分
- 扣分项:代码中存在多处未抽离的魔法值;
DailyReportRecordController中引入了已被淘汰的org.apache.commons.lang.StringUtils(应替换为lang3版本),不符合阿里规范。
- 扣分项:代码中存在多处未抽离的魔法值;
- 性能与资源利用(5分):3分
- 扣分项:导出接口单次 RPC 请求数据量过大(PageSize=5000),存在网络传输瓶颈和内存压力。
- 提交信息质量(5分):5分
- 得分项:Commit message 遵循了 Angular 规范(如
feat:,fix:,refactor:),清晰地表达了变更意图,且粒度适中。
- 得分项:Commit message 遵循了 Angular 规范(如
总分:88分
- 位置:
-
Please register or sign in to post a comment