job51-gitlab-cr-node-jt-1 3.0.7 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/index.js +111 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -83,6 +83,104 @@ class GitLabCodeReviewer {
|
|
|
83
83
|
return false;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
/**
|
|
87
|
+
* 判断文件是否是 DTO/VO 类文件(需要跳过审查)
|
|
88
|
+
* DTO(Data Transfer Object)和 VO(Value Object)通常是纯数据载体,不含业务逻辑
|
|
89
|
+
* @param {string} filePath 文件路径
|
|
90
|
+
* @returns {boolean} 是否是 DTO/VO 文件
|
|
91
|
+
*/
|
|
92
|
+
isDtoVoFile(filePath) {
|
|
93
|
+
if (!filePath) return false;
|
|
94
|
+
|
|
95
|
+
// 标准化路径(统一使用 / 分隔符)
|
|
96
|
+
const normalizedPath = filePath.replace(/\\/g, '/');
|
|
97
|
+
|
|
98
|
+
// 提取文件名(不含扩展名)
|
|
99
|
+
const fileName = normalizedPath.split('/').pop() || '';
|
|
100
|
+
|
|
101
|
+
// DTO/VO 目录模式(整个目录都是数据模型)
|
|
102
|
+
const dtoVoDirPatterns = [
|
|
103
|
+
'/dto/', // Java: com/example/dto/
|
|
104
|
+
'/DTO/', // 大写形式
|
|
105
|
+
'/vo/', // Java: com/example/vo/
|
|
106
|
+
'/VO/', // 大写形式
|
|
107
|
+
'/model/', // 通用模型目录
|
|
108
|
+
'/models/', // 通用模型目录
|
|
109
|
+
'/entity/', // 实体类目录(有时也是纯数据)
|
|
110
|
+
'/entities/', // 实体类目录
|
|
111
|
+
'/pojo/', // POJO 目录
|
|
112
|
+
'/beans/', // Bean 目录
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
// 检查是否包含 DTO/VO 目录路径
|
|
116
|
+
for (const pattern of dtoVoDirPatterns) {
|
|
117
|
+
if (normalizedPath.includes(pattern)) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// DTO/VO 文件命名模式
|
|
123
|
+
// 匹配文件名中包含或以这些后缀结尾的情况
|
|
124
|
+
const dtoVoPatterns = [
|
|
125
|
+
'Dto', // Java: XxxDto.java
|
|
126
|
+
'DTO', // Java: XxxDTO.java
|
|
127
|
+
'Vo', // Java: XxxVo.java
|
|
128
|
+
'VO', // Java: XxxVO.java
|
|
129
|
+
'Request', // Request 对象通常也是纯数据
|
|
130
|
+
'Response', // Response 对象通常也是纯数据
|
|
131
|
+
'Form', // Form 对象
|
|
132
|
+
'Bean', // Bean 对象
|
|
133
|
+
'POJO', // POJO 对象
|
|
134
|
+
'Pojo', // Pojo 对象
|
|
135
|
+
'Entity', // Entity 对象(如果是简单的数据实体)
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
// 检查文件名是否包含 DTO/VO 模式
|
|
139
|
+
for (const pattern of dtoVoPatterns) {
|
|
140
|
+
// 文件名包含模式(如 CreateUserDto.java)
|
|
141
|
+
if (fileName.includes(pattern)) {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Java 特殊处理:文件名以常见 DTO/VO 后缀结尾
|
|
147
|
+
const dtoVoEndPatterns = [
|
|
148
|
+
'Dto.java',
|
|
149
|
+
'DTO.java',
|
|
150
|
+
'Vo.java',
|
|
151
|
+
'VO.java',
|
|
152
|
+
'Request.java',
|
|
153
|
+
'Response.java',
|
|
154
|
+
'Form.java',
|
|
155
|
+
'Bean.java',
|
|
156
|
+
'Entity.java',
|
|
157
|
+
// Kotlin
|
|
158
|
+
'Dto.kt',
|
|
159
|
+
'DTO.kt',
|
|
160
|
+
'Vo.kt',
|
|
161
|
+
'VO.kt',
|
|
162
|
+
'Request.kt',
|
|
163
|
+
'Response.kt',
|
|
164
|
+
// TypeScript/JavaScript
|
|
165
|
+
'Dto.ts',
|
|
166
|
+
'Dto.js',
|
|
167
|
+
'DTO.ts',
|
|
168
|
+
'DTO.js',
|
|
169
|
+
'Vo.ts',
|
|
170
|
+
'Vo.js',
|
|
171
|
+
'VO.ts',
|
|
172
|
+
'VO.js',
|
|
173
|
+
];
|
|
174
|
+
|
|
175
|
+
for (const pattern of dtoVoEndPatterns) {
|
|
176
|
+
if (fileName.endsWith(pattern)) {
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
|
|
86
184
|
/**
|
|
87
185
|
* 获取合并请求的diff信息
|
|
88
186
|
* @param {number} projectId GitLab项目ID
|
|
@@ -346,6 +444,7 @@ class GitLabCodeReviewer {
|
|
|
346
444
|
// 收集所有需要处理的块(排除测试文件)
|
|
347
445
|
const allBlocks = [];
|
|
348
446
|
const skippedTestFiles = []; // 记录跳过的测试文件
|
|
447
|
+
const skippedDtoVoFiles = []; // 记录跳过的 DTO/VO 文件
|
|
349
448
|
for (const diff of diffs) {
|
|
350
449
|
const filePath = diff.new_path || diff.old_path;
|
|
351
450
|
|
|
@@ -356,6 +455,13 @@ class GitLabCodeReviewer {
|
|
|
356
455
|
continue; // 跳过测试文件
|
|
357
456
|
}
|
|
358
457
|
|
|
458
|
+
// 检查是否是 DTO/VO 文件
|
|
459
|
+
if (this.isDtoVoFile(filePath)) {
|
|
460
|
+
debugLog(`跳过 DTO/VO 文件: ${filePath}`);
|
|
461
|
+
skippedDtoVoFiles.push(filePath);
|
|
462
|
+
continue; // 跳过 DTO/VO 文件
|
|
463
|
+
}
|
|
464
|
+
|
|
359
465
|
const diffObjects = this.getDiffBlocks(diff);
|
|
360
466
|
for (let i = 0; i < diffObjects.length; i++) {
|
|
361
467
|
// 更新块索引
|
|
@@ -369,6 +475,11 @@ class GitLabCodeReviewer {
|
|
|
369
475
|
infoLog(`已跳过 ${skippedTestFiles.length} 个测试文件: ${skippedTestFiles.join(', ')}`);
|
|
370
476
|
}
|
|
371
477
|
|
|
478
|
+
// 输出跳过的 DTO/VO 文件统计
|
|
479
|
+
if (skippedDtoVoFiles.length > 0) {
|
|
480
|
+
infoLog(`已跳过 ${skippedDtoVoFiles.length} 个 DTO/VO 文件: ${skippedDtoVoFiles.join(', ')}`);
|
|
481
|
+
}
|
|
482
|
+
|
|
372
483
|
// 使用线程池控制并发数量
|
|
373
484
|
const results = await this.processWithThreadPool(allBlocks, processBlock, maxConcurrency);
|
|
374
485
|
|