Skip to content

Commit c9a08af

Browse files
committed
Add "io" to default excluded short names for field and declaration naming rule
i.e., by default if you have a min of 3 charactors `io` (common in 0.16) will not trigger it. This also uses a consistent list for fields and declarations so they both stay in sync This unfortunately isn't handled well in the doc generation (prints the defaults variable name and not its values) but I don't think worth fixing within this commit as auto generated documentation is a lower priority atm.
1 parent e1c7a86 commit c9a08af

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

RULES.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Enforces that variable declaration names use consistent naming. For example,
7777

7878
* Exclude these declaration names from min and max declaration name checks.
7979

80-
* **Default:** `&.{ "x", "y", "z", "i", "b", "it", "ip", "c", }`
80+
* **Default:** `zlinter.strings.default_excluded_short_names`
8181

8282
## `field_naming`
8383

@@ -156,7 +156,7 @@ example, `struct`, `enum`, `union`, `opaque` and `error`.
156156

157157
* Exclude these `struct` field names from min and max `struct` field name checks.
158158

159-
* **Default:** `&.{ "x", "y", "z", "i", "b" }`
159+
* **Default:** `zlinter.strings.default_excluded_short_names`
160160

161161
* `struct_field_that_is_type`
162162

@@ -204,7 +204,7 @@ example, `struct`, `enum`, `union`, `opaque` and `error`.
204204

205205
* Exclude these `union` field names from min and max `union` field name checks.
206206

207-
* **Default:** `&.{ "x", "y", "z", "i", "b" }`
207+
* **Default:** `zlinter.strings.default_excluded_short_names`
208208

209209
## `field_ordering`
210210

src/lib/strings.zig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,16 @@ pub fn debugPrintMultilineString(source: []const u8, writer: anytype, indent: us
8282
writer.print("\n{s}\\\\{s}", .{ indent_str, line });
8383
}
8484

85+
pub const default_excluded_short_names: []const []const u8 = &.{
86+
"x",
87+
"y",
88+
"z",
89+
"i",
90+
"b",
91+
"it",
92+
"ip",
93+
"c",
94+
"io",
95+
};
96+
8597
const std = @import("std");

src/rules/declaration_naming.zig

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,7 @@ pub const Config = struct {
7474
},
7575

7676
/// Exclude these declaration names from min and max declaration name checks.
77-
decl_name_exclude_len: []const []const u8 = &.{
78-
"x",
79-
"y",
80-
"z",
81-
"i",
82-
"b",
83-
"it",
84-
"ip",
85-
"c",
86-
},
77+
decl_name_exclude_len: []const []const u8 = zlinter.strings.default_excluded_short_names,
8778
};
8879

8980
/// Builds and returns the declaration_naming rule.

src/rules/field_naming.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub const Config = struct {
7676
},
7777

7878
/// Exclude these `struct` field names from min and max `struct` field name checks.
79-
struct_field_exclude_len: []const []const u8 = &.{ "x", "y", "z", "i", "b" },
79+
struct_field_exclude_len: []const []const u8 = zlinter.strings.default_excluded_short_names,
8080

8181
/// Like `struct_field` but for fields with type `type`
8282
struct_field_that_is_type: zlinter.rules.LintTextStyleWithSeverity = .{
@@ -125,7 +125,7 @@ pub const Config = struct {
125125
},
126126

127127
/// Exclude these `union` field names from min and max `union` field name checks.
128-
union_field_exclude_len: []const []const u8 = &.{ "x", "y", "z", "i", "b" },
128+
union_field_exclude_len: []const []const u8 = zlinter.strings.default_excluded_short_names,
129129
};
130130

131131
/// Builds and returns the field_naming rule.

0 commit comments

Comments
 (0)