pumuki 6.3.188 → 6.3.189

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/VERSION CHANGED
@@ -1 +1 @@
1
- v6.3.188
1
+ v6.3.189
@@ -10,6 +10,7 @@ import {
10
10
  hasKotlinDispatcherMainBoundaryLeakUsage,
11
11
  hasKotlinGlobalScopeUsage,
12
12
  hasKotlinHardcodedBackgroundDispatcherUsage,
13
+ hasKotlinJUnit4Usage,
13
14
  hasKotlinLiveDataStateExposureUsage,
14
15
  hasKotlinLifecycleScopeUsage,
15
16
  hasKotlinSharedPreferencesUsage,
@@ -275,6 +276,45 @@ class PreferencesStore {
275
276
  assert.equal(hasKotlinSharedPreferencesUsage(source), false);
276
277
  });
277
278
 
279
+ test('hasKotlinJUnit4Usage detecta imports y anotaciones JUnit4 en tests Kotlin Android', () => {
280
+ const importSource = `
281
+ import org.junit.Test
282
+ import org.junit.Assert
283
+
284
+ class OrdersViewModelTest {
285
+ @Test
286
+ fun loadsOrders() {
287
+ Assert.assertEquals(1, 1)
288
+ }
289
+ }
290
+ `;
291
+ const runnerSource = `
292
+ import org.junit.runner.RunWith
293
+
294
+ @RunWith(AndroidJUnit4::class)
295
+ class OrdersInstrumentedTest
296
+ `;
297
+
298
+ assert.equal(hasKotlinJUnit4Usage(importSource), true);
299
+ assert.equal(hasKotlinJUnit4Usage(runnerSource), true);
300
+ });
301
+
302
+ test('hasKotlinJUnit4Usage ignora JUnit5, comentarios y strings', () => {
303
+ const source = `
304
+ import org.junit.jupiter.api.Test
305
+ // import org.junit.Test
306
+ val sample = "Assert.assertEquals(1, 1)"
307
+
308
+ class OrdersViewModelTest {
309
+ @Test
310
+ fun loadsOrders() {
311
+ assertEquals(1, 1)
312
+ }
313
+ }
314
+ `;
315
+ assert.equal(hasKotlinJUnit4Usage(source), false);
316
+ });
317
+
278
318
  test('hasKotlinSupervisorScopeUsage detecta supervisorScope con parentesis y llaves', () => {
279
319
  const parenthesesSource = `
280
320
  class SyncOrdersUseCase {
@@ -271,6 +271,17 @@ export const hasKotlinSharedPreferencesUsage = (source: string): boolean => {
271
271
  return collectKotlinRegexLines(source, /\b(?:SharedPreferences|PreferenceManager\s*\.|getSharedPreferences\s*\()/).length > 0;
272
272
  };
273
273
 
274
+ export const hasKotlinJUnit4Usage = (source: string): boolean => {
275
+ return source.split(/\r?\n/).some((line) => {
276
+ const sanitized = stripKotlinLineForSemanticScan(line);
277
+ return (
278
+ /\bimport\s+org\.junit\.(?:Test|Before|After|BeforeClass|AfterClass|Assert|Rule|ClassRule|runner\.RunWith|rules\.)\b/.test(sanitized) ||
279
+ /@(?:RunWith|Rule|ClassRule)\b/.test(sanitized) ||
280
+ /\bAssert\s*\./.test(sanitized)
281
+ );
282
+ });
283
+ };
284
+
274
285
  export const hasKotlinSupervisorScopeUsage = (source: string): boolean => {
275
286
  return collectKotlinRegexLines(source, /\bsupervisorScope\s*(?:<[^>\n]+>\s*)?(?:\(|\{)/).length > 0;
276
287
  };
@@ -161,6 +161,10 @@ const isKotlinTestPath = (path: string): boolean => {
161
161
  );
162
162
  };
163
163
 
164
+ const isAndroidKotlinTestPath = (path: string): boolean => {
165
+ return isAndroidKotlinPath(path) && isKotlinTestPath(path);
166
+ };
167
+
164
168
  const isExcludedProjectScanPath = (path: string): boolean => {
165
169
  const normalized = path.replace(/\\/g, '/').toLowerCase();
166
170
  return (
@@ -654,6 +658,7 @@ const textDetectorRegistry: ReadonlyArray<TextDetectorRegistryEntry> = [
654
658
  { platform: 'android', pathCheck: isAndroidKotlinPath, excludePaths: [isKotlinTestPath], detect: TextAndroid.hasKotlinRunBlockingUsage, ruleId: 'heuristics.android.run-blocking.ast', code: 'HEURISTICS_ANDROID_RUN_BLOCKING_AST', message: 'AST heuristic detected runBlocking usage in production Kotlin code.' },
655
659
  { platform: 'android', pathCheck: isAndroidLocalPropertiesPath, excludePaths: [], detect: detectsTrackedFilePresence, ruleId: 'heuristics.android.security.local-properties-tracked.ast', code: 'HEURISTICS_ANDROID_SECURITY_LOCAL_PROPERTIES_TRACKED_AST', message: 'AST heuristic detected tracked Android local.properties file.' },
656
660
  { platform: 'android', pathCheck: isAndroidKotlinPath, excludePaths: [isKotlinTestPath], detect: TextAndroid.hasKotlinSharedPreferencesUsage, ruleId: 'heuristics.android.persistence.shared-preferences-usage.ast', code: 'HEURISTICS_ANDROID_PERSISTENCE_SHARED_PREFERENCES_USAGE_AST', message: 'AST heuristic detected SharedPreferences usage in Android production Kotlin code.' },
661
+ { platform: 'android', pathCheck: isAndroidKotlinTestPath, excludePaths: [], detect: TextAndroid.hasKotlinJUnit4Usage, ruleId: 'heuristics.android.testing.junit4-usage.ast', code: 'HEURISTICS_ANDROID_TESTING_JUNIT4_USAGE_AST', message: 'AST heuristic detected JUnit4 usage in Android Kotlin tests where JUnit5 is preferred.' },
657
662
  { platform: 'android', pathCheck: isAndroidPresentationPath, excludePaths: [isKotlinTestPath], detect: TextAndroid.hasKotlinLiveDataStateExposureUsage, ruleId: 'heuristics.android.flow.livedata-state-exposure.ast', code: 'HEURISTICS_ANDROID_FLOW_LIVEDATA_STATE_EXPOSURE_AST', message: 'AST heuristic detected LiveData state exposure in Android presentation code where StateFlow or SharedFlow should be preferred.' },
658
663
  { platform: 'android', pathCheck: isAndroidPresentationPath, excludePaths: [isKotlinTestPath], detect: TextAndroid.hasKotlinManualCoroutineScopeInViewModelUsage, ruleId: 'heuristics.android.coroutines.manual-scope-in-viewmodel.ast', code: 'HEURISTICS_ANDROID_COROUTINES_MANUAL_SCOPE_IN_VIEWMODEL_AST', message: 'AST heuristic detected manual CoroutineScope inside an Android ViewModel where viewModelScope should be preferred.' },
659
664
  { platform: 'android', pathCheck: isAndroidNonPresentationKotlinPath, excludePaths: [isKotlinTestPath], detect: TextAndroid.hasKotlinDispatcherMainBoundaryLeakUsage, ruleId: 'heuristics.android.coroutines.dispatchers-main-boundary-leak.ast', code: 'HEURISTICS_ANDROID_COROUTINES_DISPATCHERS_MAIN_BOUNDARY_LEAK_AST', message: 'AST heuristic detected Dispatchers.Main outside Android presentation code.' },
@@ -3,7 +3,7 @@ import test from 'node:test';
3
3
  import { androidRules } from './android';
4
4
 
5
5
  test('androidRules define reglas heurísticas locked para plataforma android', () => {
6
- assert.equal(androidRules.length, 18);
6
+ assert.equal(androidRules.length, 19);
7
7
 
8
8
  const ids = androidRules.map((rule) => rule.id);
9
9
  assert.deepEqual(ids, [
@@ -13,6 +13,7 @@ test('androidRules define reglas heurísticas locked para plataforma android', (
13
13
  'heuristics.android.flow.livedata-state-exposure.ast',
14
14
  'heuristics.android.security.local-properties-tracked.ast',
15
15
  'heuristics.android.persistence.shared-preferences-usage.ast',
16
+ 'heuristics.android.testing.junit4-usage.ast',
16
17
  'heuristics.android.coroutines.manual-scope-in-viewmodel.ast',
17
18
  'heuristics.android.coroutines.dispatchers-main-boundary-leak.ast',
18
19
  'heuristics.android.coroutines.hardcoded-background-dispatcher.ast',
@@ -62,6 +63,10 @@ test('androidRules define reglas heurísticas locked para plataforma android', (
62
63
  byId.get('heuristics.android.persistence.shared-preferences-usage.ast')?.then.code,
63
64
  'HEURISTICS_ANDROID_PERSISTENCE_SHARED_PREFERENCES_USAGE_AST'
64
65
  );
66
+ assert.equal(
67
+ byId.get('heuristics.android.testing.junit4-usage.ast')?.then.code,
68
+ 'HEURISTICS_ANDROID_TESTING_JUNIT4_USAGE_AST'
69
+ );
65
70
  assert.equal(
66
71
  byId.get('heuristics.android.coroutines.manual-scope-in-viewmodel.ast')?.then.code,
67
72
  'HEURISTICS_ANDROID_COROUTINES_MANUAL_SCOPE_IN_VIEWMODEL_AST'
@@ -115,6 +115,26 @@ export const androidRules: RuleSet = [
115
115
  code: 'HEURISTICS_ANDROID_PERSISTENCE_SHARED_PREFERENCES_USAGE_AST',
116
116
  },
117
117
  },
118
+ {
119
+ id: 'heuristics.android.testing.junit4-usage.ast',
120
+ description:
121
+ 'Detects JUnit4 usage in Android Kotlin tests where JUnit5 is preferred.',
122
+ severity: 'WARN',
123
+ platform: 'android',
124
+ locked: true,
125
+ when: {
126
+ kind: 'Heuristic',
127
+ where: {
128
+ ruleId: 'heuristics.android.testing.junit4-usage.ast',
129
+ },
130
+ },
131
+ then: {
132
+ kind: 'Finding',
133
+ message:
134
+ 'AST heuristic detected JUnit4 usage in Android Kotlin tests.',
135
+ code: 'HEURISTICS_ANDROID_TESTING_JUNIT4_USAGE_AST',
136
+ },
137
+ },
118
138
  {
119
139
  id: 'heuristics.android.coroutines.manual-scope-in-viewmodel.ast',
120
140
  description:
@@ -146,6 +146,11 @@ app/
146
146
  ✅ Este baseline no obliga a que todo ViewModel use Flow; solo detecta una alternativa legacy concreta cuando aparece en código de presentación Android.
147
147
  ✅ `Flow`, `collectAsState`, `stateIn`, Room observable queries y SharedFlow events quedan fuera hasta que tengan detectores propios y regresiones dirigidas.
148
148
 
149
+ ### Enforcement AST inicial de testing Android
150
+ ✅ `skills.android.guideline.android.junit5-framework-de-testing-preferido-sobre-junit4` debe mapear a señal ejecutable de uso JUnit4 en tests Kotlin Android.
151
+ ✅ Este baseline detecta imports/anotaciones JUnit4 (`org.junit.Test`, `org.junit.Assert`, `@RunWith`, reglas JUnit4) bajo `apps/android/**/test/**` y `apps/android/**/androidTest/**`.
152
+ ✅ JUnit5/Jupiter queda preservado como caso limpio; migración completa de runner, Gradle y APIs de assertions queda fuera hasta tener detectores propios.
153
+
149
154
  ### Dependency Injection (Hilt):
150
155
  ✅ **Hilt** - DI framework (NO manual factories)
151
156
  ✅ **@HiltAndroidApp** - Application class
@@ -255,6 +255,10 @@ const registryByRuleId: Record<string, SkillsDetectorBinding> = {
255
255
  'android.persistence.shared-preferences',
256
256
  ['heuristics.android.persistence.shared-preferences-usage.ast']
257
257
  ),
258
+ 'skills.android.guideline.android.junit5-framework-de-testing-preferido-sobre-junit4': heuristicDetector(
259
+ 'android.testing.junit4-usage',
260
+ ['heuristics.android.testing.junit4-usage.ast']
261
+ ),
258
262
  'skills.android.guideline.android.stateflow-estado-mutable-observable': heuristicDetector(
259
263
  'android.flow.state-exposure',
260
264
  ['heuristics.android.flow.livedata-state-exposure.ast']
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pumuki",
3
- "version": "6.3.188",
3
+ "version": "6.3.189",
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-12T21:13:45.516Z",
4
+ "generatedAt": "2026-05-12T21:22:02.797Z",
5
5
  "bundles": [
6
6
  {
7
7
  "name": "android-guidelines",