From 098b1b3bc7774aa0f9e6a4facf641c3d6e793e68 Mon Sep 17 00:00:00 2001 From: "fizzy-linux[bot]" <346940526+fizzy-linux[bot]@users.noreply.github.com> Date: Sat, 24 Oct 2026 07:57:09 -0500 Subject: [PATCH 1/3] lint: line-length (codex) Agent-Team: linux Worker: codex --- scripts/demos.zig | 22 ++++++++++++-- scripts/lint.zig | 60 ++++++++++++++++++++++++++++++--------- scripts/tests_reached.zig | 6 +++- 3 files changed, 70 insertions(+), 18 deletions(-) diff --git a/scripts/demos.zig b/scripts/demos.zig index 59bfb9ffd..b6b821731 100644 --- a/scripts/demos.zig +++ b/scripts/demos.zig @@ -83,19 +83,35 @@ pub fn main(init: std.process.Init) !void { /// Write `t` as `.tape` in `out`, having read it back from those bytes. The row is `arena`'s: /// the tape goes before the index is written. -fn emit(arena: std.mem.Allocator, gpa: std.mem.Allocator, io: std.Io, out: std.Io.Dir, rows: []const Row, name: []const u8, t: Tape, live: bool) !Row { +fn emit( + arena: std.mem.Allocator, + gpa: std.mem.Allocator, + io: std.Io, + out: std.Io.Dir, + rows: []const Row, + name: []const u8, + t: Tape, + live: bool, +) !Row { for (rows) |r| if (std.mem.eql(u8, r.name, name)) return fail("two tapes are named '{s}'", .{name}); var bytes: std.Io.Writer.Allocating = .init(arena); try tape.binary.write(gpa, t, &bytes.writer, .{ .deflate = true }); var c = check; c.live = live; - var back = tape.binary.read(gpa, bytes.written(), c) catch |err| return fail("{s}: its tape does not read back: {t}", .{ name, err }); + var back = tape.binary.read(gpa, bytes.written(), c) catch |err| + return fail("{s}: its tape does not read back: {t}", .{ name, err }); defer back.deinit(); if (back.tape.ops.len != t.ops.len or back.tape.duration() != t.duration()) return fail("{s}: its tape reads back as another", .{name}); const file = try arena.print("{s}.tape", .{name}); try out.writeFile(io, .{ .sub_path = file, .data = bytes.written() }); - return .{ .name = try arena.dupe(u8, name), .title = try arena.dupe(u8, t.title), .file = file, .ms = t.duration(), .live = live }; + return .{ + .name = try arena.dupe(u8, name), + .title = try arena.dupe(u8, t.title), + .file = file, + .ms = t.duration(), + .live = live, + }; } fn fail(comptime fmt: []const u8, args: anytype) error{DemoFailed} { diff --git a/scripts/lint.zig b/scripts/lint.zig index 2cc3087b4..10ef9af94 100644 --- a/scripts/lint.zig +++ b/scripts/lint.zig @@ -1,7 +1,14 @@ //! Repository lint with per-file budgets for existing findings. const std = @import("std"); -const Rule = enum { @"fn-length", @"create-needs-destroy", @"lint-allow-reason", @"file-alias", anyerror, @"deprecated-names-replacement" }; +const Rule = enum { + @"fn-length", + @"create-needs-destroy", + @"lint-allow-reason", + @"file-alias", + anyerror, + @"deprecated-names-replacement", +}; const Finding = struct { rule: Rule, line: usize, message: []const u8 }; const Allow = struct { rule: Rule, file: []const u8, count: usize }; const Suppression = struct { rule: []const u8, line: usize }; @@ -60,7 +67,10 @@ pub fn main(init: std.process.Init) !void { } } for (parsed, seen) |allow, visited| if (!visited) { - try output.writer.print("{s}:1: {s}: file not found; remove its allowance of {d}\n", .{ allow.file, @tagName(allow.rule), allow.count }); + try output.writer.print( + "{s}:1: {s}: file not found; remove its allowance of {d}\n", + .{ allow.file, @tagName(allow.rule), allow.count }, + ); failed = true; }; std.debug.print("{s}", .{output.written()}); @@ -98,11 +108,17 @@ fn reportFile( } switch (status) { .over => { - try writer.print("{s}:1: {s}: count {d} exceeds allowance {d}\n", .{ path, @tagName(rule), count, budget }); + try writer.print( + "{s}:1: {s}: count {d} exceeds allowance {d}\n", + .{ path, @tagName(rule), count, budget }, + ); failed = true; }, .under => { - try writer.print("{s}:1: {s}: count {d} is under allowance {d}; lower the allowance to {d}\n", .{ path, @tagName(rule), count, budget, count }); + try writer.print( + "{s}:1: {s}: count {d} is under allowance {d}; lower the allowance to {d}\n", + .{ path, @tagName(rule), count, budget, count }, + ); failed = true; }, .equal => {}, @@ -135,7 +151,11 @@ fn analyze(allocator: std.mem.Allocator, source: [:0]const u8) ![]Finding { const close = std.mem.findScalar(u8, text, ')') orelse text.len; const tail = if (close < text.len) std.mem.trim(u8, text[close + 1 ..], " \t\r") else ""; if (tail.len < 2 or tail[0] != ':' or std.mem.trim(u8, tail[1..], " \t\r").len == 0) { - try findings.append(allocator, .{ .rule = .@"lint-allow-reason", .line = line_number, .message = "lint-allow requires a reason after ':'" }); + try findings.append(allocator, .{ + .rule = .@"lint-allow-reason", + .line = line_number, + .message = "lint-allow requires a reason after ':'", + }); } else { try suppressions.append(allocator, .{ .rule = text[prefix.len..close], .line = line_number }); } @@ -175,7 +195,11 @@ fn analyze(allocator: std.mem.Allocator, source: [:0]const u8) ![]Finding { const end = tree.tokenLocation(0, tree.lastToken(node)).line + 1; const length = end - line + 1; if (length > 150 and !silenced(suppressions.items, .@"fn-length", line)) { - try findings.append(allocator, .{ .rule = .@"fn-length", .line = line, .message = try allocator.print("function {s} is {d} lines (limit 150)", .{ name, length }) }); + try findings.append(allocator, .{ + .rule = .@"fn-length", + .line = line, + .message = try allocator.print("function {s} is {d} lines (limit 150)", .{ name, length }), + }); } } if (create_line != null and !has_destroy) try findings.append(allocator, .{ @@ -264,11 +288,12 @@ fn deprecatedReplacement(allocator: std.mem.Allocator, source: [:0]const u8, pat } } const line = std.mem.count(u8, source[0..token.loc.start], "\n") + 1; - if (!replacement and !silenced(suppressions.items, .@"deprecated-names-replacement", line)) try findings.append(allocator, .{ - .rule = .@"deprecated-names-replacement", - .line = line, - .message = "Deprecated marker must name a backticked replacement", - }); + if (!replacement and !silenced(suppressions.items, .@"deprecated-names-replacement", line)) + try findings.append(allocator, .{ + .rule = .@"deprecated-names-replacement", + .line = line, + .message = "Deprecated marker must name a backticked replacement", + }); } return findings.toOwnedSlice(allocator); } @@ -535,14 +560,18 @@ test "SDK deprecated markers name a backticked replacement" { "const text = \"/// Deprecated\";", "/// DeprecatedThing is an identifier.\npub const old = 1;", "/// Foo\n/// Deprecated, see below\npub const old = 1;", - }) |source| try std.testing.expectEqual(@as(usize, 0), (try deprecatedReplacement(a, source, "sdk/src/old.zig")).len); + }) |source| try std.testing.expectEqual( + @as(usize, 0), + (try deprecatedReplacement(a, source, "sdk/src/old.zig")).len, + ); } test "deprecated marker honors lint-allow suppression and a file budget" { var arena = std.heap.ArenaAllocator.init(std.testing.allocator); defer arena.deinit(); const a = arena.allocator(); - const suppressed = "// lint-allow(deprecated-names-replacement): removed with the next SDK\n/// Deprecated\npub const old = 1;"; + const suppressed = "// lint-allow(deprecated-names-replacement): removed with the next SDK\n" ++ + "/// Deprecated\npub const old = 1;"; try std.testing.expectEqual(@as(usize, 0), (try deprecatedReplacement(a, suppressed, "sdk/src/old.zig")).len); const inside_doc = "/// Deprecated // lint-allow(deprecated-names-replacement): not a comment\npub const old = 1;"; try std.testing.expectEqual(@as(usize, 1), (try deprecatedReplacement(a, inside_doc, "sdk/src/old.zig")).len); @@ -553,7 +582,10 @@ test "deprecated marker honors lint-allow suppression and a file budget" { for ([_][:0]const u8{ "// lint-allow(anyerror): wrong rule\n/// Deprecated\npub const old = 1;", "// lint-allow(deprecated-names-replacement): too far\n\n/// Deprecated\npub const old = 1;", - }) |source| try std.testing.expectEqual(@as(usize, 1), (try deprecatedReplacement(a, source, "sdk/src/old.zig")).len); + }) |source| try std.testing.expectEqual( + @as(usize, 1), + (try deprecatedReplacement(a, source, "sdk/src/old.zig")).len, + ); const hit = try deprecatedReplacement(a, "/// Deprecated\npub const old = 1;", "sdk/src/old.zig"); const allowances = [_]Allow{ diff --git a/scripts/tests_reached.zig b/scripts/tests_reached.zig index 936257f51..34017de5d 100644 --- a/scripts/tests_reached.zig +++ b/scripts/tests_reached.zig @@ -72,7 +72,11 @@ pub fn main(init: std.process.Init) !void { const name = testName(arena, line) orelse continue; file_tests += 1; if (reached(arena, binaries.items, abs, name)) continue; - if (missing == 0) std.debug.print("Tests no test binary compiles (none of `zig build test` / `test-integration` reaches the file):\n", .{}); + if (missing == 0) std.debug.print( + "Tests no test binary compiles " ++ + "(none of `zig build test` / `test-integration` reaches the file):\n", + .{}, + ); std.debug.print(" {s}: {s} \"{s}\"\n", .{ rel, name.kind, name.name }); missing += 1; } From acea9acedec6a9d494bd257d7365ad8325282cf4 Mon Sep 17 00:00:00 2001 From: "fizzy-linux[bot]" <346940526+fizzy-linux[bot]@users.noreply.github.com> Date: Sun, 25 Oct 2026 03:28:04 -0500 Subject: [PATCH 2/3] lint: line-length (codex) Agent-Team: linux Worker: codex --- scripts/lint.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/lint.zig b/scripts/lint.zig index 06e06fc5b..87549125d 100644 --- a/scripts/lint.zig +++ b/scripts/lint.zig @@ -745,14 +745,17 @@ test "changelog words report hits, honor line allows, and never fail the runner" "const s =\n \\\\// now fixed\n;", "// Unknown prefix and renewed storage.\nconst n = 1;", }) |source| try std.testing.expectEqual(@as(usize, 0), (try analyze(a, source)).len); - for ([_][]const u8{ "fixed", "NOW", "used to", "previously", "formerly", "no longer", "New:", "new:behavior" }) |word| { + for ([_][]const u8{ + "fixed", "NOW", "used to", "previously", "formerly", "no longer", "New:", "new:behavior", + }) |word| { const source = try a.printSentinel("//! {s} works.\n", .{word}, 0); try std.testing.expectEqual(@as(usize, 1), (try analyze(a, source)).len); } var output: std.Io.Writer.Allocating = .init(a); try std.testing.expect(!try reportFile(&output.writer, "hit.zig", hit, &.{}, &.{}, false)); try std.testing.expectEqualStrings( - "hit.zig:1: changelog-words: comment contains 'previously': Previously used a different buffer. (report-only)\n", + "hit.zig:1: changelog-words: comment contains 'previously': " ++ + "Previously used a different buffer. (report-only)\n", output.written(), ); } From bc3d8651f1132d94a7659d3b98cb83baad95468e Mon Sep 17 00:00:00 2001 From: "fizzy-linux[bot]" <346940526+fizzy-linux[bot]@users.noreply.github.com> Date: Sun, 25 Oct 2026 07:00:56 -0500 Subject: [PATCH 3/3] lint: line-length (codex) Agent-Team: linux Worker: codex --- build.zig | 99 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 84 insertions(+), 15 deletions(-) diff --git a/build.zig b/build.zig index fa9ff2827..7af90062b 100644 --- a/build.zig +++ b/build.zig @@ -23,23 +23,55 @@ pub fn build(b: *std.Build) !void { run_lint.has_side_effects = true; b.step("lint", "Check Zig source against lint budgets").dependOn(&run_lint.step); - const windows_msvc_libc_opt = b.option([]const u8, "windows-msvc-libc", "zig libc manifest for *-windows-msvc when cross-compiling; forwarded by packageall for Windows children") orelse null; - const fetch_msvc_opt = b.option(bool, "fetch-msvc", "If *-windows-msvc libc is missing under .velopack-msvc/, run msvcup-setup first (downloads MSVC+SDK; requires network). Defaults to true on Windows hosts targeting *-windows-msvc.") orelse null; + const windows_msvc_libc_opt = b.option( + []const u8, + "windows-msvc-libc", + "zig libc manifest for *-windows-msvc when cross-compiling; forwarded by " ++ + "packageall for Windows children", + ) orelse null; + const fetch_msvc_opt = b.option( + bool, + "fetch-msvc", + "If *-windows-msvc libc is missing under .velopack-msvc/, run msvcup-setup " ++ + "first (downloads MSVC+SDK; requires network). Defaults to true on Windows " ++ + "hosts targeting *-windows-msvc.", + ) orelse null; // Options only, never the environment: Zig 0.17 caches the build's configuration without // regard to it, so a variable read here would be seen once and then ignored. // `scripts/release.sh` and `release.yml` turn the FIZZY_MACOS_* variables into these. - const macos_sign_app_identity = b.option([]const u8, "macos-sign-app", "macOS codesign identity for the app bundle (e.g. 'Developer ID Application: NAME (TEAMID)')"); - const macos_sign_install_identity = b.option([]const u8, "macos-sign-installer", "macOS codesign identity for the installer pkg (e.g. 'Developer ID Installer: NAME (TEAMID)')"); - const macos_notary_profile = b.option([]const u8, "macos-notary-profile", "notarytool keychain profile name (run `xcrun notarytool store-credentials ` first)"); - const macos_sdk = b.option([]const u8, "macos-sdk", "macOS SDK path for an explicit -Dtarget=*-macos (default: `xcrun --sdk macosx --show-sdk-path`)"); + const macos_sign_app_identity = b.option( + []const u8, + "macos-sign-app", + "macOS codesign identity for the app bundle (e.g. 'Developer ID " ++ + "Application: NAME (TEAMID)')", + ); + const macos_sign_install_identity = b.option( + []const u8, + "macos-sign-installer", + "macOS codesign identity for the installer pkg (e.g. 'Developer ID " ++ + "Installer: NAME (TEAMID)')", + ); + const macos_notary_profile = b.option( + []const u8, + "macos-notary-profile", + "notarytool keychain profile name (run `xcrun notarytool store-credentials " ++ + "` first)", + ); + const macos_sdk = b.option( + []const u8, + "macos-sdk", + "macOS SDK path for an explicit -Dtarget=*-macos (default: `xcrun --sdk " ++ + "macosx --show-sdk-path`)", + ); // Windows 10 1803 at least: AF_UNIX arrived there, and std offers it only to a target whose // minimum is that (`std.Io.net.has_unix_sockets`) — the control server's socket // (`app/control/Server.zig`). Every Windows still supported by Microsoft is newer. const target = target: { const asked = b.standardTargetOptions(.{}); - if (asked.result.os.tag != .windows or asked.result.os.isAtLeast(.windows, .win10_rs4) == true) break :target asked; + if (asked.result.os.tag != .windows or + asked.result.os.isAtLeast(.windows, .win10_rs4) == true) break :target asked; if (asked.result.os.version_range.windows.max.isAtLeast(.win10_rs4) != true) std.debug.panic("fizzy needs Windows 10 1803 (win10_rs4) or newer; -Dtarget asks for an older range", .{}); var query = asked.query; @@ -84,7 +116,13 @@ pub fn build(b: *std.Build) !void { // `defer-app` here and calls `buildApp` below with its plugin modules instead. const app = @import("build/app.zig"); const cfg = try app.readConfig(b, target, base); - if (b.option(bool, "defer-app", "Do not build the application here; the consumer calls `buildApp` with its own plugins") orelse false) { + const defer_app = b.option( + bool, + "defer-app", + "Do not build the application here; the consumer calls `buildApp` with its " ++ + "own plugins", + ) orelse false; + if (defer_app) { deferred = .{ .target = target, .optimize = optimize, .base = base, .cfg = cfg }; return; } @@ -126,7 +164,13 @@ pub const plugins = @import("build/plugins.zig").entries; /// try fizzy.buildApp(fizzy_dep, &.{ /// fizzy.plugins.workbench, /// fizzy.plugins.text, -/// .{ .name = "pixi", .module = b.dependency("pixi", .{ .target = target, .optimize = optimize }).module("plugin") }, +/// .{ +/// .name = "pixi", +/// .module = b.dependency("pixi", .{ +/// .target = target, +/// .optimize = optimize, +/// }).module("plugin"), +/// }, /// }); /// b.installArtifact(fizzy_dep.artifact("myapp")); /// ``` @@ -136,7 +180,10 @@ pub const plugins = @import("build/plugins.zig").entries; /// (its root's `plugin_id`) and `module` its static module, which the plugin package exports and /// which fizzy wires to `dvui`, `core`, `fizzy_sdk` and `icons`. pub fn buildApp(fizzy_dep: *std.Build.Dependency, linked: []const BundledPlugin) !void { - const d = deferred orelse @panic("fizzy.buildApp: pass `.@\"defer-app\" = true` to b.dependency(\"fizzy\", …) first"); + const d = deferred orelse @panic( + "fizzy.buildApp: pass `.@\"defer-app\" = true` to b.dependency(\"fizzy\", " ++ + "…) first", + ); var opts = d.base; // Until fizzyedit/example-app lists fizzy's plugins itself (its CI and fizzy's build each // other's main): a list naming none of fizzy's gets all of them ahead of its own, as before. @@ -144,7 +191,11 @@ pub fn buildApp(fizzy_dep: *std.Build.Dependency, linked: []const BundledPlugin) const names_fizzys = for (linked) |p| { if (p.module == null) break true; } else false; - opts.app_plugins = if (names_fizzys) linked else try std.mem.concat(fizzy_dep.builder.allocator, BundledPlugin, &.{ &plugins.all, linked }); + opts.app_plugins = if (names_fizzys) linked else try std.mem.concat( + fizzy_dep.builder.allocator, + BundledPlugin, + &.{ &plugins.all, linked }, + ); try @import("build/app.zig").construct(fizzy_dep.builder, d.target, d.optimize, opts, d.cfg); deferred.?.built = true; } @@ -173,10 +224,17 @@ pub fn buildApp(fizzy_dep: *std.Build.Dependency, linked: []const BundledPlugin) /// Windows MSVC ones reach fizzy only if the app declares `windows-msvc-libc` / `fetch-msvc` and /// passes them on in `b.dependency`. Without them, a `*-windows-msvc` run fetches MSVC itself. pub fn addPackageSteps(b: *std.Build, fizzy_dep: *std.Build.Dependency) !void { - const d = deferred orelse @panic("fizzy.addPackageSteps: pass `.@\"defer-app\" = true` to b.dependency(\"fizzy\", …) and call fizzy.buildApp first"); + const d = deferred orelse @panic( + "fizzy.addPackageSteps: pass `.@\"defer-app\" = true` to " ++ + "b.dependency(\"fizzy\", …) and call fizzy.buildApp first", + ); const names = [_][]const u8{ "package", "desktop", "packageall" }; for (names) |name| if (b.top_level_steps.contains(name)) { - std.log.err("fizzy.addPackageSteps: this build already has a `{s}` step; `package`, `desktop` and `packageall` are the names it adds", .{name}); + std.log.err( + "fizzy.addPackageSteps: this build already has a `{s}` step; `package`, " ++ + "`desktop` and `packageall` are the names it adds", + .{name}, + ); return error.PackageStepTaken; }; if (!d.built) @panic("fizzy.addPackageSteps: call fizzy.buildApp first"); @@ -207,7 +265,10 @@ pub const NativeBackend = @import("build/exe.zig").NativeBackend; /// /// ```zig /// const backend = @import("backend"); -/// const viewports = if (@hasDecl(backend, "viewports")) backend.viewports else @import("viewports_none"); +/// const viewports = if (@hasDecl(backend, "viewports")) +/// backend.viewports +/// else +/// @import("viewports_none"); /// ``` /// /// On fizzy's backend it also gets `platform` (the window's chrome and state), and on macOS the @@ -225,6 +286,14 @@ pub fn addDvui(fizzy_dep: *std.Build.Dependency, root_module: *std.Build.Module, root_module.addImport("viewports_none", @import("fizzy_backend").viewportsNoneModule(backend_dep, native.dvui)); if (backend == .fizzy) { root_module.addImport("platform", exe.platformModule(b, native, target, optimize, macos_sdl_paths)); - @import("fizzy_backend").addPlatformObjC(backend_dep, root_module, exe.backendOptions(target, optimize, macos_sdl_paths)); + @import("fizzy_backend").addPlatformObjC( + backend_dep, + root_module, + exe.backendOptions( + target, + optimize, + macos_sdl_paths, + ), + ); } }