Skip to content

Commit 59129bb

Browse files
authored
Walk symbols when checking return types of function calls #132 (#133)
This change also adds more names to be excluded by the default min name length check (e.g., `it`), although kinda tempted to turn this off by default as its really only useful those super pedantic, as short names can be readable. It also now ignores unknown types instead of falling back to the assumption that they're standard variables. I think this only happens if a dependency/module isn't resolved or if things are a bit too compile time. I'll need to look more into it at some point. Ignoring seems better than giving a false positive to an issue.
1 parent f85a673 commit 59129bb

File tree

4 files changed

+316
-83
lines changed

4 files changed

+316
-83
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
fn IntToFloatType(IntType: type) type {
2+
return @Type(.{
3+
.int = .{
4+
.signedness = .signed,
5+
.bits = @typeInfo(IntType).float.bits,
6+
},
7+
});
8+
}
9+
10+
const GoodFloatType = IntToFloatType(u32);
11+
const badFloatType = IntToFloatType(u32);
12+
const bad_float_type = IntToFloatType(u32);
13+
14+
const GoodInt = std.math.IntFittingRange(0, 10);
15+
const badInt = std.math.IntFittingRange(0, 10);
16+
const bad_int = std.math.IntFittingRange(0, 10);
17+
18+
const GoodBitSet = std.StaticBitSet(10);
19+
const badBitSet = std.StaticBitSet(10);
20+
const bad_bit_set = std.StaticBitSet(10);
21+
22+
const std = @import("std");
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error Type declaration should be TitleCase [test_cases/declaration_naming/regression_132.input.zig:11:7] declaration_naming
2+
3+
11 | const badFloatType = IntToFloatType(u32);
4+
| ^^^^^^^^^^^^
5+
6+
error Type declaration should be TitleCase [test_cases/declaration_naming/regression_132.input.zig:12:7] declaration_naming
7+
8+
12 | const bad_float_type = IntToFloatType(u32);
9+
| ^^^^^^^^^^^^^^
10+
11+
error Type declaration should be TitleCase [test_cases/declaration_naming/regression_132.input.zig:15:7] declaration_naming
12+
13+
15 | const badInt = std.math.IntFittingRange(0, 10);
14+
| ^^^^^^
15+
16+
error Type declaration should be TitleCase [test_cases/declaration_naming/regression_132.input.zig:16:7] declaration_naming
17+
18+
16 | const bad_int = std.math.IntFittingRange(0, 10);
19+
| ^^^^^^^
20+
21+
error Type declaration should be TitleCase [test_cases/declaration_naming/regression_132.input.zig:19:7] declaration_naming
22+
23+
19 | const badBitSet = std.StaticBitSet(10);
24+
| ^^^^^^^^^
25+
26+
error Type declaration should be TitleCase [test_cases/declaration_naming/regression_132.input.zig:20:7] declaration_naming
27+
28+
20 | const bad_bit_set = std.StaticBitSet(10);
29+
| ^^^^^^^^^^^
30+
31+
x 6 errors

0 commit comments

Comments
 (0)