js-code-detector 0.0.11 → 0.0.12

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/dist/cjs/index.js CHANGED
@@ -62,6 +62,7 @@ async function umiPluginCallback(api) {
62
62
  const usingFileNoPrefix = usingFiles.map((item) => item.filePath.replace(absPathPrefix, ""));
63
63
  const groupGitDiffLines = gitDiffDetail.filter((item) => usingFileNoPrefix.includes(item.filePath));
64
64
  const reports = (0, import_report_util.createDetectReport)({ groupGitDiffLines, tree, absPathPrefix });
65
+ (0, import_fs2.writeFileSync)((0, import_path.join)(api.cwd, "reports.json"), JSON.stringify(reports, null, 2), { encoding: "utf-8", flag: "w" });
65
66
  const mdContent = (0, import_createMdByJson.createMdByJson)(reports);
66
67
  (0, import_fs2.writeFileSync)((0, import_path.join)(api.cwd, jsonName), mdContent, { encoding: "utf-8", flag: "w" });
67
68
  }
@@ -150,9 +151,6 @@ async function gitDiffDetect() {
150
151
  const mdFileName = `${(0, import_dayjs.default)().format("YYYYMDD_HHmm")}_${jsonName}`;
151
152
  (0, import_fs2.writeFileSync)((0, import_path.join)(process.cwd(), mdFileName), content, { encoding: "utf-8", flag: "w" });
152
153
  import_utils.logger.info("报告完成: " + mdFileName);
153
- (0, import_utils.rimraf)((0, import_path.join)(process.cwd(), today), () => {
154
- import_utils.logger.info("临时目录已删除");
155
- });
156
154
  }
157
155
  // Annotate the CommonJS export names for ESM import in node:
158
156
  0 && (module.exports = {
@@ -6,6 +6,7 @@ type EffectItem = {
6
6
  effects: AstNode[];
7
7
  };
8
8
  export type BlockReport = {
9
+ index: number;
9
10
  kind: BlockReportKind;
10
11
  diff_txt: string[];
11
12
  topAdded: AstNode[];
@@ -22,6 +23,7 @@ type Arg = {
22
23
  gitDiffItem: GitDiffDetail;
23
24
  absPathPrefix: string;
24
25
  blockReports: BlockReport[];
26
+ index: number;
25
27
  };
26
28
  export default function codeBlockDetect(arg: Arg): void;
27
29
  export {};
@@ -35,7 +35,8 @@ module.exports = __toCommonJS(code_block_detect_exports);
35
35
  var import_path = require("path");
36
36
  var import_getAstKitByFilePath = __toESM(require("../ast_util/getAstKitByFilePath"));
37
37
  var import_AstUtil = __toESM(require("../ast_util/AstUtil"));
38
- var createBlockReport = (kind) => ({
38
+ var createBlockReport = (kind, index) => ({
39
+ index,
39
40
  kind,
40
41
  diff_txt: [],
41
42
  topAdded: [],
@@ -48,22 +49,19 @@ var createBlockReport = (kind) => ({
48
49
  removedStillUsing: [],
49
50
  removedEffects: []
50
51
  });
51
- var findOrCreateBlockReport = (blockReports, kind, fromHead) => {
52
- var _a, _b;
53
- if (fromHead) {
54
- for (let i = blockReports.length - 1; i >= 0; i--) {
55
- if (blockReports[i].kind === kind) {
56
- return blockReports[i];
57
- }
52
+ var findOrCreateBlockReport = (blockReports, kind, index) => {
53
+ var _a;
54
+ if (((_a = blockReports.at(-1)) == null ? void 0 : _a.index) === index) {
55
+ const res = blockReports.at(-1);
56
+ if (res.kind !== kind) {
57
+ res.kind = `${res.kind} | ${kind}`;
58
58
  }
59
+ return res;
59
60
  }
60
- if (((_a = blockReports.at(-1)) == null ? void 0 : _a.kind) === kind || kind === "Other" && ((_b = blockReports.at(-1)) == null ? void 0 : _b.kind.startsWith("Other:"))) {
61
- return blockReports.at(-1);
62
- }
63
- return createBlockReport(kind);
61
+ return createBlockReport(kind, index);
64
62
  };
65
63
  function codeBlockDetect(arg) {
66
- const { gitDiffItem, absPathPrefix, blockReports } = arg;
64
+ const { gitDiffItem, absPathPrefix, blockReports, index } = arg;
67
65
  const { filePath, startLineOfNew, items, startLineOfOld } = gitDiffItem;
68
66
  const { mapFileLineToNodeSet, mapUuidToNode } = (0, import_getAstKitByFilePath.default)(filePath, absPathPrefix);
69
67
  const filePathOfOld = (0, import_path.join)(process.cwd(), "..", "source", filePath);
@@ -76,8 +74,8 @@ function codeBlockDetect(arg) {
76
74
  const lineNumberEndOld = lineNumberStartOld + items.filter((item) => item.startsWith("-")).length - 1;
77
75
  const addNodes = import_AstUtil.default.getTopScopeNodesByLineNumberRange(mapFileLineToNodeSet, lineNumberStartNew, lineNumberEndNew);
78
76
  const removeNodes = import_AstUtil.default.getTopScopeNodesByLineNumberRange(mapFileLineToNodeSetOld, lineNumberStartOld, lineNumberEndOld);
79
- iterateNodes(addNodes, "add", { blockReports, programNode });
80
- iterateNodes(removeNodes, "remove", { blockReports, programNode });
77
+ iterateNodes(addNodes, "add", { blockReports, programNode }, index);
78
+ iterateNodes(removeNodes, "remove", { blockReports, programNode }, index);
81
79
  const lastReport = blockReports.at(-1);
82
80
  if (lastReport) {
83
81
  lastReport.diff_txt = items;
@@ -85,7 +83,7 @@ function codeBlockDetect(arg) {
85
83
  lastReport.topRemoved = removeNodes;
86
84
  }
87
85
  }
88
- blockReports.push(createBlockReport("Never"));
86
+ blockReports.push(createBlockReport("Never", NaN));
89
87
  }
90
88
  function getPathsOfNode(topScopeNodes) {
91
89
  const paths = [];
@@ -108,19 +106,19 @@ function filterBySamePathAndLen(list, sameEffectsPaths) {
108
106
  function extractEffectItem(list) {
109
107
  return list.map((e) => ({ ...e, effects: e.effects.map((item) => item.ele) }));
110
108
  }
111
- function pushBlockReport(blockReports, blockReport, programNode) {
112
- const sameNames = blockReport.added.filter((path) => blockReport.removed.includes(path));
113
- if (sameNames.length) {
114
- ["added", "removed"].forEach((key) => {
115
- blockReport[key] = blockReport[key].filter((path) => !sameNames.includes(path));
116
- });
117
- }
109
+ function pushBlockReport(blockReports, blockReport, programNode, index) {
118
110
  if (blockReport.kind.startsWith("Other:")) {
119
111
  ["added", "removed"].forEach((key) => {
120
112
  const tailElements = blockReport[key].map((ele) => ele.split(":").at(-1)).filter(Boolean);
121
113
  blockReport[key] = [...new Set(tailElements)];
122
114
  });
123
115
  }
116
+ const sameNames = blockReport.added.filter((path) => blockReport.removed.includes(path));
117
+ if (sameNames.length) {
118
+ ["added", "removed"].forEach((key) => {
119
+ blockReport[key] = blockReport[key].filter((path) => !sameNames.includes(path));
120
+ });
121
+ }
124
122
  const addedEffectsList = mapNodePath(blockReport.addedEffects);
125
123
  const removedEffectsList = mapNodePath(blockReport.removedEffects);
126
124
  const addedEffectsPaths = addedEffectsList.map((item) => item.effects.map(({ path }) => path)).flat();
@@ -132,44 +130,44 @@ function pushBlockReport(blockReports, blockReport, programNode) {
132
130
  blockReport.addedEffects = extractEffectItem(addedEffects);
133
131
  blockReport.removedEffects = extractEffectItem(removedEffects);
134
132
  }
135
- if (!blockReports.includes(blockReport) && Object.entries(blockReport).filter((e) => e[0] !== "kind").some((e) => e[1].length)) {
133
+ if (!blockReports.includes(blockReport)) {
136
134
  blockReports.push(blockReport);
137
135
  }
138
136
  }
139
- function iterateNodes(topScopeNodes, operation, extra) {
137
+ function iterateNodes(topScopeNodes, operation, extra, index) {
140
138
  for (const topScopeNode of topScopeNodes) {
141
139
  if (["ImportDeclaration", "ImportSpecifier", "ImportDefaultSpecifier"].includes(topScopeNode.type)) {
142
- detectImport({ topScopeNode, operation, extra });
140
+ detectImport({ topScopeNode, operation, extra }, index);
143
141
  } else if (["VariableDeclaration", "VariableDeclarator"].includes(topScopeNode.type) || import_AstUtil.default.isSubNodeOfVariableDeclarator(topScopeNode)) {
144
- detectVariableDeclaration({ topScopeNode, operation, extra });
142
+ detectVariableDeclaration({ topScopeNode, operation, extra }, index);
145
143
  } else if (["FunctionDeclaration", "ClassDeclaration"].includes(topScopeNode.type)) {
146
- detectFnClsDeclaration({ topScopeNode, operation, extra });
144
+ detectFnClsDeclaration({ topScopeNode, operation, extra }, index);
147
145
  } else if (["UnaryExpression", "UpdateExpression"].includes(topScopeNode.type)) {
148
- detectUpdateEffectExp({ topScopeNode, operation, extra });
146
+ detectUpdateEffectExp({ topScopeNode, operation, extra }, index);
149
147
  } else if (["CallExpression"].includes(topScopeNode.type)) {
150
- detectFnCallExp({ topScopeNode, operation, extra });
148
+ detectFnCallExp({ topScopeNode, operation, extra }, index);
151
149
  } else if (["AssignmentExpression"].includes(topScopeNode.type)) {
152
- detectAssignmentEffectExp({ topScopeNode, operation, extra });
150
+ detectAssignmentEffectExp({ topScopeNode, operation, extra }, index);
153
151
  } else if (["ExpressionStatement"].includes(topScopeNode.type)) {
154
152
  const { expression } = topScopeNode;
155
- iterateNodes([expression], operation, extra);
153
+ iterateNodes([expression], operation, extra, index);
156
154
  } else {
157
- detectOther({ topScopeNode, operation, extra });
155
+ detectOther({ topScopeNode, operation, extra }, index);
158
156
  }
159
157
  }
160
158
  }
161
- function detectOther(arg) {
159
+ function detectOther(arg, index) {
162
160
  const { topScopeNode, operation, extra: { blockReports, programNode } } = arg;
163
- const blockReport = findOrCreateBlockReport(blockReports, "Other");
161
+ const blockReport = findOrCreateBlockReport(blockReports, "Other", index);
164
162
  const { added, removed } = blockReport;
165
163
  const nodePaths = getPathsOfNode(topScopeNode._util.nodeCollection);
166
164
  (operation === "add" ? added : removed).push(...nodePaths);
167
165
  blockReport.kind = "Other:" + topScopeNode.type;
168
- pushBlockReport(blockReports, blockReport, programNode);
166
+ pushBlockReport(blockReports, blockReport, programNode, index);
169
167
  }
170
- function detectImport(arg) {
168
+ function detectImport(arg, index) {
171
169
  const { topScopeNode, operation, extra: { blockReports, programNode } } = arg;
172
- const blockReport = findOrCreateBlockReport(blockReports, "Import");
170
+ const blockReport = findOrCreateBlockReport(blockReports, "Import", index);
173
171
  const { added, removed, addedEffects, removedEffects } = blockReport;
174
172
  const specifiers = topScopeNode.type === "ImportDeclaration" ? topScopeNode.specifiers : [topScopeNode];
175
173
  if (Array.isArray(specifiers)) {
@@ -179,23 +177,23 @@ function detectImport(arg) {
179
177
  (operation === "add" ? addedEffects : removedEffects).push({ causeBy: local, effects: [...local._util.effectIds] });
180
178
  });
181
179
  }
182
- pushBlockReport(blockReports, blockReport, programNode);
180
+ pushBlockReport(blockReports, blockReport, programNode, index);
183
181
  }
184
- function detectFnClsDeclaration(arg) {
182
+ function detectFnClsDeclaration(arg, index) {
185
183
  const { topScopeNode, operation, extra: { blockReports, programNode } } = arg;
186
- const blockReport = findOrCreateBlockReport(blockReports, "Declaration");
184
+ const blockReport = findOrCreateBlockReport(blockReports, "Declaration", index);
187
185
  const { added, removed, addedEffects, removedEffects } = blockReport;
188
186
  const { id } = topScopeNode;
189
187
  (operation === "add" ? added : removed).push(id.name);
190
188
  (operation === "add" ? addedEffects : removedEffects).push({ causeBy: id, effects: [...id._util.effectIds] });
191
- pushBlockReport(blockReports, blockReport, programNode);
189
+ pushBlockReport(blockReports, blockReport, programNode, index);
192
190
  }
193
191
  function insertPrefix(n, prefix, sep = ":") {
194
192
  return [prefix, n].join(sep);
195
193
  }
196
- function detectVariableDeclaration(arg) {
194
+ function detectVariableDeclaration(arg, index) {
197
195
  const { topScopeNode, operation, extra: { blockReports, programNode } } = arg;
198
- const blockReport = findOrCreateBlockReport(blockReports, "Declaration");
196
+ const blockReport = findOrCreateBlockReport(blockReports, "Declaration", index);
199
197
  const { added, removed, addedEffects, removedEffects } = blockReport;
200
198
  if (["VariableDeclaration", "VariableDeclarator"].includes(topScopeNode.type)) {
201
199
  let declarations = [];
@@ -232,11 +230,11 @@ function detectVariableDeclaration(arg) {
232
230
  }
233
231
  });
234
232
  }
235
- pushBlockReport(blockReports, blockReport, programNode);
233
+ pushBlockReport(blockReports, blockReport, programNode, index);
236
234
  }
237
- function detectUpdateEffectExp(arg) {
235
+ function detectUpdateEffectExp(arg, index) {
238
236
  const { topScopeNode, operation, extra: { blockReports, programNode } } = arg;
239
- const blockReport = findOrCreateBlockReport(blockReports, "SelfUpdate");
237
+ const blockReport = findOrCreateBlockReport(blockReports, "SelfUpdate", index);
240
238
  const { added, removed, addedEffects, removedEffects } = blockReport;
241
239
  const { argument: args } = topScopeNode;
242
240
  const createdExpIdSet = /* @__PURE__ */ new Set();
@@ -245,11 +243,11 @@ function detectUpdateEffectExp(arg) {
245
243
  (operation === "add" ? added : removed).push(createdExpId.name);
246
244
  (operation === "add" ? addedEffects : removedEffects).push({ causeBy: createdExpId, effects: [...createdExpId._util.effectIds] });
247
245
  }
248
- pushBlockReport(blockReports, blockReport, programNode);
246
+ pushBlockReport(blockReports, blockReport, programNode, index);
249
247
  }
250
- function detectFnCallExp(arg) {
248
+ function detectFnCallExp(arg, index) {
251
249
  const { topScopeNode, operation, extra: { blockReports, programNode } } = arg;
252
- const blockReport = findOrCreateBlockReport(blockReports, "Invoke");
250
+ const blockReport = findOrCreateBlockReport(blockReports, "Invoke", index);
253
251
  const { added, removed, addedEffects, removedEffects } = blockReport;
254
252
  const { callee, arguments: args } = topScopeNode;
255
253
  const argsIds = args.map((arg2) => arg2._util.nodeCollection.filter((n) => n.type === "Identifier")).flat();
@@ -263,11 +261,11 @@ function detectFnCallExp(arg) {
263
261
  (operation === "add" ? added : removed).push(createdExpId.name);
264
262
  (operation === "add" ? addedEffects : removedEffects).push({ causeBy: createdExpId, effects: [...createdExpId._util.effectIds] });
265
263
  }
266
- pushBlockReport(blockReports, blockReport, programNode);
264
+ pushBlockReport(blockReports, blockReport, programNode, index);
267
265
  }
268
- function detectAssignmentEffectExp(arg) {
266
+ function detectAssignmentEffectExp(arg, index) {
269
267
  const { topScopeNode, operation, extra: { blockReports, programNode } } = arg;
270
- const blockReport = findOrCreateBlockReport(blockReports, "Assignment");
268
+ const blockReport = findOrCreateBlockReport(blockReports, "Assignment", index);
271
269
  const { added, removed, addedEffects, removedEffects } = blockReport;
272
270
  const { left, right } = topScopeNode;
273
271
  const idSetLeft = /* @__PURE__ */ new Set();
@@ -281,5 +279,5 @@ function detectAssignmentEffectExp(arg) {
281
279
  for (const createdExp of idSetRight) {
282
280
  (operation === "add" ? added : removed).push(insertPrefix(createdExp.name, "right"));
283
281
  }
284
- pushBlockReport(blockReports, blockReport, programNode);
282
+ pushBlockReport(blockReports, blockReport, programNode, index);
285
283
  }
@@ -28,22 +28,26 @@ var mapReportType = {
28
28
  delete: "删除"
29
29
  };
30
30
  function createMdByJson(report) {
31
- return report.map(reportItemToMd).join("\n\n\n");
31
+ const allFiles = `# 文件汇总
32
+ ${report.map((r) => `- ${r.filePath}`).join("\n")}
33
+
34
+ `;
35
+ return allFiles + report.map(reportItemToMd).join("\n\n\n");
32
36
  }
33
37
  function reportItemToMd(report) {
34
38
  const { filePath, filesDependsOnMe, type, dangerIdentifiers, blockReports } = report;
35
39
  return [
36
40
  `## ${filePath}`,
37
41
  `### 类型: ${mapReportType[type]}`,
38
- filesDependsOnMe.length > 0 ? `### 依赖${filePath}的文件` : "",
39
- ...filesDependsOnMe.map((file) => `- ${file}`),
40
- dangerIdentifiers.length > 0 ? `### 重点检查使用的变量` : "",
41
- dangerIdentifiers.length > 0 ? `> ${dangerIdentifiers.join(", ")}` : "",
42
- blockReports.length > 0 ? `### 代码块分析` : "",
42
+ filesDependsOnMe.length > 0 ? `### 所影响的文件
43
+ ${filesDependsOnMe.map((files) => `- ${files.join("、")}`).join("\n")}` : "",
44
+ dangerIdentifiers.length > 0 ? `### 重点检查使用的变量
45
+ > ${dangerIdentifiers.join(", ")}` : "",
46
+ blockReports.length > 0 ? `### 对比分析 共${blockReports.length}处` : "",
43
47
  ...blockReports.map(blockReportToMd)
44
48
  ].filter(Boolean).join("\n\n");
45
49
  }
46
- function blockReportToMd(block) {
50
+ function blockReportToMd(block, index) {
47
51
  const {
48
52
  kind,
49
53
  diff_txt,
@@ -53,17 +57,19 @@ function blockReportToMd(block) {
53
57
  removedEffects
54
58
  } = block;
55
59
  return [
56
- `#### 修改分类: ${kind}`,
57
- `- 原始diff内容`,
58
- `\`\`\`txt
60
+ `### 对比${index + 1}分析`,
61
+ `- 原始diff内容
62
+ \`\`\`txt
59
63
  ${diff_txt.join("\n")}
60
64
  \`\`\``,
61
- added.length > 0 ? `- 新增标识符` : "",
62
- added.length > 0 ? `> ${added.join(", ")}` : "",
63
- addedEffects.length > 0 ? `- 新增标识符影响` : "",
65
+ `#### 修改分类: ${kind}`,
66
+ added.length > 0 ? `- 新增标识符
67
+ > ${added.join(", ")}` : "",
68
+ addedEffects.length > 0 ? `- 新增标识符影响
69
+ ` : "",
64
70
  addedEffects.map(({ causeBy, effects }) => `> ${causeBy}相关: ${effects.join()}`).join("\n\n"),
65
- removed.length > 0 ? `- 删除标识符` : "",
66
- removed.length > 0 ? `> ${removed.join(", ")}` : "",
71
+ removed.length > 0 ? `- 删除标识符
72
+ > ${removed.join(", ")}` : "",
67
73
  removedEffects.length > 0 ? `- 删除标识符影响` : "",
68
74
  removedEffects.map(({ causeBy, effects }) => `> ${causeBy}相关: ${effects.join()}`).join("\n\n")
69
75
  ].filter(Boolean).join("\n\n");
@@ -0,0 +1 @@
1
+ export default function getFileDepends(filePath: string, tree: Record<string, string[]>): string[][];
@@ -0,0 +1,38 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/util/report_util/getFileDepends.ts
20
+ var getFileDepends_exports = {};
21
+ __export(getFileDepends_exports, {
22
+ default: () => getFileDepends
23
+ });
24
+ module.exports = __toCommonJS(getFileDepends_exports);
25
+ function getFileDepends(filePath, tree) {
26
+ const res = [];
27
+ getFileDependsRecursive(res, [filePath], Object.entries(tree), 2);
28
+ return res;
29
+ }
30
+ function getFileDependsRecursive(res, filePaths, treeEntries, maxTry) {
31
+ const depends = filePaths.map((f) => treeEntries.filter((entry) => entry[1].includes(f)).map((e) => e[0])).flat();
32
+ if (depends.length > 0) {
33
+ res.push(depends);
34
+ if (maxTry === 0)
35
+ return;
36
+ getFileDependsRecursive(res, depends, treeEntries, maxTry - 1);
37
+ }
38
+ }
@@ -3,7 +3,7 @@ import { BlockReport } from "./report_util/code_block_detect";
3
3
  export type DetectReport = {
4
4
  filePath: string;
5
5
  type: "modify" | "add" | "delete";
6
- filesDependsOnMe: string[];
6
+ filesDependsOnMe: string[][];
7
7
  dangerIdentifiers: string[];
8
8
  blockReports: BlockReport[];
9
9
  };
@@ -22,6 +22,7 @@ export declare function createDetectReport(arg: Arg): {
22
22
  causeBy: string;
23
23
  effects: (string | undefined)[];
24
24
  }[];
25
+ index: number;
25
26
  diff_txt: string[];
26
27
  added: string[];
27
28
  addedNotUsed: string[];
@@ -32,7 +33,7 @@ export declare function createDetectReport(arg: Arg): {
32
33
  }[];
33
34
  filePath: string;
34
35
  type: "add" | "modify" | "delete";
35
- filesDependsOnMe: string[];
36
+ filesDependsOnMe: string[][];
36
37
  dangerIdentifiers: string[];
37
38
  }[];
38
39
  export {};
@@ -36,13 +36,13 @@ var import_code_block_detect = __toESM(require("./report_util/code_block_detect"
36
36
  var import_getAstKitByFilePath = __toESM(require("./ast_util/getAstKitByFilePath"));
37
37
  var import_AstUtil = __toESM(require("./ast_util/AstUtil"));
38
38
  var import_file_identifier_detect = require("./report_util/file_identifier_detect");
39
+ var import_getFileDepends = __toESM(require("./report_util/getFileDepends"));
39
40
  function createDetectReport(arg) {
40
41
  const { groupGitDiffLines, tree, absPathPrefix } = arg;
41
42
  const reports = [];
42
- const entries = Object.entries(tree);
43
- groupGitDiffLines.forEach((item) => {
43
+ groupGitDiffLines.forEach((item, index) => {
44
44
  const { filePath, type } = item;
45
- const filesDependsOnMe = entries.filter((entry) => entry[1].includes(filePath)).map((e) => e[0]);
45
+ const filesDependsOnMe = (0, import_getFileDepends.default)(filePath, tree);
46
46
  let reportItem = reports.find((e) => e.filePath === filePath);
47
47
  if (!reportItem) {
48
48
  reportItem = {
@@ -56,7 +56,7 @@ function createDetectReport(arg) {
56
56
  }
57
57
  reportItem.dangerIdentifiers = (0, import_file_identifier_detect.fileIdentifierDetect)(filePath, absPathPrefix);
58
58
  if (type === "modify") {
59
- (0, import_code_block_detect.default)({ gitDiffItem: item, absPathPrefix, blockReports: reportItem.blockReports });
59
+ (0, import_code_block_detect.default)({ gitDiffItem: item, absPathPrefix, blockReports: reportItem.blockReports, index });
60
60
  }
61
61
  });
62
62
  return reports.map((report) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-code-detector",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",