authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-06-03 23:13:01-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-06-03 23:13:01-07:00
log80b40ce96a50ccf07a2b64991419c01c01e67f53
tree1f7db380cf4300b02373a6c72d6918a6dc269087
parent4c262c4b4e4b63977872454f33bd49a7e40e745a
signature Signed by PGP key B5690EEEBB952194

[codex] fix mobile native static analysis source discovery (#2942)

Co-authored-by: Julius Marminge <julius@mac.lan>

1 files changed, 15 insertions(+), 8 deletions(-)

scripts/mobile-native-static-check.ts+15-8
...@@ -40,14 +40,13 @@ const sourceExtensions = new Set([".swift", ".kt", ".kts"]);...@@ -40,14 +40,13 @@ const sourceExtensions = new Set([".swift", ".kt", ".kts"]);
40const excludedDirectories = new Set([40const excludedDirectories = new Set([
41 ".expo",41 ".expo",
42 ".git",42 ".git",
43 "android",
44 "build",43 "build",
45 "DerivedData",44 "DerivedData",
46 "ios",
47 "node_modules",45 "node_modules",
48 "Pods",46 "Pods",
49 "Vendor",47 "Vendor",
50]);48]);
49const generatedNativeProjectDirectories = new Set(["android", "ios"]);
5150
52const appRoot = Effect.service(Path.Path).pipe(51const appRoot = Effect.service(Path.Path).pipe(
53 Effect.flatMap((path) => path.fromFileUrl(new URL("../apps/mobile", import.meta.url))),52 Effect.flatMap((path) => path.fromFileUrl(new URL("../apps/mobile", import.meta.url))),
...@@ -108,6 +107,7 @@ const runCommand = Effect.fn("runCommand")(function* (...@@ -108,6 +107,7 @@ const runCommand = Effect.fn("runCommand")(function* (
108107
109function collectSources(108function collectSources(
110 directory: string,109 directory: string,
110 root: string,
111): Effect.Effect<111): Effect.Effect<
112 ReadonlyArray<string>,112 ReadonlyArray<string>,
113 PlatformError.PlatformError,113 PlatformError.PlatformError,
...@@ -120,15 +120,18 @@ function collectSources(...@@ -120,15 +120,18 @@ function collectSources(
120 const sources: Array<string> = [];120 const sources: Array<string> = [];
121121
122 for (const entry of entries) {122 for (const entry of entries) {
123 if (excludedDirectories.has(entry)) {
124 continue;
125 }
126
127 const entryPath = path.join(directory, entry);123 const entryPath = path.join(directory, entry);
128 const stat = yield* fs.stat(entryPath);124 const stat = yield* fs.stat(entryPath);
129125
130 if (stat.type === "Directory") {126 if (stat.type === "Directory") {
131 sources.push(...(yield* collectSources(entryPath)));127 const isGeneratedNativeProjectDirectory =
128 directory === root && generatedNativeProjectDirectories.has(entry);
129
130 if (excludedDirectories.has(entry) || isGeneratedNativeProjectDirectory) {
131 continue;
132 }
133
134 sources.push(...(yield* collectSources(entryPath, root)));
132 continue;135 continue;
133 }136 }
134137
...@@ -144,7 +147,7 @@ function collectSources(...@@ -144,7 +147,7 @@ function collectSources(
144const runNativeStaticChecks = Effect.fn("runNativeStaticChecks")(function* () {147const runNativeStaticChecks = Effect.fn("runNativeStaticChecks")(function* () {
145 const path = yield* Path.Path;148 const path = yield* Path.Path;
146 const root = yield* appRoot;149 const root = yield* appRoot;
147 const sources = yield* collectSources(root);150 const sources = yield* collectSources(root, root);
148 const swiftSources = sources.filter((source) => path.extname(source) === ".swift");151 const swiftSources = sources.filter((source) => path.extname(source) === ".swift");
149 const kotlinSources = sources.filter((source) => {152 const kotlinSources = sources.filter((source) => {
150 const extension = path.extname(source);153 const extension = path.extname(source);
...@@ -156,6 +159,10 @@ const runNativeStaticChecks = Effect.fn("runNativeStaticChecks")(function* () {...@@ -156,6 +159,10 @@ const runNativeStaticChecks = Effect.fn("runNativeStaticChecks")(function* () {
156 availableTools.set(tool.command, yield* commandExists(tool.command));159 availableTools.set(tool.command, yield* commandExists(tool.command));
157 }160 }
158161
162 yield* Console.log(
163 `Found ${swiftSources.length} Swift and ${kotlinSources.length} Kotlin native source files.`,
164 );
165
159 if (swiftSources.length > 0) {166 if (swiftSources.length > 0) {
160 if (availableTools.get("swiftlint")) {167 if (availableTools.get("swiftlint")) {
161 yield* runCommand("swiftlint", ["lint", "--config", ".swiftlint.yml", "--strict"], root);168 yield* runCommand("swiftlint", ["lint", "--config", ".swiftlint.yml", "--strict"], root);