@goshenkata/dryscan-core 1.0.10 → 1.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goshenkata/dryscan-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "Core library for DryScan - semantic code duplication analyzer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@types/better-sqlite3": "^7.6.13",
|
|
39
38
|
"@types/debug": "^4.1.12",
|
|
40
39
|
"@types/node": "^25.0.3",
|
|
41
40
|
"chai": "^6.2.2",
|
|
@@ -49,7 +48,6 @@
|
|
|
49
48
|
"@langchain/core": "^1.1.8",
|
|
50
49
|
"@langchain/google-genai": "^2.1.3",
|
|
51
50
|
"@langchain/ollama": "^1.1.0",
|
|
52
|
-
"better-sqlite3": "^12.5.0",
|
|
53
51
|
"debug": "^4.4.3",
|
|
54
52
|
"glob-gitignore": "^1.0.15",
|
|
55
53
|
"ignore": "^7.0.5",
|
|
@@ -58,9 +56,9 @@
|
|
|
58
56
|
"minimatch": "^10.1.1",
|
|
59
57
|
"reflect-metadata": "^0.2.2",
|
|
60
58
|
"short-uuid": "^6.0.3",
|
|
59
|
+
"sqlite3": "^5.1.7",
|
|
61
60
|
"tree-sitter": "^0.25.0",
|
|
62
61
|
"tree-sitter-java": "^0.23.5",
|
|
63
|
-
"tree-sitter-python": "^0.25.0",
|
|
64
62
|
"typeorm": "^0.3.28",
|
|
65
63
|
"upath": "^2.0.1"
|
|
66
64
|
}
|
|
@@ -19,7 +19,7 @@ export class DryScanDatabase {
|
|
|
19
19
|
await fs.mkdir(upath.dirname(dbPath), { recursive: true });
|
|
20
20
|
|
|
21
21
|
this.dataSource = new DataSource({
|
|
22
|
-
type: "
|
|
22
|
+
type: "sqlite",
|
|
23
23
|
database: dbPath,
|
|
24
24
|
entities: [IndexUnitEntity, FileEntity],
|
|
25
25
|
synchronize: true,
|
|
@@ -149,19 +149,32 @@ export class DuplicateService {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
if (left.unitType === IndexUnitType.FUNCTION) {
|
|
152
|
-
const parentClassSimilarity = this.parentSimilarity(left, right, IndexUnitType.CLASS);
|
|
153
152
|
const weights = indexConfig.weights.function;
|
|
154
|
-
|
|
153
|
+
const hasParentClass = !!this.findParentOfType(left, IndexUnitType.CLASS) && !!this.findParentOfType(right, IndexUnitType.CLASS);
|
|
154
|
+
const parentClassSimilarity = hasParentClass ? this.parentSimilarity(left, right, IndexUnitType.CLASS) : 0;
|
|
155
|
+
|
|
156
|
+
// Re-normalize weights when parent context is missing, so standalone units aren't penalized.
|
|
157
|
+
const totalWeight = weights.self + (hasParentClass ? weights.parentClass : 0);
|
|
158
|
+
return ((weights.self * selfSimilarity) + (hasParentClass ? (weights.parentClass * parentClassSimilarity) : 0)) / totalWeight;
|
|
155
159
|
}
|
|
156
160
|
|
|
157
161
|
const weights = indexConfig.weights.block;
|
|
158
|
-
const
|
|
159
|
-
const
|
|
162
|
+
const hasParentFunction = !!this.findParentOfType(left, IndexUnitType.FUNCTION) && !!this.findParentOfType(right, IndexUnitType.FUNCTION);
|
|
163
|
+
const hasParentClass = !!this.findParentOfType(left, IndexUnitType.CLASS) && !!this.findParentOfType(right, IndexUnitType.CLASS);
|
|
164
|
+
const parentFuncSim = hasParentFunction ? this.parentSimilarity(left, right, IndexUnitType.FUNCTION) : 0;
|
|
165
|
+
const parentClassSim = hasParentClass ? this.parentSimilarity(left, right, IndexUnitType.CLASS) : 0;
|
|
166
|
+
|
|
167
|
+
// Re-normalize weights when some parent context is missing.
|
|
168
|
+
const totalWeight =
|
|
169
|
+
weights.self +
|
|
170
|
+
(hasParentFunction ? weights.parentFunction : 0) +
|
|
171
|
+
(hasParentClass ? weights.parentClass : 0);
|
|
172
|
+
|
|
160
173
|
return (
|
|
161
|
-
weights.self * selfSimilarity +
|
|
162
|
-
weights.parentFunction * parentFuncSim +
|
|
163
|
-
weights.parentClass * parentClassSim
|
|
164
|
-
);
|
|
174
|
+
(weights.self * selfSimilarity) +
|
|
175
|
+
(hasParentFunction ? (weights.parentFunction * parentFuncSim) : 0) +
|
|
176
|
+
(hasParentClass ? (weights.parentClass * parentClassSim) : 0)
|
|
177
|
+
) / totalWeight;
|
|
165
178
|
}
|
|
166
179
|
|
|
167
180
|
private parentSimilarity(left: IndexUnit, right: IndexUnit, targetType: IndexUnitType): number {
|