@herbertgao/pi-extensions 2026.8.13 → 2026.8.15
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/README.md +19 -14
- package/THIRD_PARTY_NOTICES.md +0 -1
- package/node_modules/@czottmann/pi-automode/CHANGELOG.md +19 -0
- package/node_modules/@czottmann/pi-automode/README.md +5 -1
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/classifier.ts +126 -13
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/config.ts +7 -3
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/constants.ts +2 -0
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/hard-deny.ts +134 -23
- package/node_modules/@czottmann/pi-automode/package.json +1 -1
- package/node_modules/@herbertgao/{pi-stash → pi-bark}/LICENSE +4 -5
- package/node_modules/@herbertgao/pi-bark/README.md +44 -0
- package/node_modules/@herbertgao/pi-bark/assets/pi-icon.png +0 -0
- package/node_modules/@herbertgao/pi-bark/package.json +53 -0
- package/node_modules/@herbertgao/pi-bark/src/index.ts +178 -0
- package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +1 -1
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +1 -1
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +3 -3
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
- package/node_modules/@herbertgao/pi-subagents/package.json +2 -1
- package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +8 -1
- package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +2 -2
- package/node_modules/@narumitw/pi-btw/README.md +125 -88
- package/node_modules/@narumitw/pi-btw/dist/index.ts +140 -45
- package/node_modules/@narumitw/pi-btw/dist/index.ts.map +2 -2
- package/node_modules/@narumitw/pi-btw/package.json +5 -8
- package/node_modules/@narumitw/pi-btw/src/btw.ts +31 -26
- package/node_modules/@narumitw/pi-btw/src/fullscreen-ui.ts +106 -17
- package/node_modules/@narumitw/pi-btw/src/menu.ts +34 -2
- package/node_modules/@narumitw/pi-btw/src/settings.ts +16 -0
- package/node_modules/@tifan/pi-handoff/README.md +36 -13
- package/node_modules/@tifan/pi-handoff/package.json +2 -2
- package/node_modules/@tifan/pi-handoff/src/index.ts +160 -4
- package/node_modules/@tifan/pi-preferred-thinking/README.md +1 -1
- package/node_modules/@tifan/pi-preferred-thinking/package.json +1 -1
- package/node_modules/@tifan/pi-preferred-thinking/src/index.ts +15 -2
- package/node_modules/@tifan/pi-recap/README.md +1 -1
- package/node_modules/@tifan/pi-recap/package.json +2 -2
- package/node_modules/@tifan/pi-recap/src/index.ts +15 -0
- package/node_modules/@tifan/pi-rename/README.md +42 -21
- package/node_modules/@tifan/pi-rename/package.json +1 -1
- package/node_modules/@tifan/pi-rename/src/index.ts +62 -11
- package/node_modules/@tifan/pi-rename/src/language.ts +18 -0
- package/node_modules/@tifan/pi-rename/src/models.ts +69 -13
- package/node_modules/@tifan/pi-rename/src/naming.ts +36 -7
- package/node_modules/@tifan/pi-rename/src/sanitize.ts +22 -14
- package/node_modules/pi-lens/CHANGELOG.md +320 -0
- package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +79 -0
- package/node_modules/pi-lens/dist/clients/actionable-warnings-logger.js +16 -1
- package/node_modules/pi-lens/dist/clients/ast-grep-client.js +13 -6
- package/node_modules/pi-lens/dist/clients/availability-probe-flight.js +12 -0
- package/node_modules/pi-lens/dist/clients/biome-client.js +7 -0
- package/node_modules/pi-lens/dist/clients/blocker-freshness.js +20 -0
- package/node_modules/pi-lens/dist/clients/bounded-telemetry.js +56 -19
- package/node_modules/pi-lens/dist/clients/build-identity.js +95 -0
- package/node_modules/pi-lens/dist/clients/bus-publish.js +3 -0
- package/node_modules/pi-lens/dist/clients/cache/rule-cache.js +2 -1
- package/node_modules/pi-lens/dist/clients/cache-observability.js +2 -1
- package/node_modules/pi-lens/dist/clients/cascade-logger.js +15 -1
- package/node_modules/pi-lens/dist/clients/dead-code-client.js +14 -11
- package/node_modules/pi-lens/dist/clients/degradation-ledger.js +56 -4
- package/node_modules/pi-lens/dist/clients/demoted-finding-render.js +14 -0
- package/node_modules/pi-lens/dist/clients/dependency-checker.js +20 -3
- package/node_modules/pi-lens/dist/clients/deps/minimatch.js +1 -1
- package/node_modules/pi-lens/dist/clients/dispatch/collect-later-tier.js +39 -0
- package/node_modules/pi-lens/dist/clients/dispatch/dispatcher.js +150 -9
- package/node_modules/pi-lens/dist/clients/dispatch/fact-store.js +231 -9
- package/node_modules/pi-lens/dist/clients/dispatch/integration.js +205 -100
- package/node_modules/pi-lens/dist/clients/dispatch/pending-runner-findings.js +87 -0
- package/node_modules/pi-lens/dist/clients/dispatch/plan.js +21 -5
- package/node_modules/pi-lens/dist/clients/dispatch/runners/ast-grep-napi.js +174 -55
- package/node_modules/pi-lens/dist/clients/dispatch/runners/eslint.js +5 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/helm-lint.js +16 -3
- package/node_modules/pi-lens/dist/clients/dispatch/runners/helm-render.js +54 -9
- package/node_modules/pi-lens/dist/clients/dispatch/runners/index.js +1 -3
- package/node_modules/pi-lens/dist/clients/dispatch/runners/lsp.js +37 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/markdownlint.js +4 -1
- package/node_modules/pi-lens/dist/clients/dispatch/runners/oxlint.js +11 -4
- package/node_modules/pi-lens/dist/clients/dispatch/runners/psscriptanalyzer.js +4 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/rust-clippy.js +8 -3
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/runner-helpers.js +76 -25
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/spawn-outcome.js +4 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/tool-failure.js +19 -7
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/toolchain-availability.js +7 -13
- package/node_modules/pi-lens/dist/clients/dispatch/runners/yaml-rule-parser.js +51 -17
- package/node_modules/pi-lens/dist/clients/event-loop-monitor.js +66 -1
- package/node_modules/pi-lens/dist/clients/file-utils.js +157 -7
- package/node_modules/pi-lens/dist/clients/finding-delivery-gate.js +5 -0
- package/node_modules/pi-lens/dist/clients/formatters.js +28 -3
- package/node_modules/pi-lens/dist/clients/git-guard.js +197 -47
- package/node_modules/pi-lens/dist/clients/git-tracked-ignore.js +32 -1
- package/node_modules/pi-lens/dist/clients/govulncheck-client.js +5 -1
- package/node_modules/pi-lens/dist/clients/gzip-stage-write.js +7 -0
- package/node_modules/pi-lens/dist/clients/installer/index.js +131 -34
- package/node_modules/pi-lens/dist/clients/installer/managed-tool-refresh.js +3 -1
- package/node_modules/pi-lens/dist/clients/instance-reaper.js +4 -13
- package/node_modules/pi-lens/dist/clients/instance-registry-lock.js +145 -0
- package/node_modules/pi-lens/dist/clients/instance-registry.js +432 -122
- package/node_modules/pi-lens/dist/clients/jscpd-client.js +6 -1
- package/node_modules/pi-lens/dist/clients/language-profile.js +4 -2
- package/node_modules/pi-lens/dist/clients/latency-logger.js +19 -1
- package/node_modules/pi-lens/dist/clients/lens-flag-registry.js +8 -0
- package/node_modules/pi-lens/dist/clients/lens-map.js +3 -1
- package/node_modules/pi-lens/dist/clients/lsp/cascade-tier.js +4 -0
- package/node_modules/pi-lens/dist/clients/lsp/client.js +516 -31
- package/node_modules/pi-lens/dist/clients/lsp/config.js +25 -2
- package/node_modules/pi-lens/dist/clients/lsp/diagnostic-binding.js +9 -4
- package/node_modules/pi-lens/dist/clients/lsp/index.js +509 -182
- package/node_modules/pi-lens/dist/clients/lsp/jvm-runtime.js +5 -0
- package/node_modules/pi-lens/dist/clients/lsp/launch.js +36 -8
- package/node_modules/pi-lens/dist/clients/lsp/pending-aux-coverage.js +116 -4
- package/node_modules/pi-lens/dist/clients/lsp/server.js +142 -13
- package/node_modules/pi-lens/dist/clients/lsp/session-roots.js +99 -0
- package/node_modules/pi-lens/dist/clients/lsp/workspace-diagnostics-cache.js +16 -6
- package/node_modules/pi-lens/dist/clients/lsp/workspace-sweep-hold.js +32 -23
- package/node_modules/pi-lens/dist/clients/lsp-mutation.js +16 -2
- package/node_modules/pi-lens/dist/clients/mcp/analyze.js +12 -6
- package/node_modules/pi-lens/dist/clients/mcp/session.js +14 -1
- package/node_modules/pi-lens/dist/clients/memory-sampler.js +23 -1
- package/node_modules/pi-lens/dist/clients/message-end-attribution.js +30 -0
- package/node_modules/pi-lens/dist/clients/metrics-history.js +21 -4
- package/node_modules/pi-lens/dist/clients/opaque-mutation-scan.js +232 -18
- package/node_modules/pi-lens/dist/clients/package-manager.js +6 -18
- package/node_modules/pi-lens/dist/clients/path-keyed-map.js +14 -1
- package/node_modules/pi-lens/dist/clients/path-utils.js +32 -0
- package/node_modules/pi-lens/dist/clients/pipeline.js +0 -8
- package/node_modules/pi-lens/dist/clients/process-singletons.js +210 -0
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/madge.js +2 -1
- package/node_modules/pi-lens/dist/clients/project-diagnostics/scanner.js +10 -4
- package/node_modules/pi-lens/dist/clients/project-snapshot.js +33 -11
- package/node_modules/pi-lens/dist/clients/read-guard-logger.js +24 -2
- package/node_modules/pi-lens/dist/clients/read-guard.js +74 -7
- package/node_modules/pi-lens/dist/clients/recent-touches.js +17 -5
- package/node_modules/pi-lens/dist/clients/review-graph/builder.js +639 -62
- package/node_modules/pi-lens/dist/clients/review-graph/tsconfig-paths.js +5 -1
- package/node_modules/pi-lens/dist/clients/review-graph-logger.js +21 -1
- package/node_modules/pi-lens/dist/clients/runtime-coordinator.js +68 -0
- package/node_modules/pi-lens/dist/clients/runtime-session.js +30 -12
- package/node_modules/pi-lens/dist/clients/runtime-tool-call.js +15 -0
- package/node_modules/pi-lens/dist/clients/runtime-tool-result.js +106 -7
- package/node_modules/pi-lens/dist/clients/runtime-turn.js +242 -27
- package/node_modules/pi-lens/dist/clients/safe-spawn.js +158 -18
- package/node_modules/pi-lens/dist/clients/security-scan-client.js +48 -17
- package/node_modules/pi-lens/dist/clients/session-lifecycle.js +238 -42
- package/node_modules/pi-lens/dist/clients/sg-runner.js +27 -15
- package/node_modules/pi-lens/dist/clients/shared-checkout-guard.js +338 -0
- package/node_modules/pi-lens/dist/clients/spawn-output-cap.js +37 -0
- package/node_modules/pi-lens/dist/clients/spawn-timeout-cooldown.js +15 -1
- package/node_modules/pi-lens/dist/clients/startup-scan.js +6 -7
- package/node_modules/pi-lens/dist/clients/startup-timing.js +69 -4
- package/node_modules/pi-lens/dist/clients/string-utils.js +20 -0
- package/node_modules/pi-lens/dist/clients/test-runner-client.js +419 -88
- package/node_modules/pi-lens/dist/clients/tool-policy.js +1 -1
- package/node_modules/pi-lens/dist/clients/tree-sitter-client.js +11 -5
- package/node_modules/pi-lens/dist/clients/tree-sitter-logger.js +17 -1
- package/node_modules/pi-lens/dist/clients/warm-attach.js +8 -10
- package/node_modules/pi-lens/dist/clients/word-index-logger.js +13 -1
- package/node_modules/pi-lens/dist/clients/word-index-store.js +448 -0
- package/node_modules/pi-lens/dist/clients/word-index.js +582 -104
- package/node_modules/pi-lens/dist/clients/workspace-topology.js +17 -0
- package/node_modules/pi-lens/dist/clients/zizmor-config.js +26 -6
- package/node_modules/pi-lens/dist/index.js +11243 -6651
- package/node_modules/pi-lens/dist/mcp/build-staleness.js +8 -7
- package/node_modules/pi-lens/dist/mcp/cli.js +3 -1
- package/node_modules/pi-lens/dist/mcp/server.js +6 -1
- package/node_modules/pi-lens/dist/tools/lens-diagnostics.js +4 -0
- package/node_modules/pi-lens/dist/tools/lsp-diagnostics.js +14 -5
- package/node_modules/pi-lens/dist/tools/lsp-navigation.js +3 -1
- package/node_modules/pi-lens/docs/agent-guide.md +4 -2
- package/node_modules/pi-lens/docs/ast-grep_rules_catalog.md +41 -10
- package/node_modules/pi-lens/docs/astplayground.md +26 -17
- package/node_modules/pi-lens/package.json +5 -1
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/c-no-malloc-free-test.yml +20 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/cpp-no-malloc-free-test.yml +25 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/cpp-no-printf-test.yml +19 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/go-no-fmt-println-test.yml +19 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/go-no-panic-in-lib-test.yml +17 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/go-no-underscore-func-name-test.yml +18 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/go-prefer-errors-is-test.yml +15 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/go-prefer-string-builder-test.yml +21 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/hyphenated-svg-attribute-test.yml +11 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/kotlin-no-lateinit-test.yml +17 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/kotlin-no-nullable-boolean-test.yml +15 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/kotlin-no-println-test.yml +19 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/kotlin-no-unnecessary-let-test.yml +7 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/kotlin-no-unsafe-cast-test.yml +7 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/kotlin-no-var-test.yml +7 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/kotlin-prefer-data-class-test.yml +25 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/kotlin-prefer-is-empty-test.yml +11 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-important-test.yml +21 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-raw-types-test.yml +30 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-string-concat-in-loop-test.yml +100 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-system-out-println-test.yml +7 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/prefer-string-is-empty-test.yml +7 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/python-optional-type-test.yml +9 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/reducible-list-comprehension-test.yml +11 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/ruby-symbol-to-proc-candidate-test.yml +10 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/rust-no-chars-enumerate-test.yml +7 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/c-no-malloc-free.yml +39 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/cpp-no-malloc-free.yml +45 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/cpp-no-printf.yml +41 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/go-no-fmt-println.yml +43 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/go-no-panic-in-lib.yml +41 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/go-no-underscore-func-name.yml +35 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/go-prefer-errors-is.yml +40 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/go-prefer-string-builder.yml +43 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/hyphenated-svg-attribute.yml +32 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/kotlin-no-lateinit.yml +37 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/kotlin-no-nullable-boolean.yml +33 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/kotlin-no-println.yml +42 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/kotlin-no-unnecessary-let.yml +28 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/kotlin-no-unsafe-cast.yml +28 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/kotlin-no-var.yml +35 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/kotlin-prefer-data-class.yml +66 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/kotlin-prefer-is-empty.yml +35 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-important.yml +21 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-raw-types.yml +33 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-string-concat-in-loop.yml +90 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-system-out-println.yml +16 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/prefer-string-is-empty.yml +11 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/python-optional-type.yml +22 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/reducible-list-comprehension.yml +29 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/ruby-symbol-to-proc-candidate.yml +25 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/rust-no-chars-enumerate.yml +19 -0
- package/node_modules/pi-mcp-adapter/CHANGELOG.md +35 -0
- package/node_modules/pi-mcp-adapter/README.md +5 -2
- package/node_modules/pi-mcp-adapter/cli.js +4 -4
- package/node_modules/pi-mcp-adapter/commands.ts +1 -1
- package/node_modules/pi-mcp-adapter/config.ts +1 -0
- package/node_modules/pi-mcp-adapter/dist/config.js +1 -0
- package/node_modules/pi-mcp-adapter/dist/config.js.map +1 -1
- package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.d.ts +24 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.js +336 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/types.d.ts +3 -1
- package/node_modules/pi-mcp-adapter/dist/types.js.map +1 -1
- package/node_modules/pi-mcp-adapter/index.ts +90 -6
- package/node_modules/pi-mcp-adapter/mcp-auth-flow.ts +124 -32
- package/node_modules/pi-mcp-adapter/mcp-bearer-store.ts +0 -2
- package/node_modules/pi-mcp-adapter/mcp-oauth-provider.ts +89 -0
- package/node_modules/pi-mcp-adapter/mcp-references.ts +9 -1
- package/node_modules/pi-mcp-adapter/package.json +1 -1
- package/node_modules/pi-mcp-adapter/proxy-modes.ts +62 -22
- package/node_modules/pi-mcp-adapter/request-headers-command.ts +1 -1
- package/node_modules/pi-mcp-adapter/server-manager.ts +6 -0
- package/node_modules/pi-mcp-adapter/types.ts +3 -1
- package/node_modules/pi-web-access/CHANGELOG.md +42 -0
- package/node_modules/pi-web-access/README.md +26 -10
- package/node_modules/pi-web-access/curator-page.ts +12 -3
- package/node_modules/pi-web-access/curator-server.ts +3 -1
- package/node_modules/pi-web-access/extract.ts +88 -13
- package/node_modules/pi-web-access/gemini-search.ts +10 -5
- package/node_modules/pi-web-access/github-extract.ts +47 -3
- package/node_modules/pi-web-access/index.ts +40 -40
- package/node_modules/pi-web-access/package.json +1 -1
- package/node_modules/pi-web-access/page-query.ts +61 -8
- package/node_modules/pi-web-access/xcrawl.ts +264 -0
- package/package.json +19 -22
- package/node_modules/@herbertgao/pi-stash/README.md +0 -34
- package/node_modules/@herbertgao/pi-stash/package.json +0 -51
- package/node_modules/@herbertgao/pi-stash/src/index.ts +0 -118
- package/node_modules/@tifan/pi-titlebar-spinner/README.md +0 -24
- package/node_modules/@tifan/pi-titlebar-spinner/package.json +0 -39
- package/node_modules/@tifan/pi-titlebar-spinner/src/index.ts +0 -49
package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/hyphenated-svg-attribute-test.yml
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
id: hyphenated-svg-attribute
|
|
2
|
+
valid:
|
|
3
|
+
- "const icon = <svg strokeWidth=\"2\" />;"
|
|
4
|
+
- "const custom = <my-element data-value=\"x\" />;"
|
|
5
|
+
- "const other = <div stroke-width=\"2\" />;"
|
|
6
|
+
invalid:
|
|
7
|
+
- "const icon = <svg stroke-width=\"2\" />;"
|
|
8
|
+
- "const path = <path fill-rule=\"evenodd\" />;"
|
|
9
|
+
- "const path = <path clip-rule=\"evenodd\" />;"
|
|
10
|
+
- "const use = <use xlink-href=\"#icon\" />;"
|
|
11
|
+
- "const mask = <mask mask-type=\"luminance\" />;"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
id: kotlin-no-lateinit
|
|
2
|
+
valid:
|
|
3
|
+
- |
|
|
4
|
+
class UserRepository(private val apiClient: ApiClient)
|
|
5
|
+
- |
|
|
6
|
+
class Foo {
|
|
7
|
+
var name: String = ""
|
|
8
|
+
}
|
|
9
|
+
invalid:
|
|
10
|
+
- |
|
|
11
|
+
class UserRepository {
|
|
12
|
+
lateinit var apiClient: ApiClient
|
|
13
|
+
}
|
|
14
|
+
- |
|
|
15
|
+
class Foo {
|
|
16
|
+
lateinit var items: MutableList<String>
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
id: kotlin-no-println
|
|
2
|
+
valid:
|
|
3
|
+
- |
|
|
4
|
+
fun main() {
|
|
5
|
+
logger.info { "starting up" }
|
|
6
|
+
}
|
|
7
|
+
- |
|
|
8
|
+
fun main() {
|
|
9
|
+
writer.println("hi")
|
|
10
|
+
}
|
|
11
|
+
invalid:
|
|
12
|
+
- |
|
|
13
|
+
fun main() {
|
|
14
|
+
println("starting up")
|
|
15
|
+
}
|
|
16
|
+
- |
|
|
17
|
+
fun main() {
|
|
18
|
+
print("no newline")
|
|
19
|
+
}
|
package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/kotlin-prefer-data-class-test.yml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
id: kotlin-prefer-data-class
|
|
2
|
+
valid:
|
|
3
|
+
- |
|
|
4
|
+
data class Point(val x: Int, val y: Int)
|
|
5
|
+
- |
|
|
6
|
+
open class Base(val x: Int)
|
|
7
|
+
- |
|
|
8
|
+
class Mixed(val x: Int, y: Int)
|
|
9
|
+
- |
|
|
10
|
+
class WithBehavior(val x: Int) {
|
|
11
|
+
fun scale(factor: Int): Int = x * factor
|
|
12
|
+
}
|
|
13
|
+
- |
|
|
14
|
+
class WithInit(val x: Int) {
|
|
15
|
+
init { println(x) }
|
|
16
|
+
}
|
|
17
|
+
- |
|
|
18
|
+
class WithComputed(val x: Int) {
|
|
19
|
+
val doubled: Int get() = x * 2
|
|
20
|
+
}
|
|
21
|
+
invalid:
|
|
22
|
+
- |
|
|
23
|
+
class Point(val x: Int, val y: Int)
|
|
24
|
+
- |
|
|
25
|
+
class Ok(val v: String) : Result()
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
id: no-important
|
|
2
|
+
valid:
|
|
3
|
+
- |
|
|
4
|
+
.button {
|
|
5
|
+
color: red;
|
|
6
|
+
}
|
|
7
|
+
- |
|
|
8
|
+
.button {
|
|
9
|
+
color: red;
|
|
10
|
+
}
|
|
11
|
+
/* !important mentioned only in a comment, not a declaration */
|
|
12
|
+
invalid:
|
|
13
|
+
- |
|
|
14
|
+
.button {
|
|
15
|
+
color: red !important;
|
|
16
|
+
}
|
|
17
|
+
- |
|
|
18
|
+
.modal {
|
|
19
|
+
display: none !important;
|
|
20
|
+
z-index: 9999 !important;
|
|
21
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
id: no-raw-types
|
|
2
|
+
valid:
|
|
3
|
+
- 'List<String> names = new ArrayList<String>();'
|
|
4
|
+
- 'Map<String, Integer> counts = new HashMap<>();'
|
|
5
|
+
# PR #2212 review F3: neither context has a valid parameterized form.
|
|
6
|
+
# `o instanceof List<String>` and `List<String>.class` are compile errors,
|
|
7
|
+
# so a finding here can never be acted on.
|
|
8
|
+
- |
|
|
9
|
+
class Probe {
|
|
10
|
+
void check(Object o) {
|
|
11
|
+
if (o instanceof List) { }
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
- |
|
|
15
|
+
class Probe {
|
|
16
|
+
Class<?> token() {
|
|
17
|
+
return List.class;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
# The qualifier chain of a parameterized qualified type stays silent.
|
|
21
|
+
- 'java.util.List<String> queue = null;'
|
|
22
|
+
- 'Map.Entry<String, Integer> entry = null;'
|
|
23
|
+
invalid:
|
|
24
|
+
- 'List names = new ArrayList();'
|
|
25
|
+
- 'Optional value = Optional.empty();'
|
|
26
|
+
# PR #2212 review F4: a raw type nested in a type argument. The pre-fix rule
|
|
27
|
+
# excluded it, because `not: inside: {kind: generic_type, stopBy: end}`
|
|
28
|
+
# walked every ancestor and found the enclosing `Map<...>`.
|
|
29
|
+
- 'Map<String, List> nested = null;'
|
|
30
|
+
- 'java.util.List raw = null;'
|
package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-string-concat-in-loop-test.yml
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
id: no-string-concat-in-loop
|
|
2
|
+
valid:
|
|
3
|
+
- |
|
|
4
|
+
StringBuilder result = new StringBuilder();
|
|
5
|
+
for (String item : items) {
|
|
6
|
+
result.append(item);
|
|
7
|
+
}
|
|
8
|
+
- 'String result = prefix + suffix;'
|
|
9
|
+
- |
|
|
10
|
+
int total = 0;
|
|
11
|
+
for (int value : values) {
|
|
12
|
+
total = total + value;
|
|
13
|
+
}
|
|
14
|
+
- |
|
|
15
|
+
double count = 0;
|
|
16
|
+
while (ready()) {
|
|
17
|
+
count += 1;
|
|
18
|
+
}
|
|
19
|
+
# PR #2212 review F1: numeric accumulation whose right-hand side merely
|
|
20
|
+
# contains a string literal, deep inside a call argument. The pre-fix rule
|
|
21
|
+
# searched for a string_literal with `stopBy: end` and fired on both lines.
|
|
22
|
+
- |
|
|
23
|
+
class Counter {
|
|
24
|
+
void run(java.util.Map<String, Integer> counts, java.util.List<String> keys) {
|
|
25
|
+
int total = 0;
|
|
26
|
+
for (String key : keys) {
|
|
27
|
+
total += counts.get("label");
|
|
28
|
+
total = total + counts.getOrDefault("k", 0);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
# A String-named local in a different method must not license numeric
|
|
33
|
+
# accumulation here. This pins the method scoping of the declaration arm.
|
|
34
|
+
- |
|
|
35
|
+
class Scoped {
|
|
36
|
+
String build(java.util.List<String> items) {
|
|
37
|
+
String total = "";
|
|
38
|
+
return total;
|
|
39
|
+
}
|
|
40
|
+
int count(java.util.List<String> items) {
|
|
41
|
+
int total = 0;
|
|
42
|
+
for (String item : items) {
|
|
43
|
+
total += item.length();
|
|
44
|
+
}
|
|
45
|
+
return total;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
invalid:
|
|
49
|
+
- |
|
|
50
|
+
String result = "";
|
|
51
|
+
for (String item : items) {
|
|
52
|
+
result += item + " ";
|
|
53
|
+
}
|
|
54
|
+
- |
|
|
55
|
+
while (ready()) {
|
|
56
|
+
result = result + " " ;
|
|
57
|
+
}
|
|
58
|
+
# PR #2212 review F2: the canonical true positive. No string literal appears
|
|
59
|
+
# anywhere in either statement, so the pre-fix rule reported nothing.
|
|
60
|
+
- |
|
|
61
|
+
class Builder {
|
|
62
|
+
String join(java.util.List<String> items) {
|
|
63
|
+
String s = "";
|
|
64
|
+
for (String x : items) {
|
|
65
|
+
s += x;
|
|
66
|
+
}
|
|
67
|
+
return s;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
- |
|
|
71
|
+
class Builder {
|
|
72
|
+
String join(java.util.List<String> items) {
|
|
73
|
+
String t = "";
|
|
74
|
+
for (String x : items) {
|
|
75
|
+
t = t + x;
|
|
76
|
+
}
|
|
77
|
+
return t;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
# The accumulator is a String field, not a local.
|
|
81
|
+
- |
|
|
82
|
+
class Accumulator {
|
|
83
|
+
private String buffer = "";
|
|
84
|
+
void add(java.util.List<String> items) {
|
|
85
|
+
for (String item : items) {
|
|
86
|
+
buffer += item;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
# do-while loops allocate the same way as for and while.
|
|
91
|
+
- |
|
|
92
|
+
class Looper {
|
|
93
|
+
String pump() {
|
|
94
|
+
String out = "";
|
|
95
|
+
do {
|
|
96
|
+
out += next();
|
|
97
|
+
} while (ready());
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
}
|
package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/reducible-list-comprehension-test.yml
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
id: reducible-list-comprehension
|
|
2
|
+
valid:
|
|
3
|
+
- "total = sum(price for price in prices)"
|
|
4
|
+
- "items = [item for item in source]"
|
|
5
|
+
- "result = max([value for value in values])"
|
|
6
|
+
- "total = sum([price async for price in prices])"
|
|
7
|
+
- "found = any([await check(item) for item in items])"
|
|
8
|
+
invalid:
|
|
9
|
+
- "total = sum([price for price in prices])"
|
|
10
|
+
- "found = any([item for item in items])"
|
|
11
|
+
- "complete = all([item.ready for item in items])"
|
package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/ruby-symbol-to-proc-candidate-test.yml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
id: ruby-symbol-to-proc-candidate
|
|
2
|
+
valid:
|
|
3
|
+
- "names.each { |name| puts name }"
|
|
4
|
+
- "names.map { |name| name.upcase(prefix) }"
|
|
5
|
+
- "names.map { |name| name.(1) }"
|
|
6
|
+
- "names.map(&:upcase)"
|
|
7
|
+
- "names.map { |name| name.() }"
|
|
8
|
+
invalid:
|
|
9
|
+
- "names.map { |name| name.upcase }"
|
|
10
|
+
- "names.select { |name| name.empty? }"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# C No malloc/free
|
|
2
|
+
# Detects manual heap allocation via malloc/calloc/realloc/free.
|
|
3
|
+
# Ported from vinhnx/VTCode rules/c/no-malloc-free.yml (#2201, refs #2195).
|
|
4
|
+
id: c-no-malloc-free
|
|
5
|
+
language: c
|
|
6
|
+
severity: warning
|
|
7
|
+
message: "Manual malloc/calloc/realloc/free; verify ownership and error handling"
|
|
8
|
+
note: |
|
|
9
|
+
Manual heap management is routine and often correct in C, but every call
|
|
10
|
+
site needs a matching free on every path (including error returns) and a
|
|
11
|
+
NULL check on the allocation itself. This rule surfaces the call sites for
|
|
12
|
+
review; it does not imply the allocation is wrong.
|
|
13
|
+
Detection-only: whether an allocation is intentional, already
|
|
14
|
+
correctly paired and error-checked, or a leak/double-free candidate
|
|
15
|
+
requires tracing ownership across the function, which this syntactic rule
|
|
16
|
+
cannot verify.
|
|
17
|
+
Expect volume in an unmanaged-memory C codebase: this fires once per
|
|
18
|
+
malloc/calloc/realloc/free call site, so a file with routine heap use can
|
|
19
|
+
report many findings that are individually fine. Treat a high count as a
|
|
20
|
+
prompt to skim for the unpaired or unchecked exceptions, not as a signal
|
|
21
|
+
every call site needs a change.
|
|
22
|
+
rule:
|
|
23
|
+
kind: call_expression
|
|
24
|
+
has:
|
|
25
|
+
field: function
|
|
26
|
+
kind: identifier
|
|
27
|
+
regex: "^(malloc|calloc|realloc|free)$"
|
|
28
|
+
tags:
|
|
29
|
+
- c
|
|
30
|
+
- idiom
|
|
31
|
+
- memory-safety
|
|
32
|
+
examples:
|
|
33
|
+
bad: |
|
|
34
|
+
int *buf = malloc(sizeof(int) * count);
|
|
35
|
+
/* ... */
|
|
36
|
+
free(buf);
|
|
37
|
+
good: |
|
|
38
|
+
/* Same call sites, reviewed for a matching free on every path and a
|
|
39
|
+
NULL check on the allocation. */
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# C++ No malloc/free
|
|
2
|
+
# Detects manual heap allocation via malloc/calloc/realloc/free in C++.
|
|
3
|
+
# Ported from vinhnx/VTCode rules/cpp/no-malloc-free.yml (#2201, refs #2195).
|
|
4
|
+
id: cpp-no-malloc-free
|
|
5
|
+
language: cpp
|
|
6
|
+
severity: warning
|
|
7
|
+
message: "Manual malloc/calloc/realloc/free in C++; consider RAII (new/unique_ptr/vector)"
|
|
8
|
+
note: |
|
|
9
|
+
C++ has RAII, smart pointers, and standard containers that pair allocation
|
|
10
|
+
with automatic, exception-safe deallocation. malloc/free bypass
|
|
11
|
+
constructors/destructors entirely, which is unsafe for anything but a
|
|
12
|
+
trivial type.
|
|
13
|
+
Detection-only: migrating a call site to RAII requires knowing the
|
|
14
|
+
object's lifetime and whether it crosses an API boundary that expects a
|
|
15
|
+
raw pointer (a C interop layer, a custom allocator), which this rule
|
|
16
|
+
cannot verify.
|
|
17
|
+
rule:
|
|
18
|
+
kind: call_expression
|
|
19
|
+
has:
|
|
20
|
+
field: function
|
|
21
|
+
any:
|
|
22
|
+
# A bare call: malloc(...).
|
|
23
|
+
- kind: identifier
|
|
24
|
+
regex: "^(malloc|calloc|realloc|free)$"
|
|
25
|
+
# A namespace-qualified call: std::malloc(...) or ::malloc(...). C++
|
|
26
|
+
# inherits these into std:: via <cstdlib>, and the global-scope form
|
|
27
|
+
# is common in code that also has a project-local `malloc` overload.
|
|
28
|
+
# The qualifier itself (`std`/empty) isn't part of the identifier
|
|
29
|
+
# node's text, so it's unconstrained here; only the trailing name is
|
|
30
|
+
# checked, which is exactly the function being called either way.
|
|
31
|
+
- kind: qualified_identifier
|
|
32
|
+
has:
|
|
33
|
+
field: name
|
|
34
|
+
kind: identifier
|
|
35
|
+
regex: "^(malloc|calloc|realloc|free)$"
|
|
36
|
+
tags:
|
|
37
|
+
- cpp
|
|
38
|
+
- idiom
|
|
39
|
+
- memory-safety
|
|
40
|
+
examples:
|
|
41
|
+
bad: |
|
|
42
|
+
int* buf = static_cast<int*>(malloc(sizeof(int) * count));
|
|
43
|
+
free(buf);
|
|
44
|
+
good: |
|
|
45
|
+
auto buf = std::make_unique<int[]>(count);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# C++ No printf
|
|
2
|
+
# Detects C-style `printf` in C++ code.
|
|
3
|
+
# Ported from vinhnx/VTCode rules/cpp/no-printf.yml (#2201, refs #2195).
|
|
4
|
+
id: cpp-no-printf
|
|
5
|
+
language: cpp
|
|
6
|
+
severity: warning
|
|
7
|
+
message: "Avoid printf in C++; prefer std::cout/std::format for type-safe formatting"
|
|
8
|
+
note: |
|
|
9
|
+
printf's format string and argument types aren't checked by the compiler,
|
|
10
|
+
so a mismatch is undefined behavior instead of a compile error.
|
|
11
|
+
std::cout/std::format (C++20) and iostreams are type-checked.
|
|
12
|
+
Detection-only: replacing printf changes call-site syntax and, for
|
|
13
|
+
std::format, requires a C++20 toolchain, both project policy calls this
|
|
14
|
+
rule cannot make. Scoped to bare `printf`; `fprintf`/`sprintf` overlap the
|
|
15
|
+
existing `fix-format-security-error-cpp` CodeRabbit rule and are left to
|
|
16
|
+
it.
|
|
17
|
+
rule:
|
|
18
|
+
kind: call_expression
|
|
19
|
+
has:
|
|
20
|
+
field: function
|
|
21
|
+
any:
|
|
22
|
+
# A bare call: printf(...).
|
|
23
|
+
- kind: identifier
|
|
24
|
+
regex: "^printf$"
|
|
25
|
+
# A namespace-qualified call: std::printf(...) or ::printf(...). C++
|
|
26
|
+
# inherits printf into std:: via <cstdio>. The qualifier isn't part of
|
|
27
|
+
# the identifier node's text, so only the trailing name is checked.
|
|
28
|
+
- kind: qualified_identifier
|
|
29
|
+
has:
|
|
30
|
+
field: name
|
|
31
|
+
kind: identifier
|
|
32
|
+
regex: "^printf$"
|
|
33
|
+
tags:
|
|
34
|
+
- cpp
|
|
35
|
+
- idiom
|
|
36
|
+
- type-safety
|
|
37
|
+
examples:
|
|
38
|
+
bad: |
|
|
39
|
+
printf("count: %d\n", count);
|
|
40
|
+
good: |
|
|
41
|
+
std::cout << "count: " << count << "\n";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Go No fmt.Println in Production Code
|
|
2
|
+
# Detects fmt.Println/Printf/Fprintln/Fprint/Fprintf calls outside tests and
|
|
3
|
+
# examples, which should route through a structured logger instead.
|
|
4
|
+
# Ported from vinhnx/VTCode rules/go/no-fmt-println.yml (#2200, refs #2195).
|
|
5
|
+
id: go-no-fmt-println
|
|
6
|
+
language: go
|
|
7
|
+
severity: warning
|
|
8
|
+
message: "Avoid fmt.Println/Printf-family calls in production code; use a structured logger"
|
|
9
|
+
note: |
|
|
10
|
+
Direct console output via fmt.Println/Printf/Fprintln/Fprint/Fprintf is not
|
|
11
|
+
configurable and cannot be routed to log aggregators. Use log/slog
|
|
12
|
+
(Go 1.21+) or a structured logging library for production code.
|
|
13
|
+
fmt.Println is acceptable in tests, examples, and CLI tools, so this rule
|
|
14
|
+
excludes _test.go files and examples/ directories.
|
|
15
|
+
Detection-only: which logger to use, and whether a given call site is a
|
|
16
|
+
CLI entry point rather than library code, is a project policy call this
|
|
17
|
+
rule cannot make.
|
|
18
|
+
rule:
|
|
19
|
+
any:
|
|
20
|
+
- pattern: $FUNC($$$)
|
|
21
|
+
constraints:
|
|
22
|
+
FUNC:
|
|
23
|
+
regex: "^fmt\\.(Println|Printf|Fprintln|Fprint|Fprintf)$"
|
|
24
|
+
has:
|
|
25
|
+
kind: field_identifier
|
|
26
|
+
ignores:
|
|
27
|
+
- "**/*_test.go"
|
|
28
|
+
- "**/examples/**"
|
|
29
|
+
- "tests/fixtures/**"
|
|
30
|
+
- "cases/**"
|
|
31
|
+
tags:
|
|
32
|
+
- go
|
|
33
|
+
- idiom
|
|
34
|
+
- logging
|
|
35
|
+
examples:
|
|
36
|
+
bad: |
|
|
37
|
+
func main() {
|
|
38
|
+
fmt.Println("hello")
|
|
39
|
+
}
|
|
40
|
+
good: |
|
|
41
|
+
func main() {
|
|
42
|
+
slog.Info("hello")
|
|
43
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Go No panic() in Library Code
|
|
2
|
+
# Detects panic() calls outside tests and cmd/ entry points; library code
|
|
3
|
+
# should return error values instead.
|
|
4
|
+
# Ported from vinhnx/VTCode rules/go/no-panic-in-lib.yml (#2200, refs #2195).
|
|
5
|
+
id: go-no-panic-in-lib
|
|
6
|
+
language: go
|
|
7
|
+
severity: warning
|
|
8
|
+
message: "Avoid panic() in library code; return errors instead"
|
|
9
|
+
note: |
|
|
10
|
+
panic() unwinds the entire goroutine stack and is not recoverable by
|
|
11
|
+
callers unless they use defer/recover. Library code should return error
|
|
12
|
+
values so callers can handle failures gracefully. Scoped to non-test,
|
|
13
|
+
non-cmd Go files, since main packages under cmd/ legitimately panic on
|
|
14
|
+
unrecoverable startup failures.
|
|
15
|
+
Detection-only: converting a panic to an error return changes the
|
|
16
|
+
function's signature and every caller, which this rule cannot verify is
|
|
17
|
+
safe.
|
|
18
|
+
rule:
|
|
19
|
+
pattern: panic($MSG)
|
|
20
|
+
ignores:
|
|
21
|
+
- "**/*_test.go"
|
|
22
|
+
- "**/cmd/**"
|
|
23
|
+
tags:
|
|
24
|
+
- go
|
|
25
|
+
- idiom
|
|
26
|
+
- error-handling
|
|
27
|
+
examples:
|
|
28
|
+
bad: |
|
|
29
|
+
func mustDivide(a, b int) int {
|
|
30
|
+
if b == 0 {
|
|
31
|
+
panic("division by zero")
|
|
32
|
+
}
|
|
33
|
+
return a / b
|
|
34
|
+
}
|
|
35
|
+
good: |
|
|
36
|
+
func divide(a, b int) (int, error) {
|
|
37
|
+
if b == 0 {
|
|
38
|
+
return 0, errors.New("division by zero")
|
|
39
|
+
}
|
|
40
|
+
return a / b, nil
|
|
41
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Go No Underscore in Function Names
|
|
2
|
+
# Detects snake_case Go function names, which violate Go's camelCase
|
|
3
|
+
# naming convention.
|
|
4
|
+
# Ported from vinhnx/VTCode rules/go/no-underscore-func-name.yml
|
|
5
|
+
# (#2200, refs #2195).
|
|
6
|
+
id: go-no-underscore-func-name
|
|
7
|
+
language: go
|
|
8
|
+
severity: hint
|
|
9
|
+
message: "Use camelCase for Go function names, not snake_case"
|
|
10
|
+
note: |
|
|
11
|
+
Go convention uses camelCase for function names (e.g. getUserName, not
|
|
12
|
+
get_user_name). Detection-only, with no autofix: renaming a function
|
|
13
|
+
requires updating every call site, and an exported (capitalized) name
|
|
14
|
+
change also breaks API compatibility for downstream importers. Scoped to
|
|
15
|
+
non-test Go files.
|
|
16
|
+
rule:
|
|
17
|
+
pattern: func $NAME($$$) $$$ { $$$ }
|
|
18
|
+
constraints:
|
|
19
|
+
NAME:
|
|
20
|
+
regex: "^[a-z_]*_[a-z]"
|
|
21
|
+
ignores:
|
|
22
|
+
- "**/*_test.go"
|
|
23
|
+
tags:
|
|
24
|
+
- go
|
|
25
|
+
- idiom
|
|
26
|
+
- naming-convention
|
|
27
|
+
examples:
|
|
28
|
+
bad: |
|
|
29
|
+
func get_user_name(id int) string {
|
|
30
|
+
return ""
|
|
31
|
+
}
|
|
32
|
+
good: |
|
|
33
|
+
func getUserName(id int) string {
|
|
34
|
+
return ""
|
|
35
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Go Prefer errors.Is Over Direct Comparison
|
|
2
|
+
# Detects direct == / != comparison against an error-shaped identifier,
|
|
3
|
+
# which fails to match wrapped errors.
|
|
4
|
+
# Ported from vinhnx/VTCode rules/go/prefer-errors-is.yml (#2200, refs #2195).
|
|
5
|
+
id: go-prefer-errors-is
|
|
6
|
+
language: go
|
|
7
|
+
severity: hint
|
|
8
|
+
message: "Use errors.Is(err, target) instead of direct comparison for error checking"
|
|
9
|
+
note: |
|
|
10
|
+
Direct comparison (err == target / err != target) fails for wrapped
|
|
11
|
+
errors. errors.Is unwraps the error chain and compares each layer, which
|
|
12
|
+
is the idiomatic check for a specific error value in Go 1.13+.
|
|
13
|
+
Detection-only, with no autofix: VTCode ships an unconditional
|
|
14
|
+
`fix: errors.Is($ERR, $TARGET)`, but that rewrite is wrong for the `!=`
|
|
15
|
+
form (it needs `!errors.Is(...)`) and requires inserting an `errors`
|
|
16
|
+
import the rule cannot verify is already present, so pi-lens withholds
|
|
17
|
+
the fix pending a review of both branches (per the #2195 triage verdict).
|
|
18
|
+
Scoped to non-test Go files.
|
|
19
|
+
rule:
|
|
20
|
+
any:
|
|
21
|
+
- pattern: $ERR == $TARGET
|
|
22
|
+
- pattern: $ERR != $TARGET
|
|
23
|
+
constraints:
|
|
24
|
+
TARGET:
|
|
25
|
+
regex: "^(Err|err|[A-Z].*[Ee]rror|os\\.Err)"
|
|
26
|
+
ignores:
|
|
27
|
+
- "**/*_test.go"
|
|
28
|
+
tags:
|
|
29
|
+
- go
|
|
30
|
+
- idiom
|
|
31
|
+
- error-handling
|
|
32
|
+
examples:
|
|
33
|
+
bad: |
|
|
34
|
+
if err == os.ErrNotExist {
|
|
35
|
+
return nil
|
|
36
|
+
}
|
|
37
|
+
good: |
|
|
38
|
+
if errors.Is(err, os.ErrNotExist) {
|
|
39
|
+
return nil
|
|
40
|
+
}
|