Commit graph

7 commits

Author SHA1 Message Date
Christian C. Berclaz
7f8b01d506
refactor(ingestion): consolidate per-language patterns into LanguageProvider (#1279)
* refactor(ingestion): consolidate per-language patterns into LanguageProvider

Move entry-point name patterns and AST framework detection patterns from
shared maps in entry-point-scoring.ts and framework-detection.ts into each
LanguageProvider. The shared files now build their lookup tables dynamically
from the provider registry at module load.

This aligns with the architecture principle that shared pipeline code must
not name languages. Adding a new language no longer requires modifying
entry-point-scoring.ts or framework-detection.ts — the provider file is
the single source of truth for all language-specific data.

New LanguageProvider fields:
  - entryPointPatterns: RegExp[] (default: [])
  - astFrameworkPatterns: AstFrameworkPatternConfig[] (default: [])

* test(ingestion): add provider-registry, multiplier/reason, and Kotlin/Dart/Ruby entry-point coverage

Addresses review feedback on the per-language pattern consolidation:

- Runtime guard that providers map covers every SupportedLanguages member,
  catching enum/registry drift that the compile-time `satisfies` cannot.
- Multiplier/reason parity assertions for nestjs (3.2/nestjs-decorator),
  spring (3.2/spring-annotation), and fastapi (3.0/fastapi-decorator) so a
  silent value change during future relocations would fail loudly.
- Entry-point pattern coverage for Kotlin (Android lifecycle, ViewModel,
  Service), Dart (Flutter widget lifecycle), and Ruby (call/perform/execute)
  — the three providers whose patterns moved without representative tests.

* refactor(ingestion): apply satisfies AstFrameworkPatternConfig[] to remaining providers

The c-cpp, dart, php, ruby, and swift providers imported AstFrameworkPatternConfig
but never used it, which the root ESLint config flagged as a hard error in the
quality / lint CI gate.

Use the type the same way csharp/go/java/kotlin/python/rust/typescript already do —
as a satisfies assertion on the astFrameworkPatterns array. This both clears the
unused-import error and gives every provider compile-time validation of pattern
shape, narrowing the gap that the original review flagged about lost exhaustiveness
on the optional astFrameworkPatterns field.

---------

Co-authored-by: Gergo Magyar <gergomagyar@icloud.com>
2026-05-03 10:34:00 +01:00
Ryanba
363245eb63
fix: detect React component paths before lowercasing (#260) 2026-04-19 07:10:36 +01:00
Gergő Magyar
bf09eab95b
feat: configure prettier with pre-commit hook (#563)
* feat: configure prettier with pre-commit hook integration

Add prettier, lint-staged, and prettier-plugin-tailwindcss at the repo
root with husky pre-commit hook integration. Moves husky from
gitnexus/ to root package.json for reliable hook installation.

- Root package.json with prepare/format/format:check scripts
- .prettierrc with endOfLine:lf and tailwindStylesheet for TW v4
- .prettierignore excluding fixtures, vendor, generated, *.d.ts, *.md
- .gitattributes enforcing LF line endings for Windows consistency
- Pre-commit hook uses direct node_modules/.bin/ paths (no npx)

* style: apply prettier formatting to entire codebase

One-time bulk format. No logic changes.
Use .git-blame-ignore-revs to skip this commit in git blame.

* chore: add .git-blame-ignore-revs for prettier format commit

* perf: pre-commit hook runs only tests related to staged files

Use vitest --related to scope test execution to tests that import
the changed files, instead of running the full suite on every commit.

* perf: remove vitest from pre-commit hook, keep in CI only

Pre-commit now runs lint-staged + tsc only. Tests run in CI
(ci-tests.yml) where they belong — keeps commits fast.

* ci: add prettier format check to quality workflow

PRs will now fail if code isn't formatted with prettier.
2026-03-28 14:58:04 +00:00
marxo126
95f97c884c
feat: add Expo Router file-based route detection (#503) 2026-03-25 11:05:55 +00:00
Gergo Magyar
76ed0fa53b fix: address PR #409 review findings (P0-P3) and simplify import resolution API
Bug fixes (P0):
- Narrow Go /cmd/ entry-point detection to only match /main.go
- Fix Rust scoped grouped imports (use crate::models::{User, Repo}) resolution
- Filter PHP use function/use const from class-type namedImportMap bindings

Improvements (P1):
- Add C# resolveStandard fallback when .csproj discovery fails
- Change preprocessImportPath return type to string | null with caller guards
- Add Q_SIGNALS/Q_SLOTS (standard plural Qt macros)
- Fix stale "11 supported languages" comment → 13

API simplification (P2):
- Replace buildImportResolvers() factory with const importResolvers table
- Move configs onto ResolveCtx (extends ImportResolutionContext)
- Eliminate tsconfigPaths parameter threading through 6 non-TS resolvers
- Split utils.ts (1,476 lines) into ast-helpers.ts + call-analysis.ts + utils.ts
- Consolidate findChild/findChildByType into single source of truth
- Match multi-file import bindings to files by basename for namedImportMap

Cleanup (P3):
- EMPTY_INDEX returns shared frozen empty array instead of allocating per call
- Type appendKotlinWildcard parameter as SyntaxNode instead of any
- Document call-routing validation requirement on CallRouter type

Tests:
- Add unit tests for preprocessImportPath (13 tests)
- Add integration tests: Rust scoped multi-file, PHP use function/const,
  C# without .csproj, Go cmd/ helper scoring (14 tests, 4 fixtures)

All 3579 tests pass.
2026-03-21 14:15:15 +00:00
Gergo Magyar
2c17a4642c refactor: unify language dispatch with compile-time exhaustive tables
Replace the 120-line if-chain in resolveLanguageImport() and the 7-branch
dispatch in extractNamedBindings() with per-language dispatch tables using
`satisfies Record<SupportedLanguages, T>` for compile-time exhaustiveness.

Key changes:
- New import-resolution.ts: buildImportResolvers factory + namedBindingExtractors
  table + preprocessImportPath with control character rejection
- Extracted loadImportConfigs(), createImportEdgeHelpers(), getLabelFromCaptures()
  to eliminate duplication across import-processor.ts and parse-worker.ts
- Added isCppDuplicateClassFunction and getLabelFromCaptures shared helpers
- Migrated ENTRY_POINT_PATTERNS and AST_FRAMEWORK_PATTERNS_BY_LANGUAGE to
  satisfies Record<SupportedLanguages, T> with compile-time exhaustiveness
- Added Kotlin entry-point patterns (Android lifecycle, Ktor, MVVM)
- Expanded framework detection: Go (Gin/Echo/Fiber/gRPC), Rust (Actix/Axum/
  Rocket/Tokio), C++ (Qt), Swift (UIKit/SwiftUI/Vapor), Ruby (Rails/Sinatra)
- Fixed Go cmd/ entry-point detection operator precedence bug
- Added EMPTY_INDEX frozen sentinel for type-safe memory cleanup
- Unified ImportResolutionContext (suffixIndex->index, removed unused dispose())
- Extracted NamedBinding interface (replaced 16 inline occurrences)
- Replaced any with SyntaxNode on all tree-sitter node parameters
- Added contributor checklist to SupportedLanguages enum

14 files changed, +318/-550 (net -232 lines). All 3550+ tests pass.
2026-03-21 11:48:11 +00:00
abhigyanpatwari
8a100a76d3 test: add test suite with vitest (unit + integration + fixtures)
- 59 test files covering unit and integration tests
- vitest config with coverage thresholds and fork pooling
- Test fixtures (mini-repo + multi-language sample code)
- Add vitest + coverage-v8 to devDependencies
- Add test scripts (test, test:integration, test:all, test:watch, test:coverage)
- Move typescript to devDependencies where it belongs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 20:07:02 +05:30