tackbox 0.1.105__py3-none-android_24_arm64_v8a.whl

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.
Files changed (90) hide show
  1. tackbox/__init__.py +1 -0
  2. tackbox/approvals.py +313 -0
  3. tackbox/bin/ast-grep +4 -0
  4. tackbox/bin/erclint +0 -0
  5. tackbox/bin/erclint-opengrep +0 -0
  6. tackbox/bin/javalint.jar +0 -0
  7. tackbox/bin/tackbox-jscpd +0 -0
  8. tackbox/cache.py +474 -0
  9. tackbox/callable_zones.py +330 -0
  10. tackbox/cli.py +1847 -0
  11. tackbox/codequality.py +124 -0
  12. tackbox/doctor.py +472 -0
  13. tackbox/engines.json +698 -0
  14. tackbox/engines.py +1754 -0
  15. tackbox/escapes.py +402 -0
  16. tackbox/gitfiles.py +145 -0
  17. tackbox/hashing.py +38 -0
  18. tackbox/hookproto.py +302 -0
  19. tackbox/proc.py +61 -0
  20. tackbox/pyrules/__init__.py +13 -0
  21. tackbox/pyrules/checker.py +735 -0
  22. tackbox/pyrules/codes.py +45 -0
  23. tackbox/pyrules/flake8_runner.py +67 -0
  24. tackbox/pyrules/markers.py +76 -0
  25. tackbox/pyrules/origin.py +381 -0
  26. tackbox/pyrules/reporters.py +69 -0
  27. tackbox/pyrules/unused_private.py +274 -0
  28. tackbox/reporters.py +129 -0
  29. tackbox/rules/bin/tackbox-eslint.js +164 -0
  30. tackbox/rules/bin/tackbox-mdlint.js +101 -0
  31. tackbox/rules/eslint.config.preset.js +23 -0
  32. tackbox/rules/js/eslint-plugin.js +68 -0
  33. tackbox/rules/js/markdownlint-rules/declared-chars.js +153 -0
  34. tackbox/rules/js/markdownlint-rules/link-integrity.js +275 -0
  35. tackbox/rules/js/rules/_shared.js +874 -0
  36. tackbox/rules/js/rules/no-broad-notify.js +48 -0
  37. tackbox/rules/js/rules/no-console-error.js +23 -0
  38. tackbox/rules/js/rules/no-focused-test.js +22 -0
  39. tackbox/rules/js/rules/no-parse-fallback.js +149 -0
  40. tackbox/rules/js/rules/no-skipped-test.js +93 -0
  41. tackbox/rules/js/rules/no-swallow-allsettled.js +51 -0
  42. tackbox/rules/js/rules/no-swallow-catch.js +30 -0
  43. tackbox/rules/js/rules/no-swallow-promise-catch.js +37 -0
  44. tackbox/rules/js/rules/no-throw-and-report.js +30 -0
  45. tackbox/rules/js/rules/ts-exit-in-catch.js +26 -0
  46. tackbox/rules/js/rules/ts-rethrow-without-cause.js +62 -0
  47. tackbox/rules/js/rules/ts-useless-catch.js +25 -0
  48. tackbox/rules/js/rules/valid-dedup-key.js +50 -0
  49. tackbox/rules/js/rules/valid-error-report.js +99 -0
  50. tackbox/rules/opengrep/exceptions-go.yaml +15 -0
  51. tackbox/scopes.py +669 -0
  52. tackbox/source_set.py +351 -0
  53. tackbox/third_party/licenses/ast-grep.LICENSE.txt +1 -0
  54. tackbox/third_party/licenses/go/NOTICE.txt +8 -0
  55. tackbox/third_party/licenses/go/github.com_getsentry_sentry-go.LICENSE.txt +21 -0
  56. tackbox/third_party/licenses/go/go.LICENSE.txt +27 -0
  57. tackbox/third_party/licenses/go/golang.org_x_exp_typeparams.LICENSE.txt +27 -0
  58. tackbox/third_party/licenses/go/golang.org_x_mod.LICENSE.txt +27 -0
  59. tackbox/third_party/licenses/go/golang.org_x_sync.LICENSE.txt +27 -0
  60. tackbox/third_party/licenses/go/golang.org_x_sys.LICENSE.txt +27 -0
  61. tackbox/third_party/licenses/go/golang.org_x_text.LICENSE.txt +27 -0
  62. tackbox/third_party/licenses/go/golang.org_x_tools.LICENSE.txt +27 -0
  63. tackbox/third_party/licenses/go/honnef.co_go_tools.LICENSE.txt +20 -0
  64. tackbox/third_party/licenses/go/inventory.json +81 -0
  65. tackbox/third_party/licenses/javalint/NOTICE.txt +14 -0
  66. tackbox/third_party/licenses/javalint/antlr4.LICENSE.txt +52 -0
  67. tackbox/third_party/licenses/javalint/asm.LICENSE.txt +28 -0
  68. tackbox/third_party/licenses/javalint/checker-qual.LICENSE.txt +22 -0
  69. tackbox/third_party/licenses/javalint/commons-lang3.LICENSE.txt +202 -0
  70. tackbox/third_party/licenses/javalint/commons-lang3.NOTICE.txt +5 -0
  71. tackbox/third_party/licenses/javalint/error-prone.LICENSE.txt +202 -0
  72. tackbox/third_party/licenses/javalint/gson.LICENSE.txt +202 -0
  73. tackbox/third_party/licenses/javalint/inventory.json +162 -0
  74. tackbox/third_party/licenses/javalint/javaparser.LICENSE.txt +202 -0
  75. tackbox/third_party/licenses/javalint/javaparser.NOTICE.txt +6 -0
  76. tackbox/third_party/licenses/javalint/nice-xml-messages.LICENSE.txt +22 -0
  77. tackbox/third_party/licenses/javalint/pcollections.LICENSE.txt +24 -0
  78. tackbox/third_party/licenses/javalint/pmd.LICENSE.txt +237 -0
  79. tackbox/third_party/licenses/javalint/pmd.NOTICE.txt +8 -0
  80. tackbox/third_party/licenses/javalint/slf4j.LICENSE.txt +24 -0
  81. tackbox/third_party/licenses/tackbox.LICENSE.txt +21 -0
  82. tackbox-0.1.105.dist-info/METADATA +1064 -0
  83. tackbox-0.1.105.dist-info/RECORD +90 -0
  84. tackbox-0.1.105.dist-info/WHEEL +5 -0
  85. tackbox-0.1.105.dist-info/entry_points.txt +5 -0
  86. tackbox-0.1.105.dist-info/top_level.txt +2 -0
  87. tackbox_report/tackbox_report/__init__.py +417 -0
  88. tackbox_report/tackbox_report/py.typed +0 -0
  89. tackbox_report/tests/conftest.py +69 -0
  90. tackbox_report/tests/test_report.py +236 -0
