pumuki 6.3.158 → 6.3.159

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.
@@ -659,17 +659,28 @@ let text = "XCTUnwrap(optionalValue)"
659
659
  });
660
660
 
661
661
  test('hasSwiftWaitForExpectationsUsage detecta waits legacy y excluye await fulfillment', () => {
662
- const legacyWait = `
662
+ const legacyAsyncWait = `
663
+ func testLegacyAsync() async {
663
664
  let expectation = expectation(description: "Done")
664
665
  wait(for: [expectation], timeout: 1)
665
666
  waitForExpectations(timeout: 1)
667
+ }
668
+ `;
669
+ const legacySyncWait = `
670
+ func testLegacySync() {
671
+ let expectation = expectation(description: "Done")
672
+ wait(for: [expectation], timeout: 1)
673
+ }
666
674
  `;
667
675
  const modernWait = `
676
+ func testModernAsync() async {
668
677
  let expectation = expectation(description: "Done")
669
678
  await fulfillment(of: [expectation], timeout: 1)
679
+ }
670
680
  `;
671
681
 
672
- assert.equal(hasSwiftWaitForExpectationsUsage(legacyWait), true);
682
+ assert.equal(hasSwiftWaitForExpectationsUsage(legacyAsyncWait), true);
683
+ assert.equal(hasSwiftWaitForExpectationsUsage(legacySyncWait), false);
673
684
  assert.equal(hasSwiftWaitForExpectationsUsage(modernWait), false);
674
685
  });
675
686
 
@@ -100,6 +100,63 @@ const hasSwiftSanitizedRegexMatch = (source: string, regex: RegExp): boolean =>
100
100
  return regex.test(sanitizeSwiftSourceForMultilineRegex(source));
101
101
  };
102
102
 
103
+ type SwiftFunctionDeclaration = {
104
+ signature: string;
105
+ body: string;
106
+ };
107
+
108
+ const collectSwiftFunctionDeclarations = (source: string): readonly SwiftFunctionDeclaration[] => {
109
+ const lines = source.split(/\r?\n/);
110
+ const functions: SwiftFunctionDeclaration[] = [];
111
+
112
+ for (let index = 0; index < lines.length; index += 1) {
113
+ const firstLine = stripSwiftLineForSemanticScan(lines[index] ?? '');
114
+ if (!/\bfunc\b/.test(firstLine)) {
115
+ continue;
116
+ }
117
+
118
+ const signatureLines: string[] = [];
119
+ let cursor = index;
120
+ let openingLineIndex = -1;
121
+ for (; cursor < lines.length && cursor < index + 24; cursor += 1) {
122
+ const line = stripSwiftLineForSemanticScan(lines[cursor] ?? '');
123
+ signatureLines.push(line);
124
+ if (line.includes('{')) {
125
+ openingLineIndex = cursor;
126
+ break;
127
+ }
128
+ if (line.includes('}')) {
129
+ break;
130
+ }
131
+ }
132
+
133
+ if (openingLineIndex < 0) {
134
+ continue;
135
+ }
136
+
137
+ const bodyLines: string[] = [];
138
+ let braceDepth = 0;
139
+ for (let bodyCursor = openingLineIndex; bodyCursor < lines.length; bodyCursor += 1) {
140
+ const line = stripSwiftLineForSemanticScan(lines[bodyCursor] ?? '');
141
+ braceDepth += countTokenOccurrences(line, '{');
142
+ braceDepth -= countTokenOccurrences(line, '}');
143
+ bodyLines.push(line);
144
+ if (bodyCursor > openingLineIndex && braceDepth <= 0) {
145
+ cursor = bodyCursor;
146
+ break;
147
+ }
148
+ }
149
+
150
+ functions.push({
151
+ signature: signatureLines.join('\n'),
152
+ body: bodyLines.join('\n'),
153
+ });
154
+ index = cursor;
155
+ }
156
+
157
+ return functions;
158
+ };
159
+
103
160
  const hasSwiftUiModernizationSnapshotMatch = (source: string, entryId: string): boolean => {
104
161
  const entry = getIosSwiftUiModernizationEntry(entryId);
105
162
  if (!entry) {
@@ -855,10 +912,14 @@ const hasSwiftConfirmationUsage = (source: string): boolean => {
855
912
  };
856
913
 
857
914
  export const hasSwiftWaitForExpectationsUsage = (source: string): boolean => {
858
- return hasSwiftSanitizedRegexMatch(
859
- source,
860
- /\bwait\s*\(\s*for\s*:|\bwaitForExpectations\s*\(/
861
- );
915
+ const legacyWaitPattern = /\bwait\s*\(\s*for\s*:|\bwaitForExpectations\s*\(/;
916
+ return collectSwiftFunctionDeclarations(source).some((declaration) => {
917
+ if (!/\basync\b/.test(declaration.signature)) {
918
+ return false;
919
+ }
920
+ legacyWaitPattern.lastIndex = 0;
921
+ return legacyWaitPattern.test(declaration.body);
922
+ });
862
923
  };
863
924
 
864
925
  export const hasSwiftLegacyExpectationDescriptionUsage = (source: string): boolean => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pumuki",
3
- "version": "6.3.158",
3
+ "version": "6.3.159",
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": {