crabatool 1.0.326 → 1.0.333
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/index.js +1 -0
- package/lib/config.js +8 -4
- package/package.json +1 -1
- package/tool/checkiconfont.js +8 -6
- package/tool/checkjs.js +15 -2
package/index.js
CHANGED
package/lib/config.js
CHANGED
|
@@ -4,8 +4,14 @@ var pg = require('../package.json');
|
|
|
4
4
|
|
|
5
5
|
class Config {
|
|
6
6
|
constructor() {
|
|
7
|
-
this.reportHost = "http://crabadoc.ca.com"; // 用于接收检测报告的服务器,可配置的。由于产品没有提供服务,目前统一放到平台的文档服务器
|
|
7
|
+
//this.reportHost = "http://crabadoc.ca.com"; // 用于接收检测报告的服务器,可配置的。由于产品没有提供服务,目前统一放到平台的文档服务器
|
|
8
8
|
//this.reportHost = "http://127.0.0.1:9998";
|
|
9
|
+
this.reportHost = 'http://172.17.0.201:9998';
|
|
10
|
+
|
|
11
|
+
//this.SourceHost = "http://crabadoc.mygjp.com.cn";
|
|
12
|
+
//this.SourceHost = "http://crabadoc.ca.com";
|
|
13
|
+
this.SourceHost = 'http://172.17.0.201:9998';
|
|
14
|
+
|
|
9
15
|
this.webhooks = "https://oapi.dingtalk.com/robot/send?access_token=ce27b1b1540881540d44c0bd05ba738d865363758892ede137dc1020bd36bd5a";
|
|
10
16
|
this.crabaHooks = "https://oapi.dingtalk.com/robot/send?access_token=ce27b1b1540881540d44c0bd05ba738d865363758892ede137dc1020bd36bd5a";
|
|
11
17
|
//this.webhooks = "https://oapi.dingtalk.com/robot/send?access_token=37279df60e03ebf25e8eb71230ddb93fe74de99951a8d635d0458e60bfcd44d8";
|
|
@@ -15,9 +21,7 @@ class Config {
|
|
|
15
21
|
this.Version = pg.version;
|
|
16
22
|
this.Debug = false;
|
|
17
23
|
this.version = 'master';
|
|
18
|
-
|
|
19
|
-
this.SourceHost = "http://crabadoc.ca.com";
|
|
20
|
-
//this.SourceHost = "http://127.0.0.1:9998";
|
|
24
|
+
|
|
21
25
|
this.TempPath = path.join(os.tmpdir(), '_crabatemp');
|
|
22
26
|
this.ImageCache = path.join(this.TempPath, "_img");
|
|
23
27
|
this.JsonFile = path.join(this.TempPath, "craba.json");
|
package/package.json
CHANGED
package/tool/checkiconfont.js
CHANGED
|
@@ -32,6 +32,7 @@ module.exports.start = async function() {
|
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
// 用项目名+分支名确定唯一性
|
|
35
36
|
|
|
36
37
|
var reportData = {
|
|
37
38
|
webPath: config.webPath,
|
|
@@ -39,28 +40,29 @@ module.exports.start = async function() {
|
|
|
39
40
|
branchName: getBranchName(),
|
|
40
41
|
list: list,
|
|
41
42
|
counts: counts
|
|
42
|
-
}
|
|
43
|
+
};
|
|
44
|
+
var id = utils.getHashCode(reportData.projectName + reportData.branchName);
|
|
45
|
+
reportData.id = id;
|
|
43
46
|
|
|
44
47
|
//console.log(reportData);
|
|
45
48
|
|
|
46
|
-
// 用项目名+分支名确定唯一性
|
|
47
|
-
var id = utils.getHashCode(reportData.projectName + reportData.branchName);
|
|
48
|
-
|
|
49
49
|
var data = {
|
|
50
50
|
id: id,
|
|
51
51
|
data: reportData // 代码质量管理系统需要,一起提交到文档保存到文档服务器
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
+
var url = config.reportHost + '/apis/saveIconfontData';
|
|
54
55
|
axios({
|
|
55
56
|
method: 'post',
|
|
56
|
-
url:
|
|
57
|
+
url: url,
|
|
57
58
|
data: data,
|
|
58
59
|
maxBodyLength: Infinity,
|
|
59
60
|
headers: { 'Content-Type': 'application/json' },
|
|
60
61
|
}).then(function(response) {
|
|
61
62
|
console.log("保存字体图标ok");
|
|
62
63
|
}).catch(function(error) {
|
|
63
|
-
console.log("保存字体图标err" + error.message);
|
|
64
|
+
console.log("保存字体图标err:" + error.message);
|
|
65
|
+
console.log(error);
|
|
64
66
|
});
|
|
65
67
|
}
|
|
66
68
|
|
package/tool/checkjs.js
CHANGED
|
@@ -270,7 +270,7 @@ module.exports.start = async function() {
|
|
|
270
270
|
webhookList.push(`1. js语法异常数Error:${errKeys.length}个,占比${calc(errKeys.length, jsFiles.length)}`);
|
|
271
271
|
|
|
272
272
|
// 随机显示5个异常文件到钉钉消息
|
|
273
|
-
var errCount = errKeys.length;
|
|
273
|
+
/*var errCount = errKeys.length;
|
|
274
274
|
if (errCount > 0) {
|
|
275
275
|
var list0 = [];
|
|
276
276
|
while (list0.length < 6 && list0.length < errCount) {
|
|
@@ -285,7 +285,9 @@ module.exports.start = async function() {
|
|
|
285
285
|
if (reportUrl1) {
|
|
286
286
|
webhookList.push(`[更多异常...](${reportUrl1})`);
|
|
287
287
|
}
|
|
288
|
-
}
|
|
288
|
+
}*/
|
|
289
|
+
|
|
290
|
+
|
|
289
291
|
webhookList.push(`7. trimStart(x)和trimEnd(x)使用数:${trimErrKeys.length}个,占比${calc(trimErrKeys.length, jsFiles.length)}`);
|
|
290
292
|
//}
|
|
291
293
|
//if (warnKeys.length > 0) {
|
|
@@ -314,6 +316,9 @@ module.exports.start = async function() {
|
|
|
314
316
|
//if (errKeys.length > 0) {
|
|
315
317
|
detail.push("");
|
|
316
318
|
detail.push(`# ${errKeys.length}个必须修复异常清单`);
|
|
319
|
+
detail.push(`::: tip`);
|
|
320
|
+
detail.push(`检测范围:1. es6语法(不兼容ie的语法);2. 未定义变量(1是会被提升为全局变量造成污染,2是可能有些未定义变量会出现运行时异常);3. 某个对象存在重复的key值(Duplicate key)`);
|
|
321
|
+
detail.push(`:::`);
|
|
317
322
|
errKeys.forEach((fileName, index) => {
|
|
318
323
|
|
|
319
324
|
detail.push(`${index + 1}. ${fileName}`);
|
|
@@ -348,6 +353,11 @@ module.exports.start = async function() {
|
|
|
348
353
|
//if (warnKeys.length > 0) {
|
|
349
354
|
detail.push("");
|
|
350
355
|
detail.push(`# ${warnKeys.length}个建议修复警告清单`);
|
|
356
|
+
detail.push(`::: tip`);
|
|
357
|
+
detail.push(`检测范围:1. 空函数(Empty block statement);2. 语句结尾缺少分号(Unreachable code);3. 多余的空格和制表符(Irregular whitespace not allowed.
|
|
358
|
+
);4. 一个变量被赋值给自己(is assigned to itself);5. 冗余的双重否定(Redundant double negation.);5. 意外的常量条件(Unexpected constant condition.
|
|
359
|
+
)`);
|
|
360
|
+
detail.push(`:::`);
|
|
351
361
|
warnKeys.forEach((fileName, index) => {
|
|
352
362
|
|
|
353
363
|
detail.push(`${index + 1}. ${fileName}`);
|
|
@@ -366,6 +376,9 @@ module.exports.start = async function() {
|
|
|
366
376
|
//if (infoKeys.length > 0) {
|
|
367
377
|
detail.push("");
|
|
368
378
|
detail.push(`# ${infoKeys.length}个可选修复清单`);
|
|
379
|
+
detail.push(`::: tip`);
|
|
380
|
+
detail.push(`检测范围:定义了变量,但没有地方使用它。`);
|
|
381
|
+
detail.push(`:::`);
|
|
369
382
|
infoKeys.forEach((fileName, index) => {
|
|
370
383
|
|
|
371
384
|
detail.push(`${index + 1}. ${fileName}`);
|