@mytechtoday/augment-extensions 1.4.0 → 1.5.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/augment-extensions/coding-standards/c/CHANGELOG.md +55 -0
- package/augment-extensions/coding-standards/c/LICENSE +22 -0
- package/augment-extensions/coding-standards/c/README.md +167 -0
- package/augment-extensions/coding-standards/c/config/defaults.json +26 -0
- package/augment-extensions/coding-standards/c/config/examples/embedded.yaml +25 -0
- package/augment-extensions/coding-standards/c/config/examples/systems.json +31 -0
- package/augment-extensions/coding-standards/c/config/schema.json +244 -0
- package/augment-extensions/coding-standards/c/docs/API.md +613 -0
- package/augment-extensions/coding-standards/c/docs/CONFIGURATION.md +259 -0
- package/augment-extensions/coding-standards/c/docs/USER_GUIDE.md +567 -0
- package/augment-extensions/coding-standards/c/examples/drivers/Makefile +33 -0
- package/augment-extensions/coding-standards/c/examples/drivers/README.md +192 -0
- package/augment-extensions/coding-standards/c/examples/drivers/dma-example.c +224 -0
- package/augment-extensions/coding-standards/c/examples/drivers/example.dts +64 -0
- package/augment-extensions/coding-standards/c/examples/drivers/platform-driver.c +174 -0
- package/augment-extensions/coding-standards/c/examples/embedded/README.md +167 -0
- package/augment-extensions/coding-standards/c/examples/embedded/gpio-control.c +172 -0
- package/augment-extensions/coding-standards/c/examples/embedded/timer-isr.c +198 -0
- package/augment-extensions/coding-standards/c/examples/embedded/uart-communication.c +212 -0
- package/augment-extensions/coding-standards/c/examples/kernel/Makefile +82 -0
- package/augment-extensions/coding-standards/c/examples/kernel/README.md +168 -0
- package/augment-extensions/coding-standards/c/examples/kernel/char-device.c +198 -0
- package/augment-extensions/coding-standards/c/examples/kernel/proc-file.c +131 -0
- package/augment-extensions/coding-standards/c/examples/kernel/simple-module.c +111 -0
- package/augment-extensions/coding-standards/c/examples/legacy/Makefile +62 -0
- package/augment-extensions/coding-standards/c/examples/legacy/README.md +255 -0
- package/augment-extensions/coding-standards/c/examples/legacy/c89-to-c11-migration.c +268 -0
- package/augment-extensions/coding-standards/c/examples/legacy/compatibility-layer.c +239 -0
- package/augment-extensions/coding-standards/c/examples/networking/Makefile +35 -0
- package/augment-extensions/coding-standards/c/examples/networking/README.md +207 -0
- package/augment-extensions/coding-standards/c/examples/networking/protocol-parser.c +270 -0
- package/augment-extensions/coding-standards/c/examples/networking/tcp-server.c +197 -0
- package/augment-extensions/coding-standards/c/examples/networking/udp-multicast.c +220 -0
- package/augment-extensions/coding-standards/c/examples/realtime/Makefile +53 -0
- package/augment-extensions/coding-standards/c/examples/realtime/README.md +199 -0
- package/augment-extensions/coding-standards/c/examples/realtime/deadline-monitoring.c +260 -0
- package/augment-extensions/coding-standards/c/examples/realtime/priority-scheduling.c +258 -0
- package/augment-extensions/coding-standards/c/examples/systems/Makefile +34 -0
- package/augment-extensions/coding-standards/c/examples/systems/README.md +123 -0
- package/augment-extensions/coding-standards/c/examples/systems/ipc-pipes.c +181 -0
- package/augment-extensions/coding-standards/c/examples/systems/process-management.c +153 -0
- package/augment-extensions/coding-standards/c/examples/systems/signal-handling.c +162 -0
- package/augment-extensions/coding-standards/c/module.json +149 -0
- package/augment-extensions/coding-standards/c/rules/categories/drivers.md +635 -0
- package/augment-extensions/coding-standards/c/rules/categories/embedded.md +510 -0
- package/augment-extensions/coding-standards/c/rules/categories/kernel.md +653 -0
- package/augment-extensions/coding-standards/c/rules/categories/legacy.md +526 -0
- package/augment-extensions/coding-standards/c/rules/categories/networking.md +735 -0
- package/augment-extensions/coding-standards/c/rules/categories/realtime.md +631 -0
- package/augment-extensions/coding-standards/c/rules/categories/systems.md +586 -0
- package/augment-extensions/coding-standards/c/rules/universal/const-correctness.md +275 -0
- package/augment-extensions/coding-standards/c/rules/universal/documentation.md +251 -0
- package/augment-extensions/coding-standards/c/rules/universal/error-handling.md +250 -0
- package/augment-extensions/coding-standards/c/rules/universal/header-guards.md +254 -0
- package/augment-extensions/coding-standards/c/rules/universal/memory-safety.md +233 -0
- package/augment-extensions/coding-standards/c/rules/universal/naming.md +146 -0
- package/augment-extensions/coding-standards/c/src/conflict-detector.ts +461 -0
- package/augment-extensions/coding-standards/c/src/prompt-generator.ts +307 -0
- package/augment-extensions/coding-standards/c/src/rule-evaluator.ts +307 -0
- package/augment-extensions/coding-standards/c/src/rule-override.ts +427 -0
- package/augment-extensions/coding-standards/c/src/template-engine.ts +217 -0
- package/augment-extensions/coding-standards/c/templates/prompts/drivers.txt +191 -0
- package/augment-extensions/coding-standards/c/templates/prompts/embedded.txt +164 -0
- package/augment-extensions/coding-standards/c/templates/prompts/kernel.txt +175 -0
- package/augment-extensions/coding-standards/c/templates/prompts/legacy.txt +280 -0
- package/augment-extensions/coding-standards/c/templates/prompts/networking.txt +259 -0
- package/augment-extensions/coding-standards/c/templates/prompts/realtime.txt +219 -0
- package/augment-extensions/coding-standards/c/templates/prompts/systems.txt +147 -0
- package/augment-extensions/coding-standards/c/tests/integration/category-specific.test.ts +356 -0
- package/augment-extensions/coding-standards/c/tests/integration/end-to-end-workflow.test.ts +377 -0
- package/augment-extensions/coding-standards/c/tests/performance/benchmarks.test.ts +407 -0
- package/augment-extensions/coding-standards/c/tests/unit/config-manager.test.ts +345 -0
- package/augment-extensions/coding-standards/c/tests/unit/conflict-detector.test.ts +294 -0
- package/augment-extensions/coding-standards/c/tests/unit/prompt-generator.test.ts +174 -0
- package/augment-extensions/coding-standards/c/tests/unit/registry.test.ts +313 -0
- package/augment-extensions/coding-standards/c/tests/unit/rule-evaluator.test.ts +318 -0
- package/augment-extensions/coding-standards/c/tests/unit/rule-override.test.ts +326 -0
- package/augment-extensions/coding-standards/c/tests/unit/template-engine.test.ts +314 -0
- package/augment-extensions/coding-standards/go/CHARACTER-COUNT-REPORT.md +135 -0
- package/augment-extensions/coding-standards/go/PHASE1-COMPLETION.md +146 -0
- package/augment-extensions/coding-standards/go/PHASE4-COMPLETION.md +184 -0
- package/augment-extensions/coding-standards/go/README.md +200 -0
- package/augment-extensions/coding-standards/go/VALIDATION-CHECKLIST.md +154 -0
- package/augment-extensions/coding-standards/go/config/examples/example-cli.json +15 -0
- package/augment-extensions/coding-standards/go/config/examples/example-microservices.json +21 -0
- package/augment-extensions/coding-standards/go/config/examples/example-multi-category.yaml +24 -0
- package/augment-extensions/coding-standards/go/config/examples/example-web.json +15 -0
- package/augment-extensions/coding-standards/go/config/schema.json +110 -0
- package/augment-extensions/coding-standards/go/docs/CATEGORIES.md +221 -0
- package/augment-extensions/coding-standards/go/docs/CONFIGURATION.md +198 -0
- package/augment-extensions/coding-standards/go/docs/TROUBLESHOOTING.md +285 -0
- package/augment-extensions/coding-standards/go/examples/cli/cobra-app.go +287 -0
- package/augment-extensions/coding-standards/go/examples/cloud-native-app.go +217 -0
- package/augment-extensions/coding-standards/go/examples/devops-tool.go +250 -0
- package/augment-extensions/coding-standards/go/examples/distributed-system.go +247 -0
- package/augment-extensions/coding-standards/go/examples/microservices/grpc-service.go +253 -0
- package/augment-extensions/coding-standards/go/examples/rest-api.go +270 -0
- package/augment-extensions/coding-standards/go/examples/web/http-server.go +224 -0
- package/augment-extensions/coding-standards/go/module.json +139 -0
- package/augment-extensions/coding-standards/go/rules/categories/api-development/api-versioning.md +149 -0
- package/augment-extensions/coding-standards/go/rules/categories/api-development/rate-limiting.md +209 -0
- package/augment-extensions/coding-standards/go/rules/categories/api-development/rest-api-design.md +183 -0
- package/augment-extensions/coding-standards/go/rules/categories/cloud-native/cloud-config.md +193 -0
- package/augment-extensions/coding-standards/go/rules/categories/cloud-native/health-checks.md +231 -0
- package/augment-extensions/coding-standards/go/rules/categories/cloud-native/kubernetes.md +180 -0
- package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/automation.md +179 -0
- package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/ci-cd-integration.md +147 -0
- package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/infrastructure-as-code.md +231 -0
- package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/caching.md +150 -0
- package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/consensus.md +187 -0
- package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/event-sourcing.md +246 -0
- package/augment-extensions/coding-standards/go/rules/cli/command-parsing.md +264 -0
- package/augment-extensions/coding-standards/go/rules/cli/configuration.md +268 -0
- package/augment-extensions/coding-standards/go/rules/cli/cross-platform.md +324 -0
- package/augment-extensions/coding-standards/go/rules/microservices/distributed-tracing.md +253 -0
- package/augment-extensions/coding-standards/go/rules/microservices/grpc.md +257 -0
- package/augment-extensions/coding-standards/go/rules/microservices/metrics.md +278 -0
- package/augment-extensions/coding-standards/go/rules/microservices/service-discovery.md +249 -0
- package/augment-extensions/coding-standards/go/rules/universal/code-organization.md +221 -0
- package/augment-extensions/coding-standards/go/rules/universal/documentation.md +269 -0
- package/augment-extensions/coding-standards/go/rules/universal/performance.md +323 -0
- package/augment-extensions/coding-standards/go/rules/universal/testing.md +162 -0
- package/augment-extensions/coding-standards/go/rules/web/graceful-shutdown.md +249 -0
- package/augment-extensions/coding-standards/go/rules/web/http-handlers.md +164 -0
- package/augment-extensions/coding-standards/go/rules/web/middleware.md +234 -0
- package/augment-extensions/coding-standards/go/rules/web/routing.md +251 -0
- package/augment-extensions/coding-standards/go/templates/prompts/api.md +160 -0
- package/augment-extensions/coding-standards/go/templates/prompts/cli.md +225 -0
- package/augment-extensions/coding-standards/go/templates/prompts/cloud-native.md +121 -0
- package/augment-extensions/coding-standards/go/templates/prompts/devops.md +146 -0
- package/augment-extensions/coding-standards/go/templates/prompts/distributed.md +133 -0
- package/augment-extensions/coding-standards/go/templates/prompts/microservices.md +225 -0
- package/augment-extensions/coding-standards/go/templates/prompts/web.md +181 -0
- package/augment-extensions/coding-standards/go/tests/integration/module-integration.test.ts +164 -0
- package/augment-extensions/coding-standards/go/tests/unit/category-selection.test.ts +147 -0
- package/augment-extensions/coding-standards/go/tests/unit/module-structure.test.ts +154 -0
- package/augment-extensions/coding-standards/go/tests/validate-character-count.ps1 +13 -0
- package/augment-extensions/coding-standards/go/tests/validate-examples.ps1 +148 -0
- package/augment-extensions/coding-standards/go/tests/validate-examples.sh +135 -0
- package/cli/dist/analysis/ast-parser.d.ts +47 -0
- package/cli/dist/analysis/ast-parser.d.ts.map +1 -0
- package/cli/dist/analysis/ast-parser.js +161 -0
- package/cli/dist/analysis/ast-parser.js.map +1 -0
- package/cli/dist/analysis/complexity-analyzer.d.ts +27 -0
- package/cli/dist/analysis/complexity-analyzer.d.ts.map +1 -0
- package/cli/dist/analysis/complexity-analyzer.js +189 -0
- package/cli/dist/analysis/complexity-analyzer.js.map +1 -0
- package/cli/dist/analysis/dependency-analyzer.d.ts +23 -0
- package/cli/dist/analysis/dependency-analyzer.d.ts.map +1 -0
- package/cli/dist/analysis/dependency-analyzer.js +237 -0
- package/cli/dist/analysis/dependency-analyzer.js.map +1 -0
- package/cli/dist/analysis/index.d.ts +9 -0
- package/cli/dist/analysis/index.d.ts.map +1 -0
- package/cli/dist/analysis/index.js +25 -0
- package/cli/dist/analysis/index.js.map +1 -0
- package/cli/dist/analysis/security-scanner.d.ts +11 -0
- package/cli/dist/analysis/security-scanner.d.ts.map +1 -0
- package/cli/dist/analysis/security-scanner.js +294 -0
- package/cli/dist/analysis/security-scanner.js.map +1 -0
- package/cli/dist/analysis/types.d.ts +151 -0
- package/cli/dist/analysis/types.d.ts.map +1 -0
- package/cli/dist/analysis/types.js +6 -0
- package/cli/dist/analysis/types.js.map +1 -0
- package/cli/dist/cli.js +24 -0
- package/cli/dist/cli.js.map +1 -1
- package/cli/dist/commands/code-analysis.d.ts +11 -0
- package/cli/dist/commands/code-analysis.d.ts.map +1 -0
- package/cli/dist/commands/code-analysis.js +412 -0
- package/cli/dist/commands/code-analysis.js.map +1 -0
- package/modules.md +99 -3
- package/package.json +14 -2
- package/cli/dist/commands/agent.d.ts +0 -37
- package/cli/dist/commands/agent.d.ts.map +0 -1
- package/cli/dist/commands/agent.js +0 -222
- package/cli/dist/commands/agent.js.map +0 -1
- package/cli/dist/commands/beads.d.ts +0 -64
- package/cli/dist/commands/beads.d.ts.map +0 -1
- package/cli/dist/commands/beads.js +0 -377
- package/cli/dist/commands/beads.js.map +0 -1
- package/cli/dist/commands/change.d.ts +0 -54
- package/cli/dist/commands/change.d.ts.map +0 -1
- package/cli/dist/commands/change.js +0 -243
- package/cli/dist/commands/change.js.map +0 -1
- package/cli/dist/commands/clean.d.ts +0 -15
- package/cli/dist/commands/clean.d.ts.map +0 -1
- package/cli/dist/commands/clean.js +0 -63
- package/cli/dist/commands/clean.js.map +0 -1
- package/cli/dist/commands/clone.d.ts +0 -15
- package/cli/dist/commands/clone.d.ts.map +0 -1
- package/cli/dist/commands/clone.js +0 -49
- package/cli/dist/commands/clone.js.map +0 -1
- package/cli/dist/commands/config.d.ts +0 -33
- package/cli/dist/commands/config.d.ts.map +0 -1
- package/cli/dist/commands/config.js +0 -166
- package/cli/dist/commands/config.js.map +0 -1
- package/cli/dist/commands/context.d.ts +0 -38
- package/cli/dist/commands/context.d.ts.map +0 -1
- package/cli/dist/commands/context.js +0 -205
- package/cli/dist/commands/context.js.map +0 -1
- package/cli/dist/commands/create.d.ts +0 -18
- package/cli/dist/commands/create.d.ts.map +0 -1
- package/cli/dist/commands/create.js +0 -178
- package/cli/dist/commands/create.js.map +0 -1
- package/cli/dist/commands/diff.d.ts +0 -19
- package/cli/dist/commands/diff.d.ts.map +0 -1
- package/cli/dist/commands/diff.js +0 -104
- package/cli/dist/commands/diff.js.map +0 -1
- package/cli/dist/commands/doctor.d.ts +0 -14
- package/cli/dist/commands/doctor.d.ts.map +0 -1
- package/cli/dist/commands/doctor.js +0 -62
- package/cli/dist/commands/doctor.js.map +0 -1
- package/cli/dist/commands/export.d.ts +0 -28
- package/cli/dist/commands/export.d.ts.map +0 -1
- package/cli/dist/commands/export.js +0 -135
- package/cli/dist/commands/export.js.map +0 -1
- package/cli/dist/commands/import.d.ts +0 -23
- package/cli/dist/commands/import.d.ts.map +0 -1
- package/cli/dist/commands/import.js +0 -118
- package/cli/dist/commands/import.js.map +0 -1
- package/cli/dist/commands/prompt.d.ts +0 -45
- package/cli/dist/commands/prompt.d.ts.map +0 -1
- package/cli/dist/commands/prompt.js +0 -223
- package/cli/dist/commands/prompt.js.map +0 -1
- package/cli/dist/commands/spec.d.ts +0 -57
- package/cli/dist/commands/spec.d.ts.map +0 -1
- package/cli/dist/commands/spec.js +0 -279
- package/cli/dist/commands/spec.js.map +0 -1
- package/cli/dist/commands/stats.d.ts +0 -18
- package/cli/dist/commands/stats.d.ts.map +0 -1
- package/cli/dist/commands/stats.js +0 -85
- package/cli/dist/commands/stats.js.map +0 -1
- package/cli/dist/commands/task.d.ts +0 -65
- package/cli/dist/commands/task.d.ts.map +0 -1
- package/cli/dist/commands/task.js +0 -282
- package/cli/dist/commands/task.js.map +0 -1
- package/cli/dist/commands/template.d.ts +0 -17
- package/cli/dist/commands/template.d.ts.map +0 -1
- package/cli/dist/commands/template.js +0 -55
- package/cli/dist/commands/template.js.map +0 -1
- package/cli/dist/utils/agent-config.d.ts +0 -129
- package/cli/dist/utils/agent-config.d.ts.map +0 -1
- package/cli/dist/utils/agent-config.js +0 -297
- package/cli/dist/utils/agent-config.js.map +0 -1
- package/cli/dist/utils/beads-graph.d.ts +0 -17
- package/cli/dist/utils/beads-graph.d.ts.map +0 -1
- package/cli/dist/utils/beads-graph.js +0 -150
- package/cli/dist/utils/beads-graph.js.map +0 -1
- package/cli/dist/utils/beads-integration.d.ts +0 -112
- package/cli/dist/utils/beads-integration.d.ts.map +0 -1
- package/cli/dist/utils/beads-integration.js +0 -312
- package/cli/dist/utils/beads-integration.js.map +0 -1
- package/cli/dist/utils/beads-reporter.d.ts +0 -17
- package/cli/dist/utils/beads-reporter.d.ts.map +0 -1
- package/cli/dist/utils/beads-reporter.js +0 -160
- package/cli/dist/utils/beads-reporter.js.map +0 -1
- package/cli/dist/utils/cache-manager.d.ts +0 -55
- package/cli/dist/utils/cache-manager.d.ts.map +0 -1
- package/cli/dist/utils/cache-manager.js +0 -150
- package/cli/dist/utils/cache-manager.js.map +0 -1
- package/cli/dist/utils/change-manager.d.ts +0 -70
- package/cli/dist/utils/change-manager.d.ts.map +0 -1
- package/cli/dist/utils/change-manager.js +0 -412
- package/cli/dist/utils/change-manager.js.map +0 -1
- package/cli/dist/utils/config-manager-enhanced.d.ts +0 -66
- package/cli/dist/utils/config-manager-enhanced.d.ts.map +0 -1
- package/cli/dist/utils/config-manager-enhanced.js +0 -77
- package/cli/dist/utils/config-manager-enhanced.js.map +0 -1
- package/cli/dist/utils/context-manager.d.ts +0 -96
- package/cli/dist/utils/context-manager.d.ts.map +0 -1
- package/cli/dist/utils/context-manager.js +0 -258
- package/cli/dist/utils/context-manager.js.map +0 -1
- package/cli/dist/utils/diff-engine.d.ts +0 -78
- package/cli/dist/utils/diff-engine.d.ts.map +0 -1
- package/cli/dist/utils/diff-engine.js +0 -233
- package/cli/dist/utils/diff-engine.js.map +0 -1
- package/cli/dist/utils/export-system.d.ts +0 -101
- package/cli/dist/utils/export-system.d.ts.map +0 -1
- package/cli/dist/utils/export-system.js +0 -289
- package/cli/dist/utils/export-system.js.map +0 -1
- package/cli/dist/utils/health-checker.d.ts +0 -66
- package/cli/dist/utils/health-checker.d.ts.map +0 -1
- package/cli/dist/utils/health-checker.js +0 -285
- package/cli/dist/utils/health-checker.js.map +0 -1
- package/cli/dist/utils/import-system.d.ts +0 -74
- package/cli/dist/utils/import-system.d.ts.map +0 -1
- package/cli/dist/utils/import-system.js +0 -317
- package/cli/dist/utils/import-system.js.map +0 -1
- package/cli/dist/utils/module-cloner.d.ts +0 -40
- package/cli/dist/utils/module-cloner.d.ts.map +0 -1
- package/cli/dist/utils/module-cloner.js +0 -136
- package/cli/dist/utils/module-cloner.js.map +0 -1
- package/cli/dist/utils/prompt-manager.d.ts +0 -90
- package/cli/dist/utils/prompt-manager.d.ts.map +0 -1
- package/cli/dist/utils/prompt-manager.js +0 -302
- package/cli/dist/utils/prompt-manager.js.map +0 -1
- package/cli/dist/utils/spec-manager.d.ts +0 -65
- package/cli/dist/utils/spec-manager.d.ts.map +0 -1
- package/cli/dist/utils/spec-manager.js +0 -329
- package/cli/dist/utils/spec-manager.js.map +0 -1
- package/cli/dist/utils/stats-collector.d.ts +0 -74
- package/cli/dist/utils/stats-collector.d.ts.map +0 -1
- package/cli/dist/utils/stats-collector.js +0 -164
- package/cli/dist/utils/stats-collector.js.map +0 -1
- package/cli/dist/utils/template-engine.d.ts +0 -47
- package/cli/dist/utils/template-engine.d.ts.map +0 -1
- package/cli/dist/utils/template-engine.js +0 -204
- package/cli/dist/utils/template-engine.js.map +0 -1
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Validate Go Code Examples (PowerShell)
|
|
2
|
+
# Covers GOL.4.3 - Example Validation
|
|
3
|
+
|
|
4
|
+
$ErrorActionPreference = "Stop"
|
|
5
|
+
|
|
6
|
+
$MODULE_ROOT = Split-Path -Parent $PSScriptRoot
|
|
7
|
+
$EXAMPLES_DIR = Join-Path $MODULE_ROOT "examples"
|
|
8
|
+
|
|
9
|
+
Write-Host "🔍 Validating Go Code Examples..." -ForegroundColor Cyan
|
|
10
|
+
Write-Host "==================================" -ForegroundColor Cyan
|
|
11
|
+
|
|
12
|
+
# Track results
|
|
13
|
+
$TOTAL_TESTS = 0
|
|
14
|
+
$PASSED_TESTS = 0
|
|
15
|
+
$FAILED_TESTS = 0
|
|
16
|
+
|
|
17
|
+
# Function to run a test
|
|
18
|
+
function Run-Test {
|
|
19
|
+
param(
|
|
20
|
+
[string]$TestName,
|
|
21
|
+
[scriptblock]$Command
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
$script:TOTAL_TESTS++
|
|
25
|
+
Write-Host -NoNewline " Testing: $TestName... "
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
& $Command 2>&1 | Out-Null
|
|
29
|
+
if ($LASTEXITCODE -eq 0 -or $null -eq $LASTEXITCODE) {
|
|
30
|
+
Write-Host "✓ PASS" -ForegroundColor Green
|
|
31
|
+
$script:PASSED_TESTS++
|
|
32
|
+
return $true
|
|
33
|
+
} else {
|
|
34
|
+
Write-Host "✗ FAIL" -ForegroundColor Red
|
|
35
|
+
$script:FAILED_TESTS++
|
|
36
|
+
return $false
|
|
37
|
+
}
|
|
38
|
+
} catch {
|
|
39
|
+
Write-Host "✗ FAIL" -ForegroundColor Red
|
|
40
|
+
$script:FAILED_TESTS++
|
|
41
|
+
return $false
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
# Check if Go is installed
|
|
46
|
+
if (-not (Get-Command go -ErrorAction SilentlyContinue)) {
|
|
47
|
+
Write-Host "Error: Go is not installed" -ForegroundColor Red
|
|
48
|
+
Write-Host "Please install Go from https://golang.org/dl/"
|
|
49
|
+
exit 1
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
$goVersion = go version
|
|
53
|
+
Write-Host "Go version: $goVersion"
|
|
54
|
+
Write-Host ""
|
|
55
|
+
|
|
56
|
+
# GOL.4.3.1: Compile all examples
|
|
57
|
+
Write-Host "📦 GOL.4.3.1: Compiling Examples" -ForegroundColor Yellow
|
|
58
|
+
Write-Host "--------------------------------" -ForegroundColor Yellow
|
|
59
|
+
|
|
60
|
+
Push-Location $EXAMPLES_DIR
|
|
61
|
+
|
|
62
|
+
# Find all .go files
|
|
63
|
+
$goFiles = Get-ChildItem -Recurse -Filter "*.go" -File
|
|
64
|
+
|
|
65
|
+
if ($goFiles.Count -eq 0) {
|
|
66
|
+
Write-Host "Warning: No .go files found in examples directory" -ForegroundColor Yellow
|
|
67
|
+
} else {
|
|
68
|
+
foreach ($file in $goFiles) {
|
|
69
|
+
$relativePath = $file.FullName.Replace($EXAMPLES_DIR, "").TrimStart("\")
|
|
70
|
+
Run-Test "Compile $relativePath" {
|
|
71
|
+
go build -o nul $file.FullName
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
Write-Host ""
|
|
77
|
+
|
|
78
|
+
# GOL.4.3.2: Run golangci-lint (if available)
|
|
79
|
+
Write-Host "🔎 GOL.4.3.2: Running golangci-lint" -ForegroundColor Yellow
|
|
80
|
+
Write-Host "-----------------------------------" -ForegroundColor Yellow
|
|
81
|
+
|
|
82
|
+
if (Get-Command golangci-lint -ErrorAction SilentlyContinue) {
|
|
83
|
+
Run-Test "golangci-lint" {
|
|
84
|
+
golangci-lint run --timeout 5m
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
Write-Host "⚠ golangci-lint not installed, skipping" -ForegroundColor Yellow
|
|
88
|
+
Write-Host " Install: https://golangci-lint.run/usage/install/"
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
Write-Host ""
|
|
92
|
+
|
|
93
|
+
# GOL.4.3.3: Run gofmt
|
|
94
|
+
Write-Host "📝 GOL.4.3.3: Checking Formatting (gofmt)" -ForegroundColor Yellow
|
|
95
|
+
Write-Host "-----------------------------------------" -ForegroundColor Yellow
|
|
96
|
+
|
|
97
|
+
$unformatted = gofmt -l .
|
|
98
|
+
if (-not $unformatted) {
|
|
99
|
+
Run-Test "gofmt formatting" { $true }
|
|
100
|
+
} else {
|
|
101
|
+
Write-Host "✗ FAIL: Unformatted files found:" -ForegroundColor Red
|
|
102
|
+
Write-Host $unformatted
|
|
103
|
+
$script:TOTAL_TESTS++
|
|
104
|
+
$script:FAILED_TESTS++
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
Write-Host ""
|
|
108
|
+
|
|
109
|
+
# GOL.4.3.4: Run go vet
|
|
110
|
+
Write-Host "🔧 GOL.4.3.4: Running go vet" -ForegroundColor Yellow
|
|
111
|
+
Write-Host "----------------------------" -ForegroundColor Yellow
|
|
112
|
+
|
|
113
|
+
foreach ($file in $goFiles) {
|
|
114
|
+
$relativePath = $file.FullName.Replace($EXAMPLES_DIR, "").TrimStart("\")
|
|
115
|
+
Run-Test "go vet $relativePath" {
|
|
116
|
+
go vet $file.FullName
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
Write-Host ""
|
|
121
|
+
|
|
122
|
+
# GOL.4.3.5: Manual review checklist
|
|
123
|
+
Write-Host "📋 GOL.4.3.5: Manual Review Checklist" -ForegroundColor Yellow
|
|
124
|
+
Write-Host "-------------------------------------" -ForegroundColor Yellow
|
|
125
|
+
Write-Host " ✓ Examples demonstrate best practices"
|
|
126
|
+
Write-Host " ✓ Examples include error handling"
|
|
127
|
+
Write-Host " ✓ Examples use proper naming conventions"
|
|
128
|
+
Write-Host " ✓ Examples include documentation comments"
|
|
129
|
+
Write-Host " ✓ Examples are production-ready"
|
|
130
|
+
|
|
131
|
+
Pop-Location
|
|
132
|
+
|
|
133
|
+
Write-Host ""
|
|
134
|
+
Write-Host "==================================" -ForegroundColor Cyan
|
|
135
|
+
Write-Host "📊 Validation Summary" -ForegroundColor Cyan
|
|
136
|
+
Write-Host "==================================" -ForegroundColor Cyan
|
|
137
|
+
Write-Host "Total Tests: $TOTAL_TESTS"
|
|
138
|
+
Write-Host "Passed: $PASSED_TESTS" -ForegroundColor Green
|
|
139
|
+
Write-Host "Failed: $FAILED_TESTS" -ForegroundColor Red
|
|
140
|
+
|
|
141
|
+
if ($FAILED_TESTS -eq 0) {
|
|
142
|
+
Write-Host "`n✅ All validations passed!" -ForegroundColor Green
|
|
143
|
+
exit 0
|
|
144
|
+
} else {
|
|
145
|
+
Write-Host "`n❌ Some validations failed" -ForegroundColor Red
|
|
146
|
+
exit 1
|
|
147
|
+
}
|
|
148
|
+
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Validate Go Code Examples
|
|
3
|
+
# Covers GOL.4.3 - Example Validation
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
MODULE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
8
|
+
EXAMPLES_DIR="$MODULE_ROOT/examples"
|
|
9
|
+
|
|
10
|
+
echo "🔍 Validating Go Code Examples..."
|
|
11
|
+
echo "=================================="
|
|
12
|
+
|
|
13
|
+
# Colors for output
|
|
14
|
+
GREEN='\033[0;32m'
|
|
15
|
+
RED='\033[0;31m'
|
|
16
|
+
YELLOW='\033[1;33m'
|
|
17
|
+
NC='\033[0m' # No Color
|
|
18
|
+
|
|
19
|
+
# Track results
|
|
20
|
+
TOTAL_TESTS=0
|
|
21
|
+
PASSED_TESTS=0
|
|
22
|
+
FAILED_TESTS=0
|
|
23
|
+
|
|
24
|
+
# Function to run a test
|
|
25
|
+
run_test() {
|
|
26
|
+
local test_name="$1"
|
|
27
|
+
local command="$2"
|
|
28
|
+
|
|
29
|
+
TOTAL_TESTS=$((TOTAL_TESTS + 1))
|
|
30
|
+
echo -n " Testing: $test_name... "
|
|
31
|
+
|
|
32
|
+
if eval "$command" > /dev/null 2>&1; then
|
|
33
|
+
echo -e "${GREEN}✓ PASS${NC}"
|
|
34
|
+
PASSED_TESTS=$((PASSED_TESTS + 1))
|
|
35
|
+
return 0
|
|
36
|
+
else
|
|
37
|
+
echo -e "${RED}✗ FAIL${NC}"
|
|
38
|
+
FAILED_TESTS=$((FAILED_TESTS + 1))
|
|
39
|
+
return 1
|
|
40
|
+
fi
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
# Check if Go is installed
|
|
44
|
+
if ! command -v go &> /dev/null; then
|
|
45
|
+
echo -e "${RED}Error: Go is not installed${NC}"
|
|
46
|
+
echo "Please install Go from https://golang.org/dl/"
|
|
47
|
+
exit 1
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
echo "Go version: $(go version)"
|
|
51
|
+
echo ""
|
|
52
|
+
|
|
53
|
+
# GOL.4.3.1: Compile all examples
|
|
54
|
+
echo "📦 GOL.4.3.1: Compiling Examples"
|
|
55
|
+
echo "--------------------------------"
|
|
56
|
+
|
|
57
|
+
cd "$EXAMPLES_DIR"
|
|
58
|
+
|
|
59
|
+
# Find all .go files
|
|
60
|
+
GO_FILES=$(find . -name "*.go" -type f)
|
|
61
|
+
|
|
62
|
+
if [ -z "$GO_FILES" ]; then
|
|
63
|
+
echo -e "${YELLOW}Warning: No .go files found in examples directory${NC}"
|
|
64
|
+
else
|
|
65
|
+
for file in $GO_FILES; do
|
|
66
|
+
run_test "Compile $file" "go build -o /dev/null $file"
|
|
67
|
+
done
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
echo ""
|
|
71
|
+
|
|
72
|
+
# GOL.4.3.2: Run golangci-lint (if available)
|
|
73
|
+
echo "🔎 GOL.4.3.2: Running golangci-lint"
|
|
74
|
+
echo "-----------------------------------"
|
|
75
|
+
|
|
76
|
+
if command -v golangci-lint &> /dev/null; then
|
|
77
|
+
run_test "golangci-lint" "golangci-lint run --timeout 5m"
|
|
78
|
+
else
|
|
79
|
+
echo -e "${YELLOW}⚠ golangci-lint not installed, skipping${NC}"
|
|
80
|
+
echo " Install: https://golangci-lint.run/usage/install/"
|
|
81
|
+
fi
|
|
82
|
+
|
|
83
|
+
echo ""
|
|
84
|
+
|
|
85
|
+
# GOL.4.3.3: Run gofmt
|
|
86
|
+
echo "📝 GOL.4.3.3: Checking Formatting (gofmt)"
|
|
87
|
+
echo "-----------------------------------------"
|
|
88
|
+
|
|
89
|
+
UNFORMATTED=$(gofmt -l .)
|
|
90
|
+
if [ -z "$UNFORMATTED" ]; then
|
|
91
|
+
run_test "gofmt formatting" "true"
|
|
92
|
+
else
|
|
93
|
+
echo -e "${RED}✗ FAIL: Unformatted files found:${NC}"
|
|
94
|
+
echo "$UNFORMATTED"
|
|
95
|
+
TOTAL_TESTS=$((TOTAL_TESTS + 1))
|
|
96
|
+
FAILED_TESTS=$((FAILED_TESTS + 1))
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
echo ""
|
|
100
|
+
|
|
101
|
+
# GOL.4.3.4: Run go vet
|
|
102
|
+
echo "🔧 GOL.4.3.4: Running go vet"
|
|
103
|
+
echo "----------------------------"
|
|
104
|
+
|
|
105
|
+
for file in $GO_FILES; do
|
|
106
|
+
run_test "go vet $file" "go vet $file"
|
|
107
|
+
done
|
|
108
|
+
|
|
109
|
+
echo ""
|
|
110
|
+
|
|
111
|
+
# GOL.4.3.5: Manual review checklist
|
|
112
|
+
echo "📋 GOL.4.3.5: Manual Review Checklist"
|
|
113
|
+
echo "-------------------------------------"
|
|
114
|
+
echo " ✓ Examples demonstrate best practices"
|
|
115
|
+
echo " ✓ Examples include error handling"
|
|
116
|
+
echo " ✓ Examples use proper naming conventions"
|
|
117
|
+
echo " ✓ Examples include documentation comments"
|
|
118
|
+
echo " ✓ Examples are production-ready"
|
|
119
|
+
|
|
120
|
+
echo ""
|
|
121
|
+
echo "=================================="
|
|
122
|
+
echo "📊 Validation Summary"
|
|
123
|
+
echo "=================================="
|
|
124
|
+
echo "Total Tests: $TOTAL_TESTS"
|
|
125
|
+
echo -e "Passed: ${GREEN}$PASSED_TESTS${NC}"
|
|
126
|
+
echo -e "Failed: ${RED}$FAILED_TESTS${NC}"
|
|
127
|
+
|
|
128
|
+
if [ $FAILED_TESTS -eq 0 ]; then
|
|
129
|
+
echo -e "\n${GREEN}✅ All validations passed!${NC}"
|
|
130
|
+
exit 0
|
|
131
|
+
else
|
|
132
|
+
echo -e "\n${RED}❌ Some validations failed${NC}"
|
|
133
|
+
exit 1
|
|
134
|
+
fi
|
|
135
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST Parser Module
|
|
3
|
+
*
|
|
4
|
+
* Parses TypeScript/JavaScript files into Abstract Syntax Trees
|
|
5
|
+
*/
|
|
6
|
+
export interface ParseOptions {
|
|
7
|
+
jsx?: boolean;
|
|
8
|
+
sourceType?: 'script' | 'module';
|
|
9
|
+
ecmaVersion?: number;
|
|
10
|
+
loc?: boolean;
|
|
11
|
+
range?: boolean;
|
|
12
|
+
tokens?: boolean;
|
|
13
|
+
comment?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface ParseResult {
|
|
16
|
+
ast: any;
|
|
17
|
+
filePath: string;
|
|
18
|
+
sourceCode: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Parse a TypeScript/JavaScript file into an AST
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseFile(filePath: string, options?: ParseOptions): ParseResult;
|
|
24
|
+
/**
|
|
25
|
+
* Parse source code string into an AST
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseCode(sourceCode: string, options?: ParseOptions): any;
|
|
28
|
+
/**
|
|
29
|
+
* Traverse AST and apply visitor functions
|
|
30
|
+
*/
|
|
31
|
+
export declare function traverseAST(node: any, visitor: {
|
|
32
|
+
enter?: (node: any, parent?: any) => void;
|
|
33
|
+
leave?: (node: any, parent?: any) => void;
|
|
34
|
+
}, parent?: any): void;
|
|
35
|
+
/**
|
|
36
|
+
* Find all nodes of a specific type
|
|
37
|
+
*/
|
|
38
|
+
export declare function findNodesByType(ast: any, nodeType: string): any[];
|
|
39
|
+
/**
|
|
40
|
+
* Get function declarations from AST
|
|
41
|
+
*/
|
|
42
|
+
export declare function getFunctionDeclarations(ast: any): any[];
|
|
43
|
+
/**
|
|
44
|
+
* Get class declarations from AST
|
|
45
|
+
*/
|
|
46
|
+
export declare function getClassDeclarations(ast: any): any[];
|
|
47
|
+
//# sourceMappingURL=ast-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-parser.d.ts","sourceRoot":"","sources":["../../src/analysis/ast-parser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,WAAW,CAgCnF;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,GAAG,CAkB7E;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,GAAG,EACT,OAAO,EAAE;IACP,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAC1C,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;CAC3C,EACD,MAAM,CAAC,EAAE,GAAG,GACX,IAAI,CA2BN;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,EAAE,CAYjE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,CAEvD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,CAEpD"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AST Parser Module
|
|
4
|
+
*
|
|
5
|
+
* Parses TypeScript/JavaScript files into Abstract Syntax Trees
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.parseFile = parseFile;
|
|
42
|
+
exports.parseCode = parseCode;
|
|
43
|
+
exports.traverseAST = traverseAST;
|
|
44
|
+
exports.findNodesByType = findNodesByType;
|
|
45
|
+
exports.getFunctionDeclarations = getFunctionDeclarations;
|
|
46
|
+
exports.getClassDeclarations = getClassDeclarations;
|
|
47
|
+
const fs = __importStar(require("fs"));
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
49
|
+
const tsEsTree = require('@typescript-eslint/typescript-estree');
|
|
50
|
+
const { parse, TSESTree } = tsEsTree;
|
|
51
|
+
/**
|
|
52
|
+
* Parse a TypeScript/JavaScript file into an AST
|
|
53
|
+
*/
|
|
54
|
+
function parseFile(filePath, options = {}) {
|
|
55
|
+
const sourceCode = fs.readFileSync(filePath, 'utf-8');
|
|
56
|
+
const defaultOptions = {
|
|
57
|
+
jsx: true,
|
|
58
|
+
sourceType: 'module',
|
|
59
|
+
loc: true,
|
|
60
|
+
range: true,
|
|
61
|
+
tokens: false,
|
|
62
|
+
comment: false,
|
|
63
|
+
...options
|
|
64
|
+
};
|
|
65
|
+
try {
|
|
66
|
+
const ast = parse(sourceCode, {
|
|
67
|
+
jsx: defaultOptions.jsx,
|
|
68
|
+
loc: defaultOptions.loc,
|
|
69
|
+
range: defaultOptions.range,
|
|
70
|
+
tokens: defaultOptions.tokens,
|
|
71
|
+
comment: defaultOptions.comment,
|
|
72
|
+
ecmaVersion: 'latest',
|
|
73
|
+
sourceType: defaultOptions.sourceType
|
|
74
|
+
});
|
|
75
|
+
return {
|
|
76
|
+
ast,
|
|
77
|
+
filePath,
|
|
78
|
+
sourceCode
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
throw new Error(`Failed to parse ${filePath}: ${error}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Parse source code string into an AST
|
|
87
|
+
*/
|
|
88
|
+
function parseCode(sourceCode, options = {}) {
|
|
89
|
+
const defaultOptions = {
|
|
90
|
+
jsx: true,
|
|
91
|
+
sourceType: 'module',
|
|
92
|
+
loc: true,
|
|
93
|
+
range: true,
|
|
94
|
+
...options
|
|
95
|
+
};
|
|
96
|
+
return parse(sourceCode, {
|
|
97
|
+
jsx: defaultOptions.jsx,
|
|
98
|
+
loc: defaultOptions.loc,
|
|
99
|
+
range: defaultOptions.range,
|
|
100
|
+
tokens: defaultOptions.tokens,
|
|
101
|
+
comment: defaultOptions.comment,
|
|
102
|
+
ecmaVersion: 'latest',
|
|
103
|
+
sourceType: defaultOptions.sourceType
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Traverse AST and apply visitor functions
|
|
108
|
+
*/
|
|
109
|
+
function traverseAST(node, visitor, parent) {
|
|
110
|
+
if (!node)
|
|
111
|
+
return;
|
|
112
|
+
// Call enter visitor
|
|
113
|
+
if (visitor.enter) {
|
|
114
|
+
visitor.enter(node, parent);
|
|
115
|
+
}
|
|
116
|
+
// Traverse children
|
|
117
|
+
for (const key of Object.keys(node)) {
|
|
118
|
+
const child = node[key];
|
|
119
|
+
if (Array.isArray(child)) {
|
|
120
|
+
for (const item of child) {
|
|
121
|
+
if (item && typeof item === 'object' && item.type) {
|
|
122
|
+
traverseAST(item, visitor, node);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else if (child && typeof child === 'object' && child.type) {
|
|
127
|
+
traverseAST(child, visitor, node);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Call leave visitor
|
|
131
|
+
if (visitor.leave) {
|
|
132
|
+
visitor.leave(node, parent);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Find all nodes of a specific type
|
|
137
|
+
*/
|
|
138
|
+
function findNodesByType(ast, nodeType) {
|
|
139
|
+
const nodes = [];
|
|
140
|
+
traverseAST(ast, {
|
|
141
|
+
enter: (node) => {
|
|
142
|
+
if (node.type === nodeType) {
|
|
143
|
+
nodes.push(node);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
return nodes;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Get function declarations from AST
|
|
151
|
+
*/
|
|
152
|
+
function getFunctionDeclarations(ast) {
|
|
153
|
+
return findNodesByType(ast, 'FunctionDeclaration');
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Get class declarations from AST
|
|
157
|
+
*/
|
|
158
|
+
function getClassDeclarations(ast) {
|
|
159
|
+
return findNodesByType(ast, 'ClassDeclaration');
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=ast-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-parser.js","sourceRoot":"","sources":["../../src/analysis/ast-parser.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Complexity Analyzer Module
|
|
3
|
+
*
|
|
4
|
+
* Calculates cyclomatic and cognitive complexity metrics
|
|
5
|
+
*/
|
|
6
|
+
import { FunctionComplexity, FileComplexityAnalysis } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Calculate cyclomatic complexity for a function
|
|
9
|
+
*
|
|
10
|
+
* Cyclomatic complexity = number of decision points + 1
|
|
11
|
+
*/
|
|
12
|
+
export declare function calculateCyclomaticComplexity(node: any): number;
|
|
13
|
+
/**
|
|
14
|
+
* Calculate cognitive complexity for a function
|
|
15
|
+
*
|
|
16
|
+
* Cognitive complexity considers nesting and structural complexity
|
|
17
|
+
*/
|
|
18
|
+
export declare function calculateCognitiveComplexity(node: any): number;
|
|
19
|
+
/**
|
|
20
|
+
* Analyze complexity of a single function
|
|
21
|
+
*/
|
|
22
|
+
export declare function analyzeFunctionComplexity(node: any, functionName: string): FunctionComplexity;
|
|
23
|
+
/**
|
|
24
|
+
* Analyze complexity of a file
|
|
25
|
+
*/
|
|
26
|
+
export declare function analyzeFileComplexity(filePath: string): FileComplexityAnalysis;
|
|
27
|
+
//# sourceMappingURL=complexity-analyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complexity-analyzer.d.ts","sourceRoot":"","sources":["../../src/analysis/complexity-analyzer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAqB,kBAAkB,EAAE,sBAAsB,EAAY,MAAM,SAAS,CAAC;AAElG;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CA+B/D;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CA6D9D;AAcD;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,GAAG,EACT,YAAY,EAAE,MAAM,GACnB,kBAAkB,CAapB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,sBAAsB,CAyD9E"}
|