pumuki 6.3.224 → 6.3.225

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.
@@ -36,6 +36,7 @@ import {
36
36
  hasSwiftLegacyXCTestImportUsage,
37
37
  hasSwiftModernizableXCTestSuiteUsage,
38
38
  hasSwiftNonLazyScrollForEachUsage,
39
+ hasSwiftViewBodyObjectCreationUsage,
39
40
  hasSwiftAssumeIsolatedUsage,
40
41
  hasSwiftCoreDataLayerLeakUsage,
41
42
  hasSwiftSwiftDataLayerLeakUsage,
@@ -162,6 +163,34 @@ struct FeedView: View {
162
163
  assert.equal(hasSwiftNonLazyScrollForEachUsage(safe), false);
163
164
  });
164
165
 
166
+ test('hasSwiftViewBodyObjectCreationUsage detecta formatter creado en body y preserva dependencia externa', () => {
167
+ const source = `
168
+ struct PriceView: View {
169
+ let amount: Decimal
170
+
171
+ var body: some View {
172
+ let formatter = NumberFormatter()
173
+ Text(formatter.string(from: amount as NSDecimalNumber) ?? "")
174
+ }
175
+ }
176
+ `;
177
+ const safe = `
178
+ struct PriceView: View {
179
+ let formatter: NumberFormatter
180
+ let amount: Decimal
181
+
182
+ var body: some View {
183
+ Text(formatter.string(from: amount as NSDecimalNumber) ?? "")
184
+ let sample = "var body: some View { NumberFormatter() }"
185
+ // var body: some View { NumberFormatter() }
186
+ }
187
+ }
188
+ `;
189
+
190
+ assert.equal(hasSwiftViewBodyObjectCreationUsage(source), true);
191
+ assert.equal(hasSwiftViewBodyObjectCreationUsage(safe), false);
192
+ });
193
+
165
194
  test('hasSwiftForceTryUsage detecta try! y descarta try?', () => {
166
195
  const positive = `
167
196
  func load() {
@@ -388,6 +388,14 @@ export const hasSwiftNonLazyScrollForEachUsage = (source: string): boolean => {
388
388
  return nonLazyScrollableCollectionPattern.test(swiftSource);
389
389
  };
390
390
 
391
+ export const hasSwiftViewBodyObjectCreationUsage = (source: string): boolean => {
392
+ const swiftSource = sanitizeSwiftSourceForMultilineRegex(source);
393
+ const viewBodyObjectCreationPattern =
394
+ /\bvar\s+body\s*:\s*some\s+View\s*\{[\s\S]{0,2400}\b(?:DateFormatter|NumberFormatter|RelativeDateTimeFormatter|ISO8601DateFormatter|ByteCountFormatter|MeasurementFormatter|DateComponentsFormatter)\s*\(/;
395
+
396
+ return viewBodyObjectCreationPattern.test(swiftSource);
397
+ };
398
+
391
399
  export const hasSwiftDispatchQueueUsage = (source: string): boolean => {
392
400
  return scanCodeLikeSource(source, ({ source: swiftSource, index, current }) => {
393
401
  if (current !== 'D' || !hasIdentifierAt(swiftSource, index, 'DispatchQueue')) {
@@ -686,6 +686,7 @@ const textDetectorRegistry: ReadonlyArray<TextDetectorRegistryEntry> = [
686
686
  { platform: 'ios', pathCheck: isIOSPresentationPath, excludePaths: [isSwiftTestPath], detect: TextIOS.hasSwiftClosureBasedViewBuilderContentUsage, ruleId: 'heuristics.ios.swiftui.closure-based-viewbuilder-content.ast', code: 'HEURISTICS_IOS_SWIFTUI_CLOSURE_BASED_VIEWBUILDER_CONTENT_AST', message: 'AST heuristic detected closure-based content storage; @ViewBuilder let content: Content remains the preferred SwiftUI container baseline.' },
687
687
  { platform: 'ios', pathCheck: isIOSPresentationPath, excludePaths: [isSwiftTestPath], detect: TextIOS.hasSwiftRedundantReactiveStateAssignmentUsage, ruleId: 'heuristics.ios.swiftui.redundant-reactive-state-assignment.ast', code: 'HEURISTICS_IOS_SWIFTUI_REDUNDANT_REACTIVE_STATE_ASSIGNMENT_AST', message: 'AST heuristic detected reactive state assignment without a value-change guard; check for value changes before assigning state in hot paths.' },
688
688
  { platform: 'ios', pathCheck: isIOSPresentationPath, excludePaths: [isSwiftTestPath], detect: TextIOS.hasSwiftNonLazyScrollForEachUsage, ruleId: 'heuristics.ios.swiftui.non-lazy-scroll-foreach.ast', code: 'HEURISTICS_IOS_SWIFTUI_NON_LAZY_SCROLL_FOREACH_AST', message: 'AST heuristic detected ScrollView with a non-lazy stack feeding ForEach; LazyVStack/LazyHStack remain the preferred baseline for large scrollable collections.' },
689
+ { platform: 'ios', pathCheck: isIOSPresentationPath, excludePaths: [isSwiftTestPath], detect: TextIOS.hasSwiftViewBodyObjectCreationUsage, ruleId: 'heuristics.ios.swiftui.body-object-creation.ast', code: 'HEURISTICS_IOS_SWIFTUI_BODY_OBJECT_CREATION_AST', message: 'AST heuristic detected formatter object creation inside SwiftUI body; keep body simple and move expensive objects out of render paths.' },
689
690
  { platform: 'ios', pathCheck: isIOSSwiftPath, excludePaths: [isSwiftTestPath], detect: TextIOS.hasSwiftNavigationViewUsage, ruleId: 'heuristics.ios.navigation-view.ast', code: 'HEURISTICS_IOS_NAVIGATION_VIEW_AST', message: 'AST heuristic detected NavigationView usage.' },
690
691
  { platform: 'ios', pathCheck: isIOSSwiftPath, excludePaths: [isSwiftTestPath], detect: TextIOS.hasSwiftForegroundColorUsage, ruleId: 'heuristics.ios.foreground-color.ast', code: 'HEURISTICS_IOS_FOREGROUND_COLOR_AST', message: 'AST heuristic detected foregroundColor usage.' },
691
692
  { platform: 'ios', pathCheck: isIOSSwiftPath, excludePaths: [isSwiftTestPath], detect: TextIOS.hasSwiftCornerRadiusUsage, ruleId: 'heuristics.ios.corner-radius.ast', code: 'HEURISTICS_IOS_CORNER_RADIUS_AST', message: 'AST heuristic detected cornerRadius usage.' },
@@ -930,6 +930,25 @@ export const iosRules: RuleSet = [
930
930
  code: 'HEURISTICS_IOS_SWIFTUI_NON_LAZY_SCROLL_FOREACH_AST',
931
931
  },
932
932
  },
933
+ {
934
+ id: 'heuristics.ios.swiftui.body-object-creation.ast',
935
+ description: 'Detects expensive formatter object creation inside SwiftUI body.',
936
+ severity: 'WARN',
937
+ platform: 'ios',
938
+ locked: true,
939
+ when: {
940
+ kind: 'Heuristic',
941
+ where: {
942
+ ruleId: 'heuristics.ios.swiftui.body-object-creation.ast',
943
+ },
944
+ },
945
+ then: {
946
+ kind: 'Finding',
947
+ message:
948
+ 'AST heuristic detected formatter object creation inside SwiftUI body; keep body simple and move expensive objects out of render paths.',
949
+ code: 'HEURISTICS_IOS_SWIFTUI_BODY_OBJECT_CREATION_AST',
950
+ },
951
+ },
933
952
  {
934
953
  id: 'heuristics.ios.navigation-view.ast',
935
954
  description: 'Detects NavigationView usage in iOS production code.',
@@ -258,6 +258,10 @@ const registryByRuleId: Record<string, SkillsDetectorBinding> = {
258
258
  heuristicDetector('ios.swiftui.non-lazy-scroll-foreach', [
259
259
  'heuristics.ios.swiftui.non-lazy-scroll-foreach.ast',
260
260
  ]),
261
+ 'skills.ios.guideline.ios-swiftui-expert.no-object-creation-in-body':
262
+ heuristicDetector('ios.swiftui.body-object-creation', [
263
+ 'heuristics.ios.swiftui.body-object-creation.ast',
264
+ ]),
261
265
  'skills.ios.no-scrollview-shows-indicators': heuristicDetector(
262
266
  'ios.scrollview-shows-indicators',
263
267
  ['heuristics.ios.scrollview-shows-indicators.ast']
@@ -367,6 +367,13 @@ const normalizeKnownRuleTarget = (
367
367
  ) {
368
368
  return 'skills.ios.guideline.ios-swiftui-expert.use-lazyvstack-lazyhstack-for-large-lists';
369
369
  }
370
+ if (
371
+ includes('no object creation in body') ||
372
+ (includes('object creation') && includes('body')) ||
373
+ (includes('body kept simple') && includes('pure'))
374
+ ) {
375
+ return 'skills.ios.guideline.ios-swiftui-expert.no-object-creation-in-body';
376
+ }
370
377
  if (
371
378
  includes('scrollindicators hidden') ||
372
379
  includes('scroll indicators hidden') ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pumuki",
3
- "version": "6.3.224",
3
+ "version": "6.3.225",
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": {
package/skills.lock.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": "1.0",
3
3
  "compilerVersion": "1.0.0",
4
- "generatedAt": "2026-05-13T16:15:52.668Z",
4
+ "generatedAt": "2026-05-13T16:19:49.576Z",
5
5
  "bundles": [
6
6
  {
7
7
  "name": "android-guidelines",