Skip to content

Commit 434b02c

Browse files
committed
Fix erroneous snake case function names
1 parent eb8b513 commit 434b02c

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

src/argparse.zig

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub fn parse(
2525
errdefer {
2626
inline for (fields, seen) |field, seen_field| {
2727
if (seen_field) {
28-
free_field(allocator, @field(result, field.name));
28+
freeField(allocator, @field(result, field.name));
2929
}
3030
}
3131
}
@@ -38,7 +38,7 @@ pub fn parse(
3838

3939
inline for (fields, seen) |field, seen_field| {
4040
if (!seen_field) {
41-
if (@typeInfo(strip_optional(field.type)) == .bool) {
41+
if (@typeInfo(stripOptional(field.type)) == .bool) {
4242
@field(result, field.name) = false;
4343
} else {
4444
try stderr.print(
@@ -92,7 +92,7 @@ fn setFromCli(
9292
std.mem.replaceScalar(u8, arg, '-', '_');
9393
inline for (@typeInfo(T).@"struct".fields, seen) |field, *seen_field| {
9494
if (!seen_field.* and std.ascii.eqlIgnoreCase(arg, field.name)) {
95-
const t = @typeInfo(strip_optional(field.type));
95+
const t = @typeInfo(stripOptional(field.type));
9696
if (t == .bool) {
9797
@field(result, field.name) = true;
9898
} else {
@@ -146,7 +146,7 @@ fn setFromEnv(
146146
std.mem.replaceScalar(u8, key, '-', '_');
147147
inline for (@typeInfo(T).@"struct".fields, seen) |field, *seen_field| {
148148
if (!seen_field.* and std.ascii.eqlIgnoreCase(key, field.name)) {
149-
switch (@typeInfo(strip_optional(field.type))) {
149+
switch (@typeInfo(stripOptional(field.type))) {
150150
.bool => {
151151
const value = try a.dupe(u8, entry.value_ptr.*);
152152
defer a.free(value);
@@ -176,7 +176,7 @@ fn setFromDefaults(
176176
inline for (@typeInfo(T).@"struct".fields, seen) |field, *seen_field| {
177177
if (!seen_field.*) {
178178
if (field.defaultValue()) |default| {
179-
switch (@typeInfo(strip_optional(field.type))) {
179+
switch (@typeInfo(stripOptional(field.type))) {
180180
.bool, .int, .float, .@"enum" => {
181181
@field(result, field.name) = default;
182182
},
@@ -197,7 +197,7 @@ fn printUsage(T: type, allocator: std.mem.Allocator, argv0: []const u8) !void {
197197
try stdout.print("Options:\n", .{});
198198
const fields = @typeInfo(T).@"struct".fields;
199199
inline for (fields) |field| {
200-
switch (@typeInfo(strip_optional(field.type))) {
200+
switch (@typeInfo(stripOptional(field.type))) {
201201
.bool => {
202202
const flag_version = try allocator.dupe(u8, field.name);
203203
defer allocator.free(flag_version);
@@ -214,16 +214,16 @@ fn printUsage(T: type, allocator: std.mem.Allocator, argv0: []const u8) !void {
214214
}
215215
}
216216

217-
fn strip_optional(T: type) type {
217+
fn stripOptional(T: type) type {
218218
const info = @typeInfo(T);
219219
if (info != .optional) return T;
220-
return strip_optional(info.optional.child);
220+
return stripOptional(info.optional.child);
221221
}
222222

223-
fn free_field(allocator: std.mem.Allocator, field: anytype) void {
223+
fn freeField(allocator: std.mem.Allocator, field: anytype) void {
224224
switch (@typeInfo(@TypeOf(field))) {
225225
.pointer => allocator.free(field),
226-
.optional => if (field) |v| free_field(allocator, v),
226+
.optional => if (field) |v| freeField(allocator, v),
227227
.bool, .int, .float, .@"enum" => {},
228228
else => @compileError("Disallowed struct field type."),
229229
}

src/statistics.zig

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const Repository = struct {
3131
}
3232
}
3333

34-
pub fn get_lines_changed(
34+
pub fn getLinesChanged(
3535
self: *@This(),
3636
arena: *std.heap.ArenaAllocator,
3737
client: *HttpClient,
@@ -104,9 +104,9 @@ pub fn init(client: *HttpClient, allocator: std.mem.Allocator) !Statistics {
104104
var arena = std.heap.ArenaAllocator.init(allocator);
105105
defer arena.deinit();
106106

107-
var self: Statistics = try get_repos(allocator, &arena, client);
107+
var self: Statistics = try getRepos(allocator, &arena, client);
108108
errdefer self.deinit(allocator);
109-
try self.get_lines_changed(&arena, client);
109+
try self.getLinesChanged(&arena, client);
110110
return self;
111111
}
112112

@@ -132,7 +132,7 @@ pub fn deinit(self: Statistics, allocator: std.mem.Allocator) void {
132132
allocator.free(self.name);
133133
}
134134

135-
fn get_basic_info(
135+
fn getBasicInfo(
136136
client: *HttpClient,
137137
allocator: std.mem.Allocator,
138138
) !struct { []u32, []const u8, ?[]const u8 } {
@@ -174,7 +174,7 @@ fn get_basic_info(
174174
};
175175
}
176176

177-
fn get_repos_by_year(
177+
fn getReposByYear(
178178
context: struct {
179179
allocator: std.mem.Allocator,
180180
arena: *std.heap.ArenaAllocator,
@@ -289,7 +289,7 @@ fn get_repos_by_year(
289289
for (&[_]usize{ 2, 3 }) |factor| {
290290
if (months % factor == 0) {
291291
for (0..factor) |i| {
292-
try get_repos_by_year(
292+
try getReposByYear(
293293
context,
294294
year,
295295
start_month + (months / factor) * i,
@@ -396,7 +396,7 @@ fn get_repos_by_year(
396396
);
397397
}
398398

399-
_ = try repository.get_lines_changed(
399+
_ = try repository.getLinesChanged(
400400
context.arena,
401401
context.client,
402402
context.user,
@@ -407,7 +407,7 @@ fn get_repos_by_year(
407407
}
408408
}
409409

410-
fn get_repos(
410+
fn getRepos(
411411
allocator: std.mem.Allocator,
412412
arena: *std.heap.ArenaAllocator,
413413
client: *HttpClient,
@@ -429,14 +429,14 @@ fn get_repos(
429429
defer seen.deinit();
430430

431431
const years, const user, const name =
432-
try get_basic_info(client, arena.allocator());
432+
try getBasicInfo(client, arena.allocator());
433433
if (name) |n| {
434434
std.log.info("Getting data for {s} ({s})...", .{ n, user });
435435
} else {
436436
std.log.info("Getting data for user {s}...", .{user});
437437
}
438438
for (years) |year| {
439-
try get_repos_by_year(.{
439+
try getReposByYear(.{
440440
.allocator = allocator,
441441
.arena = arena,
442442
.client = client,
@@ -470,7 +470,7 @@ fn get_repos(
470470
return result;
471471
}
472472

473-
fn get_lines_changed(
473+
fn getLinesChanged(
474474
self: *Statistics,
475475
arena: *std.heap.ArenaAllocator,
476476
client: *HttpClient,
@@ -508,7 +508,7 @@ fn get_lines_changed(
508508
});
509509
std.Thread.sleep(delay * std.time.ns_per_s);
510510
}
511-
switch (try item.repo.get_lines_changed(arena, client, self.user)) {
511+
switch (try item.repo.getLinesChanged(arena, client, self.user)) {
512512
.ok => {},
513513
.accepted => {
514514
item.timestamp = std.time.timestamp() + item.delay;

0 commit comments

Comments
 (0)