Skip to content

Feat/barrel enhancements#10

Merged
Coderrob merged 12 commits intomainfrom
feat/barrel-enhancements
Feb 5, 2026
Merged

Feat/barrel enhancements#10
Coderrob merged 12 commits intomainfrom
feat/barrel-enhancements

Conversation

@Coderrob
Copy link
Owner

@Coderrob Coderrob commented Feb 3, 2026

This pull request introduces several improvements and safeguards to the barrel file generation system, focusing on preserving direct definitions in index.ts, optimizing performance and memory usage, and enhancing robustness against large files and deep directory structures. It also updates tests and linting rules to support these changes.

Barrel file generation and content preservation:

  • The BarrelFileGenerator now preserves direct definitions (such as functions, types, and constants) in index.ts files when updating, instead of overwriting or removing them. Only re-exports are sanitized and regenerated as needed. [1] [2] [3] [4]
  • Added a new test to ensure that direct definitions are correctly preserved during barrel file updates.

Performance and memory optimizations:

  • Introduced batching and concurrency control when processing TypeScript files for export extraction, preventing excessive memory usage and improving performance on large projects. [1] [2]
  • Implemented an LRU-style cache for parsed exports, keyed by file modification time, to avoid redundant parsing and further reduce processing time. [1] [2]

Robustness and safeguards:

  • Added a maximum recursion depth (20) for processing subdirectories to prevent infinite loops or stack overflows in deeply nested directory structures. [1] [2] [3]
  • The file system service now checks file size before reading and rejects files larger than 10MB, protecting against out-of-memory errors. [1] [2] [3] [4]
  • Added a method to retrieve file stats with error handling, supporting the caching and size-checking features.

Testing and linting improvements:

  • Test patterns updated to include new test files under dist/types and dist/src/types.
  • ESLint config now warns against inline object types in type annotations, encouraging use of named interfaces or type aliases.

These changes enhance the reliability, maintainability, and scalability of the barrel file generation system, especially for large or complex codebases.

…trol

feat: add file size validation in FileSystemService
test: add contract validation tests for Barrel types and enums
chore: update ESLint rules for TypeScript annotations
Copilot AI review requested due to automatic review settings February 3, 2026 23:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request enhances the barrel file generation system with performance optimizations, robustness safeguards, and improved content preservation. The changes focus on making the system more reliable and scalable for large codebases.

Changes:

  • Added preservation of direct definitions (functions, types, constants) in index.ts files when updating barrel files, ensuring only re-exports are sanitized
  • Implemented batching, concurrency control, and LRU-style caching for export parsing to optimize performance and memory usage
  • Added safeguards including recursion depth limits (20 levels) and file size checks (10MB maximum) to prevent infinite loops and memory issues

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/types/contracts.test.ts New comprehensive contract validation tests for enums, types, and behavioral contracts
src/extension.ts Added BarrelCommandQueue to prevent concurrent barrel generation operations
src/core/io/file-system.service.ts Added file size validation and new getFileStats method for caching support
src/core/io/file-system.service.test.ts Added tests for file size validation and updated existing tests for stat calls
src/core/barrel/barrel-file.generator.ts Major refactoring with caching, batching, concurrency control, recursion depth limiting, and definition preservation logic
src/core/barrel/barrel-file.generator.test.ts Added test for preserving direct definitions during barrel file updates
scripts/run-tests.cjs Added test patterns for dist/types/*.test.js and dist/src/types/*.test.js
eslint.config.mjs Added linting rule to discourage inline object types in type annotations
Comments suppressed due to low confidence (1)

src/core/io/file-system.service.ts:142

  • The error handling at lines 139-142 will catch and re-wrap errors from the file size check at lines 131-136. This means if a file is too large, the original descriptive error message about the file size will be wrapped in a generic "Failed to read file" message, making it less clear to the user what the actual problem is.

Consider checking the error type and re-throwing the size error directly, or move the size check outside the try-catch block to avoid double-wrapping the error message.

    } catch (error) {
      const errorMessage = getErrorMessage(error);
      throw new Error(`Failed to read file ${filePath}: ${errorMessage}`);
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…r concurrency control

- Added unit tests for array utilities, including `isEmptyArray`.
- Implemented comprehensive tests for custom assertion utilities.
- Created tests for error handling utilities, including `getErrorMessage` and `formatErrorForLog`.
- Developed tests for ESLint plugin helpers and string utilities.
- Introduced a Semaphore class to manage concurrency with a limit on concurrent operations.
- Added tests for the Semaphore class to ensure correct behavior in queuing and releasing permits.
- Updated string utility functions with improved sorting logic and added tests for various scenarios.
- Added type definitions for Logger and OutputChannel interfaces.
…access types; add hardening plan for test coverage
@Coderrob Coderrob merged commit ebc441f into main Feb 5, 2026
6 checks passed
@Coderrob Coderrob deleted the feat/barrel-enhancements branch February 5, 2026 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant