pumuki-ast-hooks 5.6.12 → 5.6.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pumuki-ast-hooks",
3
- "version": "5.6.12",
3
+ "version": "5.6.13",
4
4
  "description": "Enterprise-grade AST Intelligence System with multi-platform support (iOS, Android, Backend, Frontend) and Feature-First + DDD + Clean Architecture enforcement. Includes dynamic violations API for intelligent querying.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -502,3 +502,7 @@
502
502
  {"timestamp":1768158974401,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
503
503
  {"timestamp":1768158974401,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
504
504
  {"timestamp":1768158974402,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
505
+ {"timestamp":1768162663136,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
506
+ {"timestamp":1768162663136,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
507
+ {"timestamp":1768162663136,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
508
+ {"timestamp":1768162663136,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
@@ -58,6 +58,35 @@ describe('AST Common Module', () => {
58
58
  expect(findings.some(f => f.ruleId === 'common.testing.missing_makesut')).toBe(false);
59
59
  expect(findings.some(f => f.ruleId === 'common.testing.missing_track_for_memory_leaks')).toBe(false);
60
60
  });
61
+
62
+ it('does not report false positives for Swift test files when getFullText is non-empty but incomplete (prefer disk)', () => {
63
+ const project = new Project({
64
+ useInMemoryFileSystem: true,
65
+ skipAddingFilesFromTsConfig: true,
66
+ });
67
+
68
+ const swiftPath = '/tmp/DomainAPIEndpointTests.spec.swift';
69
+ const swiftContent = [
70
+ 'import XCTest',
71
+ 'final class DomainAPIEndpointTests: XCTestCase {',
72
+ ' private func makeSUT() -> Foo { Foo() }',
73
+ ' func test_example() {',
74
+ ' let sut = makeSUT()',
75
+ ' trackForMemoryLeaks(sut, testCase: self, file: #file, line: #line)',
76
+ ' }',
77
+ '}',
78
+ ].join('\n');
79
+
80
+ const sf = project.createSourceFile(swiftPath, swiftContent);
81
+ jest.spyOn(sf, 'getFullText').mockReturnValue('import XCTest\nfinal class DomainAPIEndpointTests: XCTestCase {}');
82
+ jest.spyOn(fs, 'readFileSync').mockReturnValue(swiftContent);
83
+
84
+ const findings = [];
85
+ runCommonIntelligence(project, findings);
86
+
87
+ expect(findings.some(f => f.ruleId === 'common.testing.missing_makesut')).toBe(false);
88
+ expect(findings.some(f => f.ruleId === 'common.testing.missing_track_for_memory_leaks')).toBe(false);
89
+ });
61
90
  });
62
91
 
63
92
  describe('exports', () => {
@@ -214,9 +214,12 @@ function runCommonIntelligence(project, findings) {
214
214
  const ext = path.extname(filePath).toLowerCase();
215
215
  const isSwiftOrKotlinTest = ext === '.swift' || ext === '.kt' || ext === '.kts';
216
216
 
217
- if (isSwiftOrKotlinTest && (!content || content.trim().length === 0)) {
217
+ if (isSwiftOrKotlinTest) {
218
218
  try {
219
- content = fs.readFileSync(filePath, 'utf8');
219
+ const diskContent = fs.readFileSync(filePath, 'utf8');
220
+ if (diskContent && diskContent.trim().length > 0) {
221
+ content = diskContent;
222
+ }
220
223
  } catch (error) {
221
224
  if (process.env.DEBUG) {
222
225
  console.debug(`[ast-common] Failed to read test file content for ${filePath}: ${error.message}`);