(node: PRNode, directNodes: PRNode[])
| 54 | } |
| 55 | |
| 56 | function isLikelyNoiseNode(node: PRNode, directNodes: PRNode[]): boolean { |
| 57 | if (node.prZone !== "direct") return false; |
| 58 | |
| 59 | const sameDiffCount = directNodes.filter( |
| 60 | (n) => n.gitDiff && node.gitDiff && n.gitDiff === node.gitDiff |
| 61 | ).length; |
| 62 | |
| 63 | const diff = node.gitDiff || ""; |
| 64 | |
| 65 | if (node.type === "Variable") return sameDiffCount > 1; |
| 66 | |
| 67 | if (node.type === "Function" || node.type === "Class") { |
| 68 | const diffHeaderMatch = diff.match(/^@@[^\n]*@@[^\n]*/)?.[0] || ""; |
| 69 | const isHunkAnchor = |
| 70 | diffHeaderMatch.includes(`def ${node.name}`) || |
| 71 | diffHeaderMatch.includes(`class ${node.name}`); |
| 72 | |
| 73 | const addedOrChanged = |
| 74 | diffAddsOrRemovesSymbol(diff, node.name, "def") || |
| 75 | diffAddsOrRemovesSymbol(diff, node.name, "class") || |
| 76 | (isHunkAnchor && hasAnchorBodyEdit(diff)); |
| 77 | |
| 78 | if (!addedOrChanged && sameDiffCount > 1) return true; |
| 79 | if (node.name === "<module>" && !diff.startsWith("@@ -0,0")) return true; |
| 80 | } |
| 81 | |
| 82 | return false; |
| 83 | } |
| 84 | |
| 85 | function isMeaningfulOrphan(node: PRNode, links: PRLink[]): boolean { |
| 86 | if (!node.isOrphan) return false; |
no test coverage detected