@shakibkhatri/idiolect-core 0.0.0-stage → 0.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/data/ai-tells.json +15 -0
- package/dist/analyzer-go.d.ts +6 -0
- package/dist/analyzer-go.js +144 -0
- package/dist/analyzer-go.js.map +1 -0
- package/dist/analyzer-py.d.ts +4 -0
- package/dist/analyzer-py.js +139 -0
- package/dist/analyzer-py.js.map +1 -0
- package/dist/analyzer-ts.d.ts +3 -0
- package/dist/analyzer-ts.js +164 -0
- package/dist/analyzer-ts.js.map +1 -0
- package/dist/analyzer.d.ts +138 -0
- package/dist/analyzer.js +336 -0
- package/dist/analyzer.js.map +1 -0
- package/dist/baseline.d.ts +7 -0
- package/dist/baseline.js +167 -0
- package/dist/baseline.js.map +1 -0
- package/dist/check.d.ts +21 -0
- package/dist/check.js +98 -0
- package/dist/check.js.map +1 -0
- package/dist/collector.d.ts +37 -0
- package/dist/collector.js +136 -0
- package/dist/collector.js.map +1 -0
- package/dist/config.d.ts +71 -0
- package/dist/config.js +59 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/languages.d.ts +4 -0
- package/dist/languages.js +7 -0
- package/dist/languages.js.map +1 -0
- package/dist/llm.d.ts +15 -0
- package/dist/llm.js +153 -0
- package/dist/llm.js.map +1 -0
- package/dist/metrics.d.ts +19 -0
- package/dist/metrics.js +105 -0
- package/dist/metrics.js.map +1 -0
- package/dist/parser.d.ts +3 -0
- package/dist/parser.js +25 -0
- package/dist/parser.js.map +1 -0
- package/dist/profile.d.ts +71 -0
- package/dist/profile.js +62 -0
- package/dist/profile.js.map +1 -0
- package/dist/redact.d.ts +1 -0
- package/dist/redact.js +24 -0
- package/dist/redact.js.map +1 -0
- package/dist/render.d.ts +16 -0
- package/dist/render.js +102 -0
- package/dist/render.js.map +1 -0
- package/dist/sampler.d.ts +26 -0
- package/dist/sampler.js +71 -0
- package/dist/sampler.js.map +1 -0
- package/dist/served.d.ts +8 -0
- package/dist/served.js +39 -0
- package/dist/served.js.map +1 -0
- package/dist/styles.d.ts +39 -0
- package/dist/styles.js +76 -0
- package/dist/styles.js.map +1 -0
- package/dist/unbot.d.ts +19 -0
- package/dist/unbot.js +48 -0
- package/dist/unbot.js.map +1 -0
- package/dist/writer.d.ts +19 -0
- package/dist/writer.js +122 -0
- package/dist/writer.js.map +1 -0
- package/grammars/go.LICENSE +21 -0
- package/grammars/go.wasm +0 -0
- package/grammars/kotlin.LICENSE +21 -0
- package/grammars/kotlin.wasm +0 -0
- package/grammars/python.LICENSE +21 -0
- package/grammars/python.wasm +0 -0
- package/grammars/tsx.LICENSE +21 -0
- package/grammars/tsx.wasm +0 -0
- package/grammars/typescript.LICENSE +21 -0
- package/grammars/typescript.wasm +0 -0
- package/package.json +27 -3
- package/styles/go-caddy.json +1368 -0
- package/styles/kotlin-tivi.json +1505 -0
- package/styles/python-httpx.json +1052 -0
- package/styles/typescript-vue.json +1473 -0
- package/README.md +0 -3
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[
|
|
2
|
+
{ "id": "comments.buzzwords", "metric": "comments.buzzword-ratio", "text": "Do not use words like robust, seamless, leverage, comprehensive, utilize, streamline, crucial or delve in comments." },
|
|
3
|
+
{ "id": "comments.restating", "metric": "comments.restates-ratio", "text": "Do not start comments with \"This function\", \"This method\" or \"This class\". Say what is not obvious from the code, or write nothing." },
|
|
4
|
+
{ "id": "comments.emoji", "metric": "comments.emoji-ratio", "text": "No emoji in comments." },
|
|
5
|
+
{ "id": "comments.private-docblocks", "metric": "comments.private-doc-ratio", "text": "Do not write doc comments on private functions and properties." },
|
|
6
|
+
{ "id": "naming.generic", "metric": "naming.generic-ratio", "text": "No generic names like handleData, processItem, result2 or helper. Name the thing after what it is." },
|
|
7
|
+
{ "id": "errors.try-everything", "metric": "errors.try-per-kloc", "text": "Do not wrap code in try/catch defensively. Let errors propagate unless there is a specific recovery.", "language": ["kotlin", "typescript", "python"] },
|
|
8
|
+
{ "id": "errors.force-unwrap", "metric": "errors.force-unwrap-per-kloc", "text": "Do not use !! to force-unwrap nullable values.", "language": "kotlin" },
|
|
9
|
+
{ "id": "errors.non-null-assertion", "metric": "errors.force-unwrap-per-kloc", "text": "Do not use the ! non-null assertion. Narrow the type or handle the undefined case.", "language": "typescript" },
|
|
10
|
+
{ "id": "types.any", "metric": "typescript.any-per-kloc", "text": "Do not use any. Type the value or use unknown.", "language": "typescript" },
|
|
11
|
+
{ "id": "errors.bare-except", "metric": "python.bare-except-per-kloc", "text": "Do not use a bare except. Catch the exception you expect.", "language": "python" },
|
|
12
|
+
{ "id": "errors.panic", "metric": "go.panic-per-kloc", "text": "Do not panic. Return the error.", "language": "go" },
|
|
13
|
+
{ "id": "errors.unchecked-assertion", "metric": "errors.force-unwrap-per-kloc", "text": "Use the two-value form of type assertions, v, ok := x.(T), so a wrong type does not panic.", "language": "go" },
|
|
14
|
+
{ "id": "comments.todo", "metric": "comments.todo-ratio", "text": "Do not leave TODO comments." }
|
|
15
|
+
]
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Node } from "web-tree-sitter";
|
|
2
|
+
import { type AnalyzeOptions, type LanguageStats } from "./analyzer.js";
|
|
3
|
+
import type { LineRange } from "./collector.js";
|
|
4
|
+
export declare const analyzeGo: (code: string, owned?: LineRange[], opts?: AnalyzeOptions) => Promise<LanguageStats>;
|
|
5
|
+
/** Comments that sit right above a top-level declaration are its doc, Go has no separate syntax for that. */
|
|
6
|
+
export declare function isGoDocComment(n: Node): boolean;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { analyzeTree, bump, commentText, countComment, countCommentText, countName, firstWord, GENERIC_NAME } from "./analyzer.js";
|
|
2
|
+
const NEST = new Set(["if_statement", "for_statement", "expression_switch_statement", "type_switch_statement", "select_statement", "func_literal"]);
|
|
3
|
+
const DECLS = new Set(["function_declaration", "method_declaration", "type_declaration", "var_declaration", "const_declaration", "package_clause"]);
|
|
4
|
+
export const analyzeGo = (code, owned, opts = {}) => analyzeTree(code, "go", count, owned, opts);
|
|
5
|
+
const field = (n, name) => n.childForFieldName(name);
|
|
6
|
+
const exported = (id) => /^[A-Z]/.test(id);
|
|
7
|
+
function count(n, s, test) {
|
|
8
|
+
switch (n.type) {
|
|
9
|
+
case "function_declaration":
|
|
10
|
+
case "method_declaration": return countFunction(n, s, test);
|
|
11
|
+
case "type_spec": {
|
|
12
|
+
const id = field(n, "name")?.text, type = field(n, "type");
|
|
13
|
+
if (type?.type === "struct_type")
|
|
14
|
+
s.go.structs++;
|
|
15
|
+
if (type?.type === "interface_type")
|
|
16
|
+
s.go.interfaces++;
|
|
17
|
+
countName(id, "class", s);
|
|
18
|
+
return countDoc(n.parent, id, s);
|
|
19
|
+
}
|
|
20
|
+
case "const_spec":
|
|
21
|
+
case "var_spec": {
|
|
22
|
+
const id = field(n, "name")?.text;
|
|
23
|
+
const top = n.parent?.parent?.type === "source_file";
|
|
24
|
+
countName(id, top ? (n.type === "const_spec" ? "constant" : "property") : "local", s);
|
|
25
|
+
if (top)
|
|
26
|
+
countDoc(n.parent, id, s);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
case "short_var_declaration": {
|
|
30
|
+
for (const c of field(n, "left")?.namedChildren ?? [])
|
|
31
|
+
if (c?.type === "identifier" && c.text !== "_")
|
|
32
|
+
countName(c.text, "local", s);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
case "field_declaration": {
|
|
36
|
+
const id = field(n, "name")?.text;
|
|
37
|
+
countName(id, "property", s);
|
|
38
|
+
if (id && field(n, "type")?.text === "bool")
|
|
39
|
+
bump(s.naming.booleanPrefix, firstWord(id));
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
case "parameter_declaration": {
|
|
43
|
+
const id = field(n, "name")?.text;
|
|
44
|
+
if (id && n.parent?.parent?.type !== "method_elem")
|
|
45
|
+
countName(id, "parameter", s);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
case "comment": {
|
|
49
|
+
// Go doc comments are plain // comments above a declaration, so they count as doc, not line
|
|
50
|
+
if (!isGoDocComment(n))
|
|
51
|
+
return countComment(n, s);
|
|
52
|
+
s.comments.doc++;
|
|
53
|
+
return countCommentText(commentText(n.text), s);
|
|
54
|
+
}
|
|
55
|
+
case "if_statement":
|
|
56
|
+
if (/\berr\s*!=\s*nil\b/.test(field(n, "condition")?.text ?? ""))
|
|
57
|
+
s.go.errChecks++;
|
|
58
|
+
return;
|
|
59
|
+
case "type_assertion_expression": {
|
|
60
|
+
// v, ok := x.(T) is checked, anything else can panic
|
|
61
|
+
const list = n.parent;
|
|
62
|
+
const lhs = list?.parent?.childForFieldName("left");
|
|
63
|
+
if (!(list?.type === "expression_list" && lhs?.namedChildren.length === 2))
|
|
64
|
+
s.errors.forceUnwrap++;
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
case "call_expression":
|
|
68
|
+
if (field(n, "function")?.text === "panic")
|
|
69
|
+
s.go.panics++;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function countFunction(n, s, test) {
|
|
74
|
+
const f = s.functions;
|
|
75
|
+
f.count++;
|
|
76
|
+
const fname = field(n, "name")?.text;
|
|
77
|
+
// test_x and TestX are the only forms the framework allows, so the name says nothing about the developer
|
|
78
|
+
if (test)
|
|
79
|
+
s.tests.functions++;
|
|
80
|
+
else {
|
|
81
|
+
countName(fname, "function", s);
|
|
82
|
+
if (fname && GENERIC_NAME.test(fname))
|
|
83
|
+
s.naming.genericNames++;
|
|
84
|
+
}
|
|
85
|
+
if (fname && !test)
|
|
86
|
+
bump(s.naming.functionVerb, firstWord(fname));
|
|
87
|
+
countDoc(n, fname, s);
|
|
88
|
+
bump(f.params, field(n, "parameters")?.namedChildren.length ?? 0);
|
|
89
|
+
const result = field(n, "result");
|
|
90
|
+
if (result?.type === "parameter_list" && result.namedChildren.some((c) => c?.childForFieldName("name")))
|
|
91
|
+
s.go.namedReturns++;
|
|
92
|
+
if (fname && !test && result?.text === "bool")
|
|
93
|
+
bump(s.naming.booleanPrefix, firstWord(fname));
|
|
94
|
+
const body = field(n, "body");
|
|
95
|
+
if (!body)
|
|
96
|
+
return;
|
|
97
|
+
f.blockBody++;
|
|
98
|
+
bump(f.lengthLines, n.endPosition.row - n.startPosition.row + 1);
|
|
99
|
+
let maxDepth = 0;
|
|
100
|
+
let early = false;
|
|
101
|
+
const walk = (x, depth, inner) => {
|
|
102
|
+
if (x.type === "return_statement" && depth > 0 && !inner)
|
|
103
|
+
early = true;
|
|
104
|
+
const d = NEST.has(x.type) ? depth + 1 : depth;
|
|
105
|
+
maxDepth = Math.max(maxDepth, d);
|
|
106
|
+
for (const c of x.namedChildren)
|
|
107
|
+
if (c)
|
|
108
|
+
walk(c, d, inner || x.type === "func_literal");
|
|
109
|
+
};
|
|
110
|
+
walk(body, 0, false);
|
|
111
|
+
bump(f.maxNesting, maxDepth);
|
|
112
|
+
if (early)
|
|
113
|
+
f.earlyReturn++;
|
|
114
|
+
}
|
|
115
|
+
/** Top-level declarations only. Exported means public. The doc comment is the comment block ending on the line above. */
|
|
116
|
+
function countDoc(decl, id, s) {
|
|
117
|
+
if (decl.parent?.type !== "source_file" || !id)
|
|
118
|
+
return;
|
|
119
|
+
const isPrivate = !exported(id);
|
|
120
|
+
let prev = decl.previousNamedSibling;
|
|
121
|
+
let documented = false;
|
|
122
|
+
let row = decl.startPosition.row;
|
|
123
|
+
while (prev?.type === "comment" && prev.endPosition.row === row - 1) {
|
|
124
|
+
documented = true;
|
|
125
|
+
row = prev.startPosition.row;
|
|
126
|
+
prev = prev.previousNamedSibling;
|
|
127
|
+
}
|
|
128
|
+
s.comments[isPrivate ? "privateDecls" : "publicDecls"]++;
|
|
129
|
+
if (documented)
|
|
130
|
+
s.comments[isPrivate ? "privateDocumented" : "publicDocumented"]++;
|
|
131
|
+
}
|
|
132
|
+
/** Comments that sit right above a top-level declaration are its doc, Go has no separate syntax for that. */
|
|
133
|
+
export function isGoDocComment(n) {
|
|
134
|
+
if (n.parent?.type !== "source_file")
|
|
135
|
+
return false;
|
|
136
|
+
let next = n.nextNamedSibling;
|
|
137
|
+
let row = n.endPosition.row;
|
|
138
|
+
while (next?.type === "comment" && next.startPosition.row === row + 1) {
|
|
139
|
+
row = next.endPosition.row;
|
|
140
|
+
next = next.nextNamedSibling;
|
|
141
|
+
}
|
|
142
|
+
return !!next && DECLS.has(next.type) && next.startPosition.row === row + 1;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=analyzer-go.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzer-go.js","sourceRoot":"","sources":["../src/analyzer-go.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAA0D,MAAM,eAAe,CAAC;AAG3L,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,eAAe,EAAE,6BAA6B,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,cAAc,CAAC,CAAC,CAAC;AACpJ,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,sBAAsB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAEpJ,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,KAAmB,EAAE,OAAuB,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AAEvI,MAAM,KAAK,GAAG,CAAC,CAAO,EAAE,IAAY,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;AACnE,MA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AAC;QACpE,UAAU,GAAG,IAAI,CAAC;QAClB,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;QAC7B,IAAI,GAAG,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;IACD,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC;IACzD,IAAI,UAAU;QAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,kBAAkB,CAAC,EAAE,CAAC;AACrF,CAAC;AAED,6GAA6G;AAC7G,MAAM,UAAU,cAAc,CAAC,CAAO;IACpC,IAAI,CAAC,CAAC,MAAM,EAAE,IAAI,KAAK,aAAa;QAAE,OAAO,KAAK,CAAC;IACnD,IAAI,IAAI,GAAG,CAAC,CAAC,gBAAgB,CAAC;IAC9B,IAAI,GAAG,GAAG,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC;IAC5B,OAAO,IAAI,EAAE,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,KAAK,GAAG,GAAG,CAAC,EAAE,CAAC;QAAC,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC;QAAC,IAAI,GAAG,IAAI,CAAC,gBAAgB,CAAC;IAAC,CAAC;IACpI,OAAO,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,KAAK,GAAG,GAAG,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type AnalyzeOptions, type LanguageStats } from "./analyzer.js";
|
|
2
|
+
import type { LineRange } from "./collector.js";
|
|
3
|
+
export declare const analyzePython: (code: string, owned?: LineRange[], opts?: AnalyzeOptions) => Promise<LanguageStats>;
|
|
4
|
+
export declare const docstringText: (raw: string) => string;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { analyzeTree, bump, countComment, countCommentText, countName, firstWord, GENERIC_NAME } from "./analyzer.js";
|
|
2
|
+
const NEST = new Set(["if_statement", "for_statement", "while_statement", "try_statement", "with_statement", "match_statement", "lambda"]);
|
|
3
|
+
const LITERAL = new Set(["string", "concatenated_string", "integer", "float", "true", "false", "none", "list", "tuple", "dictionary", "set"]);
|
|
4
|
+
const COMPREHENSIONS = new Set(["list_comprehension", "dictionary_comprehension", "set_comprehension", "generator_expression"]);
|
|
5
|
+
const PARAMS = new Set(["identifier", "typed_parameter", "default_parameter", "typed_default_parameter", "list_splat_pattern", "dictionary_splat_pattern"]);
|
|
6
|
+
export const analyzePython = (code, owned, opts = {}) => analyzeTree(code, "python", count, owned, opts);
|
|
7
|
+
const field = (n, name) => n.childForFieldName(name);
|
|
8
|
+
const isPrivateName = (id) => id.startsWith("_") && !id.startsWith("__");
|
|
9
|
+
/** A decorated definition is one statement, so docs and scope are read from the wrapper. */
|
|
10
|
+
const statementOf = (n) => (n.parent?.type === "decorated_definition" ? n.parent : n);
|
|
11
|
+
const isModuleLevel = (n) => statementOf(n).parent?.type === "module";
|
|
12
|
+
const docstring = (body) => {
|
|
13
|
+
const first = body?.namedChildren[0];
|
|
14
|
+
return first?.type === "expression_statement" && first.namedChildren[0]?.type === "string" ? first.namedChildren[0] : undefined;
|
|
15
|
+
};
|
|
16
|
+
export const docstringText = (raw) => raw.replace(/^[a-zA-Z]*("""|\'\'\'|"|')|("""|\'\'\'|"|')$/g, "").split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
17
|
+
function count(n, s, test) {
|
|
18
|
+
switch (n.type) {
|
|
19
|
+
case "module": {
|
|
20
|
+
const d = docstring(n);
|
|
21
|
+
if (d) {
|
|
22
|
+
s.comments.doc++;
|
|
23
|
+
countCommentText(docstringText(d.text), s);
|
|
24
|
+
}
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
case "function_definition": return countFunction(n, s, test);
|
|
28
|
+
case "class_definition": {
|
|
29
|
+
countName(field(n, "name")?.text, "class", s);
|
|
30
|
+
if (n.parent?.type === "decorated_definition" && n.parent.namedChildren.some((c) => c?.type === "decorator" && /\bdataclass\b/.test(c.text)))
|
|
31
|
+
s.python.dataclasses++;
|
|
32
|
+
return countDoc(n, field(n, "name")?.text, docstring(field(n, "body")), s);
|
|
33
|
+
}
|
|
34
|
+
case "assignment": {
|
|
35
|
+
if (n.parent?.type !== "expression_statement")
|
|
36
|
+
return;
|
|
37
|
+
const left = field(n, "left"), right = field(n, "right");
|
|
38
|
+
// self.x = ... in a method is a property, a bare name is a local, module level is a constant when it holds a literal
|
|
39
|
+
if (left?.type === "attribute" && left.namedChildren[0]?.text === "self") {
|
|
40
|
+
const id = left.namedChildren[1]?.text;
|
|
41
|
+
countName(id, "property", s);
|
|
42
|
+
if (id && (right?.type === "true" || right?.type === "false"))
|
|
43
|
+
bump(s.naming.booleanPrefix, firstWord(id));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (left?.type !== "identifier")
|
|
47
|
+
return;
|
|
48
|
+
const scope = n.parent.parent?.type;
|
|
49
|
+
const kind = scope === "module" ? (right && LITERAL.has(right.type) ? "constant" : "property") : scope === "block" && n.parent.parent?.parent?.type === "class_definition" ? "property" : "local";
|
|
50
|
+
countName(left.text, kind, s);
|
|
51
|
+
if (right?.type === "true" || right?.type === "false" || field(n, "type")?.text === "bool")
|
|
52
|
+
bump(s.naming.booleanPrefix, firstWord(left.text));
|
|
53
|
+
if (kind !== "local")
|
|
54
|
+
countDoc(n.parent, left.text, undefined, s);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
case "comment": return countComment(n, s);
|
|
58
|
+
case "try_statement":
|
|
59
|
+
s.errors.tryCatch++;
|
|
60
|
+
return;
|
|
61
|
+
case "except_clause":
|
|
62
|
+
if (n.namedChildren.every((c) => c?.type === "block" || c?.type === "comment"))
|
|
63
|
+
s.python.bareExcepts++;
|
|
64
|
+
return;
|
|
65
|
+
case "string":
|
|
66
|
+
if (/^[a-zA-Z]*[fF]/.test(n.firstChild?.text ?? ""))
|
|
67
|
+
s.python.fStrings++;
|
|
68
|
+
return;
|
|
69
|
+
case "call": {
|
|
70
|
+
const fn = field(n, "function");
|
|
71
|
+
if (fn?.type === "attribute" && fn.namedChildren[0]?.type === "string" && fn.namedChildren[1]?.text === "format")
|
|
72
|
+
s.python.formatCalls++;
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
default: if (COMPREHENSIONS.has(n.type))
|
|
76
|
+
s.python.comprehensions++;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function countFunction(n, s, test) {
|
|
80
|
+
const f = s.functions;
|
|
81
|
+
f.count++;
|
|
82
|
+
const fname = field(n, "name")?.text;
|
|
83
|
+
const magic = !!fname && fname.startsWith("__");
|
|
84
|
+
// test_x and TestX are the only forms the framework allows, so the name says nothing about the developer
|
|
85
|
+
if (test)
|
|
86
|
+
s.tests.functions++;
|
|
87
|
+
else if (!magic) {
|
|
88
|
+
countName(fname, "function", s);
|
|
89
|
+
if (fname && GENERIC_NAME.test(fname))
|
|
90
|
+
s.naming.genericNames++;
|
|
91
|
+
}
|
|
92
|
+
if (fname && !test && !magic)
|
|
93
|
+
bump(s.naming.functionVerb, firstWord(fname));
|
|
94
|
+
const body = field(n, "body");
|
|
95
|
+
countDoc(n, fname, docstring(body), s);
|
|
96
|
+
const params = field(n, "parameters")?.namedChildren.filter((c) => c && PARAMS.has(c.type) && c.text !== "self" && c.text !== "cls") ?? [];
|
|
97
|
+
bump(f.params, params.length);
|
|
98
|
+
const ret = field(n, "return_type");
|
|
99
|
+
if (ret || params.some((c) => c.type.startsWith("typed_")))
|
|
100
|
+
s.python.typeHinted++;
|
|
101
|
+
if (fname && !test && ret?.text === "bool")
|
|
102
|
+
bump(s.naming.booleanPrefix, firstWord(fname));
|
|
103
|
+
if (!body)
|
|
104
|
+
return;
|
|
105
|
+
f.blockBody++;
|
|
106
|
+
bump(f.lengthLines, n.endPosition.row - n.startPosition.row + 1);
|
|
107
|
+
let maxDepth = 0;
|
|
108
|
+
let early = false;
|
|
109
|
+
const walk = (x, depth, inner) => {
|
|
110
|
+
if (x.type === "function_definition" || x.type === "class_definition")
|
|
111
|
+
return;
|
|
112
|
+
if (x.type === "return_statement" && depth > 0 && !inner)
|
|
113
|
+
early = true;
|
|
114
|
+
const d = NEST.has(x.type) ? depth + 1 : depth;
|
|
115
|
+
maxDepth = Math.max(maxDepth, d);
|
|
116
|
+
for (const c of x.namedChildren)
|
|
117
|
+
if (c)
|
|
118
|
+
walk(c, d, inner || x.type === "lambda");
|
|
119
|
+
};
|
|
120
|
+
walk(body, 0, false);
|
|
121
|
+
bump(f.maxNesting, maxDepth);
|
|
122
|
+
if (early)
|
|
123
|
+
f.earlyReturn++;
|
|
124
|
+
}
|
|
125
|
+
/** Module and class level only. A leading underscore makes it private, a docstring documents it. */
|
|
126
|
+
function countDoc(n, id, documented, s) {
|
|
127
|
+
const stmt = statementOf(n);
|
|
128
|
+
const scope = stmt.parent?.type;
|
|
129
|
+
if (scope !== "module" && !(scope === "block" && stmt.parent?.parent?.type === "class_definition"))
|
|
130
|
+
return;
|
|
131
|
+
const isPrivate = !!id && isPrivateName(id);
|
|
132
|
+
s.comments[isPrivate ? "privateDecls" : "publicDecls"]++;
|
|
133
|
+
if (documented) {
|
|
134
|
+
s.comments[isPrivate ? "privateDocumented" : "publicDocumented"]++;
|
|
135
|
+
s.comments.doc++;
|
|
136
|
+
countCommentText(docstringText(documented.text), s);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=analyzer-py.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzer-py.js","sourceRoot":"","sources":["../src/analyzer-py.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY,EAAE,gBAAgB,EAAE,S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;QAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AAC7B,CAAC;AAED,oGAAoG;AACpG,SAAS,QAAQ,CAAC,CAAO,EAAE,EAAsB,EAAE,UAA4B,EAAE,CAAgB;IAC/F,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;IAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;IAChC,IAAI,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,KAAK,OAAO,IAAI,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,KAAK,kBAAkB,CAAC;QAAE,OAAO;IAC3G,MAAM,SAAS,GAAG,CAAC,CAAC,EAAE,IAAI,aAAa,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC;IACzD,IAAI,UAAU,EAAE,CAAC;QAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;QAAC,gBAAgB,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAAC,CAAC;AAChK,CAAC"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { analyzeTree, bump, countComment, countName, firstWord, GENERIC_NAME, grammarFor, testNameStyle, testStringStyle } from "./analyzer.js";
|
|
2
|
+
const FUNCTION_LIKE = new Set(["function_declaration", "generator_function_declaration", "function_expression", "arrow_function", "method_definition"]);
|
|
3
|
+
const NEST = new Set(["if_statement", "switch_statement", "for_statement", "for_in_statement", "while_statement", "do_statement", "try_statement", "arrow_function", "function_expression"]);
|
|
4
|
+
const LITERAL = new Set(["string", "number", "template_string", "true", "false", "null", "array", "object", "regex"]);
|
|
5
|
+
const TYPE_DECLS = new Set(["class_declaration", "abstract_class_declaration", "interface_declaration", "type_alias_declaration", "enum_declaration"]);
|
|
6
|
+
export const analyzeTypeScript = (code, owned, opts = {}) => analyzeTree(code, grammarFor("typescript", opts.path), count, owned, opts);
|
|
7
|
+
const field = (n, name) => n.childForFieldName(name);
|
|
8
|
+
const isBoolean = (type, value) => type?.namedChildren[0]?.text === "boolean" || value?.type === "true" || value?.type === "false";
|
|
9
|
+
/** The statement a declaration sits in: its export wrapper when exported, so docs and scope are read from the right node. */
|
|
10
|
+
const statementOf = (n) => (n.parent?.type === "export_statement" ? n.parent : n);
|
|
11
|
+
const isModuleLevel = (n) => statementOf(n).parent?.type === "program";
|
|
12
|
+
function count(n, s, test) {
|
|
13
|
+
switch (n.type) {
|
|
14
|
+
case "function_declaration":
|
|
15
|
+
case "generator_function_declaration":
|
|
16
|
+
s.typescript.functionDeclarations++;
|
|
17
|
+
return countFunction(n, n, field(n, "name")?.text, s, test);
|
|
18
|
+
case "method_definition": {
|
|
19
|
+
// a constructor is not a name the developer chose
|
|
20
|
+
const fname = field(n, "name")?.text;
|
|
21
|
+
return countFunction(n, n, fname === "constructor" ? undefined : fname, s, test);
|
|
22
|
+
}
|
|
23
|
+
case "arrow_function":
|
|
24
|
+
case "function_expression": {
|
|
25
|
+
// only named ones count as functions: a callback passed to a call is a lambda, like Kotlin's lambda_literal
|
|
26
|
+
const p = n.parent;
|
|
27
|
+
if (p?.type !== "variable_declarator" && p?.type !== "public_field_definition")
|
|
28
|
+
return;
|
|
29
|
+
if (n.type === "arrow_function")
|
|
30
|
+
s.typescript.arrowFunctions++;
|
|
31
|
+
return countFunction(n, p.type === "variable_declarator" ? p.parent : p, field(p, "name")?.text, s, test);
|
|
32
|
+
}
|
|
33
|
+
case "variable_declarator": {
|
|
34
|
+
const decl = n.parent;
|
|
35
|
+
if (!decl || (decl.type !== "lexical_declaration" && decl.type !== "variable_declaration"))
|
|
36
|
+
return;
|
|
37
|
+
const id = field(n, "name"), value = field(n, "value");
|
|
38
|
+
if (id?.type !== "identifier" || (value && FUNCTION_LIKE.has(value.type)))
|
|
39
|
+
return;
|
|
40
|
+
const top = isModuleLevel(decl);
|
|
41
|
+
const kind = !top ? "local" : decl.firstChild?.text === "const" && value && LITERAL.has(value.type) ? "constant" : "property";
|
|
42
|
+
countName(id.text, kind, s);
|
|
43
|
+
if (isBoolean(field(n, "type"), value))
|
|
44
|
+
bump(s.naming.booleanPrefix, firstWord(id.text));
|
|
45
|
+
if (top)
|
|
46
|
+
countDoc(decl, s);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
case "public_field_definition": {
|
|
50
|
+
const id = field(n, "name")?.text, value = field(n, "value");
|
|
51
|
+
if (value && FUNCTION_LIKE.has(value.type))
|
|
52
|
+
return;
|
|
53
|
+
countName(id, "property", s);
|
|
54
|
+
if (id && isBoolean(field(n, "type"), value))
|
|
55
|
+
bump(s.naming.booleanPrefix, firstWord(id));
|
|
56
|
+
return countDoc(n, s);
|
|
57
|
+
}
|
|
58
|
+
case "required_parameter":
|
|
59
|
+
case "optional_parameter":
|
|
60
|
+
case "rest_parameter": {
|
|
61
|
+
const pattern = field(n, "pattern");
|
|
62
|
+
if (pattern?.type === "identifier")
|
|
63
|
+
countName(pattern.text, "parameter", s);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
case "comment": return countComment(n, s);
|
|
67
|
+
case "call_expression": {
|
|
68
|
+
// it("does x", () => ...) is the test function in Vitest, Jest and Mocha, its name is the string
|
|
69
|
+
if (!test)
|
|
70
|
+
return;
|
|
71
|
+
const callee = field(n, "function")?.text;
|
|
72
|
+
const first = field(n, "arguments")?.namedChildren[0];
|
|
73
|
+
if ((callee === "it" || callee === "test") && (first?.type === "string" || first?.type === "template_string")) {
|
|
74
|
+
s.tests.functions++;
|
|
75
|
+
bump(s.naming.testNames, testStringStyle(first.text.slice(1, -1)));
|
|
76
|
+
}
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
case "try_statement":
|
|
80
|
+
s.errors.tryCatch++;
|
|
81
|
+
return;
|
|
82
|
+
case "non_null_expression":
|
|
83
|
+
s.errors.forceUnwrap++;
|
|
84
|
+
return;
|
|
85
|
+
case "optional_chain":
|
|
86
|
+
s.typescript.optionalChains++;
|
|
87
|
+
return;
|
|
88
|
+
case "predefined_type":
|
|
89
|
+
if (n.text === "any")
|
|
90
|
+
s.typescript.anyTypes++;
|
|
91
|
+
return;
|
|
92
|
+
default:
|
|
93
|
+
if (TYPE_DECLS.has(n.type)) {
|
|
94
|
+
if (n.type === "interface_declaration")
|
|
95
|
+
s.typescript.interfaces++;
|
|
96
|
+
if (n.type === "type_alias_declaration")
|
|
97
|
+
s.typescript.typeAliases++;
|
|
98
|
+
countName(field(n, "name")?.text, "class", s);
|
|
99
|
+
countDoc(n, s);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** `anchor` is the node whose lines and doc comment belong to the function: the const declaration for an arrow. */
|
|
104
|
+
function countFunction(n, anchor, fname, s, test) {
|
|
105
|
+
const f = s.functions;
|
|
106
|
+
f.count++;
|
|
107
|
+
if (test) {
|
|
108
|
+
s.tests.functions++;
|
|
109
|
+
if (fname)
|
|
110
|
+
bump(s.naming.testNames, testNameStyle(fname));
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
countName(fname, "function", s);
|
|
114
|
+
if (fname && GENERIC_NAME.test(fname))
|
|
115
|
+
s.naming.genericNames++;
|
|
116
|
+
}
|
|
117
|
+
if (fname && !test)
|
|
118
|
+
bump(s.naming.functionVerb, firstWord(fname));
|
|
119
|
+
countDoc(anchor, s);
|
|
120
|
+
const params = field(n, "parameters")?.namedChildren.length ?? (field(n, "parameter") ? 1 : 0);
|
|
121
|
+
bump(f.params, params);
|
|
122
|
+
if (fname && !test && field(n, "return_type")?.namedChildren[0]?.text === "boolean")
|
|
123
|
+
bump(s.naming.booleanPrefix, firstWord(fname));
|
|
124
|
+
const body = field(n, "body");
|
|
125
|
+
if (!body)
|
|
126
|
+
return;
|
|
127
|
+
if (body.type !== "statement_block") {
|
|
128
|
+
f.expressionBody++;
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
f.blockBody++;
|
|
132
|
+
bump(f.lengthLines, anchor.endPosition.row - anchor.startPosition.row + 1);
|
|
133
|
+
let maxDepth = 0;
|
|
134
|
+
let early = false;
|
|
135
|
+
const walk = (x, depth, inner) => {
|
|
136
|
+
if (x.type === "function_declaration" || x.type === "method_definition")
|
|
137
|
+
return;
|
|
138
|
+
if (x.type === "return_statement" && depth > 0 && !inner)
|
|
139
|
+
early = true;
|
|
140
|
+
const d = NEST.has(x.type) ? depth + 1 : depth;
|
|
141
|
+
maxDepth = Math.max(maxDepth, d);
|
|
142
|
+
for (const c of x.namedChildren)
|
|
143
|
+
if (c)
|
|
144
|
+
walk(c, d, inner || FUNCTION_LIKE.has(x.type));
|
|
145
|
+
};
|
|
146
|
+
walk(body, 0, false);
|
|
147
|
+
bump(f.maxNesting, maxDepth);
|
|
148
|
+
if (early)
|
|
149
|
+
f.earlyReturn++;
|
|
150
|
+
}
|
|
151
|
+
/** Module level: exported is public, the rest is private to the file. Class members: private or protected modifier. */
|
|
152
|
+
function countDoc(n, s) {
|
|
153
|
+
const stmt = statementOf(n);
|
|
154
|
+
const scope = stmt.parent?.type;
|
|
155
|
+
if (scope !== "program" && scope !== "class_body")
|
|
156
|
+
return;
|
|
157
|
+
const isPrivate = scope === "program" ? stmt.type !== "export_statement" : n.namedChildren.some((c) => c?.type === "accessibility_modifier" && c.text !== "public");
|
|
158
|
+
const prev = stmt.previousNamedSibling;
|
|
159
|
+
const documented = prev?.type === "comment" && prev.text.startsWith("/**");
|
|
160
|
+
s.comments[isPrivate ? "privateDecls" : "publicDecls"]++;
|
|
161
|
+
if (documented)
|
|
162
|
+
s.comments[isPrivate ? "privateDocumented" : "publicDocumented"]++;
|
|
163
|
+
}
|
|
164
|
+
//# sourceM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