tackbox/__init__.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = "0.1.105"
tackbox/approvals.py ADDED
@@ -0,0 +1,313 @@
1
+ """The approval manifest: parse, provider seam, and the consistency predicate.
2
+
3
+ `.tackbox/approvals` lists every approved suppression marker as one line - an
4
+ address (D014) plus the exact marker text; multiplicity is repeated lines. The
5
+ invariant is bidirectional and stateless: every marker in the tree must be
6
+ covered by an entry, and every entry must match a live marker (an orphan is an
7
+ error). The check is a pure function of the tree.
8
+
9
+ <repo-relative path>#<scope-chain>: <exact marker text>
10
+ <repo-relative path>: <exact marker text> (file scope)
11
+
12
+ The second form is file scope. Empty lines are ignored; every other line must
13
+ parse (a parse failure is an infra error, as with reporters). Reads go through
14
+ one provider - `load_approvals` - so an external backend is a drop-in.
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ import re
20
+ from collections import Counter
21
+ from dataclasses import dataclass, field
22
+ from pathlib import Path
23
+
24
+ from . import proc, scopes
25
+ from .gitfiles import collect_snapshot
26
+
27
+ FILENAME = ".tackbox/approvals"
28
+
29
+
30
+ class ApprovalsError(Exception):
31
+ """A manifest parse failure (CLI infra error, exit 1/2 as the caller sets)."""
32
+
33
+
34
+ @dataclass(frozen=True)
35
+ class Entry:
36
+ address: str # serialized `path` or `path#chain` (D014)
37
+ marker: str # exact marker text
38
+
39
+ def line_text(self) -> str:
40
+ return f"{self.address}: {self.marker}"
41
+
42
+
43
+ # -- escaping-aware splitting ----------------------------------------------
44
+
45
+
46
+ def _first_unescaped(s: str, ch: str, followed_by: str | None = None) -> int:
47
+ i = 0
48
+ while i < len(s):
49
+ c = s[i]
50
+ if c == "\\":
51
+ i += 2 # a backslash escapes the next character
52
+ continue
53
+ if c == ch and (followed_by is None or s[i + 1: i + 2] == followed_by):
54
+ return i
55
+ i += 1
56
+ return -1
57
+
58
+
59
+ def _unescape(s: str) -> str:
60
+ out: list[str] = []
61
+ i = 0
62
+ while i < len(s):
63
+ if s[i] == "\\" and i + 1 < len(s):
64
+ out.append(s[i + 1])
65
+ i += 2
66
+ else:
67
+ out.append(s[i])
68
+ i += 1
69
+ return "".join(out)
70
+
71
+
72
+ def split_address(address: str) -> tuple[str, str]:
73
+ """(repo-relative path, chain-string). Chain is "" for file scope. The path
74
+ is unescaped; the chain stays serialized (used only for ordering)."""
75
+ hsep = _first_unescaped(address, "#")
76
+ if hsep < 0:
77
+ return _unescape(address), ""
78
+ return _unescape(address[:hsep]), address[hsep + 1:]
79
+
80
+
81
+ # -- parse + provider seam --------------------------------------------------
82
+
83
+
84
+ def parse(text: str) -> list[tuple[Entry, int]]:
85
+ """(entry, 1-based line number) for each non-empty line. Line numbers back
86
+ the orphan report's manifest location."""
87
+ out: list[tuple[Entry, int]] = []
88
+ for lineno, raw in enumerate(text.splitlines(), start=1):
89
+ line = raw.strip()
90
+ if not line:
91
+ continue
92
+ sep = _first_unescaped(line, ":", " ")
93
+ if sep < 0:
94
+ raise ApprovalsError(f"{FILENAME}:{lineno}: expected '<address>: <marker text>'")
95
+ address, marker = line[:sep], line[sep + 2:]
96
+ hsep = _first_unescaped(address, "#")
97
+ path = address if hsep < 0 else address[:hsep]
98
+ chain = "" if hsep < 0 else address[hsep + 1:]
99
+ if not address or not marker or not path or (hsep >= 0 and not chain):
100
+ raise ApprovalsError(f"{FILENAME}:{lineno}: empty path, chain, or marker text")
101
+ out.append((Entry(address, marker), lineno))
102
+ return out
103
+
104
+
105
+ def load_approvals(root: Path) -> Counter[Entry]:
106
+ """Load approved occurrence counts from the committed manifest format."""
107
+ path = root / FILENAME
108
+ if not path.is_file():
109
+ return Counter()
110
+ return Counter(entry for entry, _ln in parse(path.read_text(encoding="utf-8")))
111
+
112
+
113
+ # -- the consistency predicate ---------------------------------------------
114
+
115
+
116
+ @dataclass(frozen=True)
117
+ class Uncovered:
118
+ entry: Entry
119
+ file: str # repo-relative path of the marker
120
+ line: int
121
+
122
+
123
+ @dataclass(frozen=True)
124
+ class Orphan:
125
+ entry: Entry
126
+ line: int # 1-based line in the manifest
127
+
128
+
129
+ @dataclass
130
+ class Report:
131
+ uncovered: list[Uncovered] = field(default_factory=list)
132
+ orphans: list[Orphan] = field(default_factory=list)
133
+ unresolvable: list[str] = field(default_factory=list)
134
+
135
+ def ok(self) -> bool:
136
+ return not (self.uncovered or self.orphans or self.unresolvable)
137
+
138
+ def draft_lines(self) -> list[str]:
139
+ """One entry line per uncovered occurrence, deterministic order."""
140
+ return [u.entry.line_text() for u in self.uncovered]
141
+
142
+
143
+ _UNRESOLVABLE = "syntax does not parse; fix the syntax before verifying markers and approvals"
144
+ HEADER = "approvals (whole tree):"
145
+
146
+
147
+ def render_blocks(report: Report, findings=()) -> list[str]:
148
+ """Render one actionable line per inconsistency, without approval entries."""
149
+ suppressed: dict[tuple[str, int, str], set[str]] = {}
150
+ for finding in findings:
151
+ if not finding.suppressed or not finding.message:
152
+ continue
153
+ text = " ".join(finding.message.split())
154
+ if not re.match(r"^(?:ERC|JV|TBX)\d+: ", text):
155
+ text = f"{finding.rule}: {text}"
156
+ key = (finding.file, finding.marker_line, finding.marker_kind)
157
+ suppressed.setdefault(key, set()).add(text)
158
+ lines = []
159
+ for uncovered in report.uncovered:
160
+ kind = uncovered.entry.marker.split(":", 1)[0]
161
+ messages = suppressed.get((uncovered.file, uncovered.line, kind))
162
+ location = f"{uncovered.file}:{uncovered.line}: "
163
+ if messages:
164
+ lines.append(
165
+ location + "; ".join(sorted(messages))
166
+ + f"; suppressed by an unapproved {kind} marker: fix the code, "
167
+ + f"or the owner approves the marker in {FILENAME}"
168
+ )
169
+ else:
170
+ lines.append(
171
+ location + f"unapproved {kind} marker suppresses nothing here: remove it, "
172
+ + f"or the owner approves it in {FILENAME}"
173
+ )
174
+ lines.extend(f"{FILENAME}:{orphan.line}: approval has no matching marker: remove the line"
175
+ for orphan in report.orphans)
176
+ lines.extend(f"{path}: {_UNRESOLVABLE}" for path in report.unresolvable)
177
+ return lines
178
+
179
+
180
+ def _sort_key_entry(entry: Entry) -> tuple[str, str, str]:
181
+ path, chain = split_address(entry.address)
182
+ return path, chain, entry.marker
183
+
184
+
185
+ def check(
186
+ root: Path, files: list[str], marker_re: re.Pattern[str], is_lintable,
187
+ only_paths: set[str] | None = None,
188
+ added_lines: dict[str, set[int] | None] | None = None,
189
+ ) -> Report:
190
+ """Check tree consistency, or prioritize unchanged lines in a hook subset."""
191
+ parsed = parse((root / FILENAME).read_text(encoding="utf-8")) if (root / FILENAME).is_file() else []
192
+ if only_paths is not None:
193
+ parsed = [(entry, line) for entry, line in parsed
194
+ if split_address(entry.address)[0] in only_paths]
195
+
196
+ manifest_paths = {split_address(e.address)[0] for e, _ln in parsed}
197
+ candidates = {
198
+ f for f in files
199
+ if is_lintable(f) and scopes.has_marker_text(root, f, marker_re)
200
+ }
201
+ candidates |= {f for f in files if is_lintable(f) and f in manifest_paths}
202
+
203
+ occ_by_entry: dict[Entry, list[Uncovered]] = {}
204
+ unresolvable: set[str] = set()
205
+ for f in candidates:
206
+ res = scopes.resolve_file(root, f, marker_re)
207
+ if res.unresolvable:
208
+ unresolvable.add(f)
209
+ continue
210
+ for rm in res.markers:
211
+ e = Entry(rm.address, rm.marker)
212
+ occ_by_entry.setdefault(e, []).append(Uncovered(e, f, rm.line))
213
+
214
+ ent_by_entry: dict[Entry, list[int]] = {}
215
+ for e, lineno in parsed:
216
+ ent_by_entry.setdefault(e, []).append(lineno)
217
+
218
+ def line_key(path: str, line: int) -> tuple[bool, int]:
219
+ lines = added_lines.get(path, ()) if added_lines is not None else ()
220
+ return lines is None or line in lines, line
221
+
222
+ report = Report(unresolvable=sorted(unresolvable))
223
+ for entry in set(occ_by_entry) | set(ent_by_entry):
224
+ if split_address(entry.address)[0] in unresolvable:
225
+ continue # reported as unresolvable, not as orphan/uncovered
226
+ occ = sorted(occ_by_entry.get(entry, []), key=lambda u: line_key(u.file, u.line))
227
+ ent = sorted(ent_by_entry.get(entry, []), key=lambda line: line_key(FILENAME, line))
228
+ covered = min(len(occ), len(ent))
229
+ report.uncovered.extend(occ[covered:])
230
+ report.orphans.extend(Orphan(entry, ln) for ln in ent[covered:])
231
+
232
+ report.uncovered.sort(key=lambda u: (*_sort_key_entry(u.entry), u.line))
233
+ report.orphans.sort(key=lambda o: (*_sort_key_entry(o.entry), o.line))
234
+ return report
235
+
236
+
237
+ _HUNK_RE = re.compile(r"^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@")
238
+
239
+
240
+ def _git(root: Path, *args: str) -> bytes:
241
+ return proc.run_bytes(["git", *args], cwd=root, capture_output=True, check=True).stdout
242
+
243
+
244
+ def session_report(root: Path, marker_re: re.Pattern[str], is_lintable) -> Report:
245
+ """Return approvals debt introduced by the worktree's difference from HEAD."""
246
+ head = proc.run_bytes(
247
+ ["git", "rev-parse", "--verify", "--quiet", "HEAD"],
248
+ cwd=root, capture_output=True,
249
+ )
250
+ if head.returncode not in (0, 1):
251
+ head.check_returncode()
252
+ if head.returncode == 1:
253
+ snapshot = collect_snapshot(root)
254
+ return check(root, snapshot.included, marker_re, is_lintable)
255
+ changed = set(_git(root, "diff", "--name-only", "--no-renames", "-z", "HEAD", "--")
256
+ .decode("utf-8").split("\0")) - {""}
257
+ untracked = set(_git(root, "ls-files", "--others", "--exclude-standard", "-z")
258
+ .decode("utf-8").split("\0")) - {""}
259
+ changed |= untracked
260
+ if not changed:
261
+ return Report()
262
+ added: dict[str, set[int] | None] = {path: None for path in untracked}
263
+ removed: dict[str, set[int]] = {}
264
+ for path in sorted(changed - untracked):
265
+ patch = _git(root, "diff", "--no-ext-diff", "--no-textconv", "--no-renames",
266
+ "--unified=0", "HEAD", "--", f":(literal){path}").decode("utf-8", errors="replace")
267
+ added[path] = set()
268
+ old_lines: set[int] = set()
269
+ for line in patch.splitlines():
270
+ match = _HUNK_RE.match(line)
271
+ if match:
272
+ old_start, old_count, new_start, new_count = match.groups()
273
+ old_lines.update(range(int(old_start), int(old_start) + int(old_count or 1)))
274
+ added[path].update(range(int(new_start), int(new_start) + int(new_count or 1)))
275
+ if old_lines and any(marker_re.search(line[1:]) for line in patch.splitlines()
276
+ if line.startswith("-") and not line.startswith("---")):
277
+ removed[path] = old_lines
278
+
279
+ manifest = root / FILENAME
280
+ parsed = parse(manifest.read_text(encoding="utf-8")) if manifest.is_file() else []
281
+ manifest_added = added.get(FILENAME, set())
282
+ new_entries = [(entry, line) for entry, line in parsed
283
+ if manifest_added is None or line in manifest_added]
284
+ paths = changed | {split_address(entry.address)[0] for entry, _ in new_entries}
285
+ snapshot = collect_snapshot(root, changed_scope=paths)
286
+ current = check(
287
+ root, snapshot.included, marker_re, is_lintable,
288
+ only_paths=paths, added_lines=added,
289
+ )
290
+ debt = Report(
291
+ uncovered=[u for u in current.uncovered
292
+ if u.file in added and (added[u.file] is None or u.line in added[u.file])],
293
+ unresolvable=current.unresolvable,
294
+ )
295
+ deleted: Counter[Entry] = Counter()
296
+ orphan_paths = {split_address(orphan.entry.address)[0] for orphan in current.orphans}
297
+ for path in sorted(orphan_paths & removed.keys()):
298
+ if not is_lintable(path):
299
+ continue
300
+ baseline = scopes.resolve_content(path, _git(root, "show", f"HEAD:{path}"), marker_re)
301
+ if baseline.unresolvable:
302
+ debt.unresolvable.append(path)
303
+ continue
304
+ deleted.update(Entry(marker.address, marker.marker) for marker in baseline.markers
305
+ if marker.line in removed[path])
306
+ for orphan in current.orphans:
307
+ if manifest_added is None or orphan.line in manifest_added:
308
+ debt.orphans.append(orphan)
309
+ elif deleted[orphan.entry]:
310
+ debt.orphans.append(orphan)
311
+ deleted[orphan.entry] -= 1
312
+ debt.unresolvable = sorted(set(debt.unresolvable))
313
+ return debt
tackbox/bin/ast-grep ADDED
@@ -0,0 +1,4 @@
1
+ [diffend] Oversized file quarantined before diffing.
2
+ name: tackbox/bin/ast-grep
3
+ size: 51749960 bytes
4
+ sha256: 723c28184fc8f1e1b75007ccbdcb41e482f6adc270a05cdc7581fcfe87c84911
tackbox/bin/erclint ADDED
Binary file
Binary file
Binary file
Binary file