@voidh4x0r/slopgate 0.1.4 → 0.1.5
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/CHANGELOG.md +13 -0
- package/README.md +4 -4
- package/dist/rules/python.js +3 -3
- package/dist/rules/typescript.js +81 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,19 @@ All notable changes to this project are documented here. The format follows [Kee
|
|
|
9
9
|
- Go and Rust grammars.
|
|
10
10
|
- VS Code diagnostics.
|
|
11
11
|
|
|
12
|
+
## [0.1.5] - 2026-11-22
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
- `ts/noop-test` reports a single test-callback parameter passed to a helper (`(t) => runSuite(t)`) as medium (“assertions may be delegated”) instead of high. Multi-parameter table-driven callbacks are not treated as delegation.
|
|
16
|
+
- `ts/unreachable` skips erased `type`, `interface` and `declare` declarations after a terminator; `enum`, classes, `let`/`const` and initialised `var` still report.
|
|
17
|
+
- `py/swallowed-exception` no longer treats `cleanup`/`refactor`/`next sprint` as blanket noise; only TODO/FIXME/XXX/HACK tags are noise. Comments on the `except` line now count, and inline comments no longer pollute the exception type, so broad handlers keep the “comment explains why” message.
|
|
18
|
+
- `ts/stub-function` reports object-literal arrow properties that throw “Not implemented” at medium confidence, matching class methods.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- 241 tests, including fifth-round regression fixtures for `delegated-assert`, `ts-type-after-return`, `cleanup-word`, `comment-placement` and the conservative `wording` cases.
|
|
22
|
+
- Benchmark unchanged at **29 high-confidence findings across 991,705 lines of CPython, 96.6% labeled precision (28/29), 14/14 seeded defects, 0 high findings on 601 JavaScript files**; `staleLabels: []`, `unlabeledHigh: []`.
|
|
23
|
+
- Docs record the accepted above-`try` wording conservatism (a bare “known bug” stays high by design).
|
|
24
|
+
|
|
12
25
|
## [0.1.4] - 2026-11-22
|
|
13
26
|
|
|
14
27
|
### Fixed
|
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ AI writes code that *looks* right. `slopgate` finds the parts that only look rig
|
|
|
14
14
|
```console
|
|
15
15
|
$ npx @voidh4x0r/slopgate .
|
|
16
16
|
|
|
17
|
-
slopgate 0.1.
|
|
17
|
+
slopgate 0.1.5 · 4 files · 39ms
|
|
18
18
|
|
|
19
19
|
app.py
|
|
20
20
|
4:1 error high py/phantom-import `helper` is imported but not declared in any manifest and not present in this repository
|
|
@@ -204,7 +204,7 @@ jobs:
|
|
|
204
204
|
- uses: actions/checkout@v4
|
|
205
205
|
- uses: actions/setup-node@v4
|
|
206
206
|
with: { node-version: 22 }
|
|
207
|
-
- run: npx --yes @voidh4x0r/slopgate@0.1.
|
|
207
|
+
- run: npx --yes @voidh4x0r/slopgate@0.1.5 . --fail-on high
|
|
208
208
|
```
|
|
209
209
|
|
|
210
210
|
For GitHub code scanning, use `--format sarif` and upload with `github/codeql-action/upload-sarif`.
|
|
@@ -212,7 +212,7 @@ For GitHub code scanning, use `--format sarif` and upload with `github/codeql-ac
|
|
|
212
212
|
For inline pull-request annotations **without** code scanning, use `--format github`, which emits [workflow commands](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions):
|
|
213
213
|
|
|
214
214
|
```yaml
|
|
215
|
-
- run: npx --yes @voidh4x0r/slopgate@0.1.
|
|
215
|
+
- run: npx --yes @voidh4x0r/slopgate@0.1.5 . --format github --fail-on high
|
|
216
216
|
```
|
|
217
217
|
|
|
218
218
|
Each finding becomes an `error` / `warning` / `notice` annotation on the exact line, followed by a summary notice.
|
|
@@ -297,7 +297,7 @@ Issues and pull requests are welcome. Start with [CONTRIBUTING.md](https://githu
|
|
|
297
297
|
git clone https://github.com/VoidH4x0r/slopgate
|
|
298
298
|
cd slopgate
|
|
299
299
|
npm install
|
|
300
|
-
npm test #
|
|
300
|
+
npm test # 241 tests; the tests themselves make no network or child-process calls
|
|
301
301
|
npm run typecheck
|
|
302
302
|
npm run verify # all release gates in one command
|
|
303
303
|
```
|
package/dist/rules/python.js
CHANGED
|
@@ -457,7 +457,7 @@ const FAILURE_WORDS = /error|fail|throw|exception|invalid|log|raise/i;
|
|
|
457
457
|
const INTENT_WORDS = /ignor\w*|abort|skip|safe|accept|fallback|best effort|tolerate|\bok\b|fine/i;
|
|
458
458
|
const STRONG_EXPLANATION = /harmless|benign|intentional|by design|safe to ignore|expected (?:error|failure|exception|behaviou?r)/i;
|
|
459
459
|
/** Comments that describe future work, not why an error is safe to ignore. */
|
|
460
|
-
const NOISE_COMMENT =
|
|
460
|
+
const NOISE_COMMENT = /\b(TODO|FIXME|XXX|HACK)\b/i;
|
|
461
461
|
function isExplanationText(text) {
|
|
462
462
|
return STRONG_EXPLANATION.test(text) || (FAILURE_WORDS.test(text) && INTENT_WORDS.test(text));
|
|
463
463
|
}
|
|
@@ -547,7 +547,7 @@ const swallowedException = {
|
|
|
547
547
|
if (!silent)
|
|
548
548
|
continue;
|
|
549
549
|
const typeText = clause.namedChildren
|
|
550
|
-
.filter((child) => child.type !== 'block')
|
|
550
|
+
.filter((child) => child.type !== 'block' && !isComment(child))
|
|
551
551
|
.map((child) => collapseWhitespace(child.text))
|
|
552
552
|
.join(' ')
|
|
553
553
|
.trim();
|
|
@@ -555,7 +555,7 @@ const swallowedException = {
|
|
|
555
555
|
if (/ImportError|ModuleNotFoundError/.test(typeText))
|
|
556
556
|
continue;
|
|
557
557
|
const commented = above ||
|
|
558
|
-
supportingCommentBetween(ctx, betweenStart, handlerEndRow + 1,
|
|
558
|
+
supportingCommentBetween(ctx, betweenStart, handlerEndRow + 1, clause.startPosition.row + 1);
|
|
559
559
|
const bare = typeText.length === 0;
|
|
560
560
|
const broad = bare || /^(\(?\s*)?(Exception|BaseException)(\s*\))?$/.test(typeText);
|
|
561
561
|
const cleanup = insideCleanupFunction(clause);
|
package/dist/rules/typescript.js
CHANGED
|
@@ -200,6 +200,53 @@ function hasAssertion(body, aliases) {
|
|
|
200
200
|
});
|
|
201
201
|
return found;
|
|
202
202
|
}
|
|
203
|
+
function parameterName(node) {
|
|
204
|
+
if (!node)
|
|
205
|
+
return undefined;
|
|
206
|
+
if (node.type === 'identifier')
|
|
207
|
+
return node.text;
|
|
208
|
+
const pattern = node.childForFieldName('pattern');
|
|
209
|
+
if (pattern)
|
|
210
|
+
return parameterName(pattern);
|
|
211
|
+
const first = node.namedChildren.find((child) => child.type === 'identifier');
|
|
212
|
+
return first?.text;
|
|
213
|
+
}
|
|
214
|
+
function firstParameterName(callback) {
|
|
215
|
+
const params = callback.childForFieldName('parameters');
|
|
216
|
+
if (!params)
|
|
217
|
+
return undefined;
|
|
218
|
+
if (params.type === 'identifier')
|
|
219
|
+
return params.text;
|
|
220
|
+
// A callback with several parameters is usually a table-driven test
|
|
221
|
+
// (`(a, b) => add(a, b)`), not a framework context being delegated.
|
|
222
|
+
if (params.namedChildren.length !== 1)
|
|
223
|
+
return undefined;
|
|
224
|
+
return parameterName(params.namedChildren[0]);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Tape/TAP often delegates assertions to a local helper that receives `t`:
|
|
228
|
+
* `test('x', (t) => { runSuite(t); t.end(); })`. The helper may assert, so
|
|
229
|
+
* this is a medium-confidence "cannot verify" rather than a guaranteed no-op.
|
|
230
|
+
*/
|
|
231
|
+
function delegatedHelper(body, callback) {
|
|
232
|
+
const param = firstParameterName(callback);
|
|
233
|
+
if (!param)
|
|
234
|
+
return undefined;
|
|
235
|
+
let helper;
|
|
236
|
+
walk(body, (node) => {
|
|
237
|
+
if (helper)
|
|
238
|
+
return false;
|
|
239
|
+
if (node.type !== 'call_expression')
|
|
240
|
+
return true;
|
|
241
|
+
const args = node.childForFieldName('arguments');
|
|
242
|
+
if (!args?.namedChildren.some((arg) => arg.type === 'identifier' && arg.text === param)) {
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
helper = collapseWhitespace(node.childForFieldName('function')?.text ?? '') || 'a helper';
|
|
246
|
+
return false;
|
|
247
|
+
});
|
|
248
|
+
return helper;
|
|
249
|
+
}
|
|
203
250
|
const phantomImport = {
|
|
204
251
|
meta: {
|
|
205
252
|
id: 'ts/phantom-import',
|
|
@@ -325,14 +372,21 @@ const noopTest = {
|
|
|
325
372
|
if (!body)
|
|
326
373
|
continue;
|
|
327
374
|
const label = args.namedChildren[0]?.type === 'string' ? truncate(args.namedChildren[0].text, 60) : undefined;
|
|
375
|
+
const delegated = delegatedHelper(body, callback);
|
|
328
376
|
if (body.type !== 'statement_block') {
|
|
329
377
|
if (!hasAssertion(body, aliases)) {
|
|
330
378
|
drafts.push({
|
|
331
|
-
message: 'test makes no assertions',
|
|
379
|
+
message: delegated ? 'test delegates its assertions to a helper' : 'test makes no assertions',
|
|
332
380
|
start: startOf(call),
|
|
333
381
|
end: endOf(body),
|
|
334
382
|
snippet: snippetOf(ctx, call),
|
|
335
|
-
|
|
383
|
+
confidence: delegated ? 'medium' : 'high',
|
|
384
|
+
evidence: [
|
|
385
|
+
`test: ${label ?? '(anonymous)'}`,
|
|
386
|
+
...(delegated
|
|
387
|
+
? [`first parameter is passed to \`${delegated}\`; the helper may assert`]
|
|
388
|
+
: ['the test body only calls code without checking a result']),
|
|
389
|
+
],
|
|
336
390
|
help: 'Every test should be able to fail. Add an assertion that depends on the behaviour under test.',
|
|
337
391
|
});
|
|
338
392
|
}
|
|
@@ -352,11 +406,18 @@ const noopTest = {
|
|
|
352
406
|
}
|
|
353
407
|
if (!hasAssertion(body, aliases)) {
|
|
354
408
|
drafts.push({
|
|
355
|
-
message: 'test makes no assertions',
|
|
409
|
+
message: delegated ? 'test delegates its assertions to a helper' : 'test makes no assertions',
|
|
356
410
|
start: startOf(call),
|
|
357
411
|
end: endOf(body),
|
|
358
412
|
snippet: snippetOf(ctx, call),
|
|
359
|
-
|
|
413
|
+
confidence: delegated ? 'medium' : 'high',
|
|
414
|
+
evidence: [
|
|
415
|
+
`test: ${label ?? '(anonymous)'}`,
|
|
416
|
+
`statements: ${statements.length}`,
|
|
417
|
+
...(delegated
|
|
418
|
+
? [`first parameter is passed to \`${delegated}\`; the helper may assert`]
|
|
419
|
+
: ['no expect() / assert() found']),
|
|
420
|
+
],
|
|
360
421
|
help: 'Every test should be able to fail. Add an assertion that depends on the behaviour under test.',
|
|
361
422
|
});
|
|
362
423
|
}
|
|
@@ -500,7 +561,11 @@ const stubFunction = {
|
|
|
500
561
|
start: startOf(node),
|
|
501
562
|
end: endOf(body),
|
|
502
563
|
snippet: snippetOf(ctx, node),
|
|
503
|
-
|
|
564
|
+
confidence: node.parent?.type === 'pair' ? 'medium' : 'high',
|
|
565
|
+
evidence: [
|
|
566
|
+
'body: throws "not implemented"',
|
|
567
|
+
...(node.parent?.type === 'pair' ? ['object-literal property: interface stubs often throw here'] : []),
|
|
568
|
+
],
|
|
504
569
|
help: 'Implement it, or throw an error with a message so callers fail loudly.',
|
|
505
570
|
});
|
|
506
571
|
}
|
|
@@ -599,11 +664,17 @@ const deadBranch = {
|
|
|
599
664
|
};
|
|
600
665
|
/**
|
|
601
666
|
* Function declarations and bare `var` statements are hoisted: they are usable
|
|
602
|
-
* before a `return` even when written after it.
|
|
603
|
-
* `
|
|
667
|
+
* before a `return` even when written after it. Type aliases, interfaces and
|
|
668
|
+
* `declare` statements are erased at compile time, so they have no runtime
|
|
669
|
+
* position either. `let`/`const`, enums, classes and initialised `var`
|
|
670
|
+
* statements execute at their position and remain genuinely dead.
|
|
604
671
|
*/
|
|
605
|
-
function
|
|
606
|
-
if (statement.type === 'function_declaration' ||
|
|
672
|
+
function isErasedOrHoisted(statement) {
|
|
673
|
+
if (statement.type === 'function_declaration' ||
|
|
674
|
+
statement.type === 'generator_function_declaration' ||
|
|
675
|
+
statement.type === 'type_alias_declaration' ||
|
|
676
|
+
statement.type === 'interface_declaration' ||
|
|
677
|
+
statement.type === 'ambient_declaration') {
|
|
607
678
|
return true;
|
|
608
679
|
}
|
|
609
680
|
if (statement.type !== 'variable_declaration')
|
|
@@ -635,7 +706,7 @@ const unreachable = {
|
|
|
635
706
|
const terminator = statements[index];
|
|
636
707
|
if (!terminator)
|
|
637
708
|
continue;
|
|
638
|
-
const firstUnreachable = statements.slice(index + 1).find((statement) => !
|
|
709
|
+
const firstUnreachable = statements.slice(index + 1).find((statement) => !isErasedOrHoisted(statement));
|
|
639
710
|
if (!firstUnreachable)
|
|
640
711
|
continue;
|
|
641
712
|
const count = statements.length - index - 1;
|