CI: Check for trailing spaces and (missing) newlines at the end of the file

fixes #737
This commit is contained in:
IntegratedQuantum 2025-02-12 17:36:44 +01:00
parent fd43253f4a
commit 22488a28ae
189 changed files with 373 additions and 382 deletions

View File

@ -39,7 +39,6 @@
.size_variation = 6, .size_variation = 6,
}, },
.{ .{
.id = "cubyz:ground_patch", .id = "cubyz:ground_patch",
.block = "cubyz:lava", .block = "cubyz:lava",
.chance = 0.064, .chance = 0.064,

View File

@ -9,7 +9,7 @@
.model = "cubyz:plane", .model = "cubyz:plane",
.rotation = .carpet, .rotation = .carpet,
.texture = "cubyz:dead_leaf_pile", .texture = "cubyz:dead_leaf_pile",
.item= .{ .item = .{
.texture = "dead_leaf_pile.png", .texture = "dead_leaf_pile.png",
}, },
.lodReplacement = "cubyz:air", .lodReplacement = "cubyz:air",

View File

@ -11,7 +11,7 @@
.model = "cubyz:plane", .model = "cubyz:plane",
.rotation = .carpet, .rotation = .carpet,
.texture = "cubyz:ivy", .texture = "cubyz:ivy",
.item= .{ .item = .{
.texture = "ivy.png", .texture = "ivy.png",
}, },
.lodReplacement = "cubyz:air", .lodReplacement = "cubyz:air",

View File

@ -75,4 +75,3 @@ void main() {
vec3 vertexPosition = modelPosition + (vertexBuffer[vertexID]*chunks[chunkID].maxPos.xyz + (1 - vertexBuffer[vertexID])*chunks[chunkID].minPos.xyz)*chunks[chunkID].voxelSize; vec3 vertexPosition = modelPosition + (vertexBuffer[vertexID]*chunks[chunkID].maxPos.xyz + (1 - vertexBuffer[vertexID])*chunks[chunkID].minPos.xyz)*chunks[chunkID].voxelSize;
gl_Position = projectionMatrix*viewMatrix*vec4(vertexPosition, 1); gl_Position = projectionMatrix*viewMatrix*vec4(vertexPosition, 1);
} }

View File

@ -15,7 +15,6 @@ uniform int circleColor;
void main() { void main() {
// Convert to opengl coordinates: // Convert to opengl coordinates:
vec2 position_percentage = (center + vertex_pos*radius)/screen; vec2 position_percentage = (center + vertex_pos*radius)/screen;

View File

@ -15,7 +15,6 @@ uniform vec2 uvDim;
uniform int color; uniform int color;
void main() { void main() {
// Convert to opengl coordinates: // Convert to opengl coordinates:
vec2 position_percentage = (start + vec2(vertex_pos.x*size.x, size.y - vertex_pos.y*size.y))/screen; vec2 position_percentage = (start + vec2(vertex_pos.x*size.x, size.y - vertex_pos.y*size.y))/screen;

View File

@ -14,7 +14,6 @@ uniform int lineColor;
void main() { void main() {
// Convert to opengl coordinates: // Convert to opengl coordinates:
vec2 position_percentage = (start + vertex_pos*direction)/screen; vec2 position_percentage = (start + vertex_pos*direction)/screen;

View File

@ -14,7 +14,6 @@ uniform int rectColor;
void main() { void main() {
// Convert to opengl coordinates: // Convert to opengl coordinates:
vec2 position_percentage = (start + vertex_pos*size)/screen; vec2 position_percentage = (start + vertex_pos*size)/screen;

View File

@ -15,7 +15,6 @@ uniform int rectColor;
void main() { void main() {
// Convert to opengl coordinates: // Convert to opengl coordinates:
vec2 position_percentage = (start + vertex_pos.xy*size + vertex_pos.zw*lineWidth)/screen; vec2 position_percentage = (start + vertex_pos.xy*size + vertex_pos.zw*lineWidth)/screen;

View File

@ -19,7 +19,6 @@ vec2 convert2Proportional(vec2 original, vec2 full){
return vec2(original.x/full.x, original.y/full.y); return vec2(original.x/full.x, original.y/full.y);
} }
void main() { void main() {
vec4 texture_rect_percentage = vec4(convert2Proportional(texture_rect.xy, fontSize), convert2Proportional(texture_rect.zw, fontSize)); vec4 texture_rect_percentage = vec4(convert2Proportional(texture_rect.xy, fontSize), convert2Proportional(texture_rect.zw, fontSize));
vec2 texture_position = vec2( vec2 texture_position = vec2(

View File

@ -20,7 +20,6 @@ vec2 convert2Proportional(vec2 original, vec2 full) {
return vec2(original.x/full.x, original.y/full.y); return vec2(original.x/full.x, original.y/full.y);
} }
void main() { void main() {
vec2 vertex_pos = face_pos*vec2(1, -1); vec2 vertex_pos = face_pos*vec2(1, -1);
vec2 position_percentage = convert2Proportional(floor(offset), scene); vec2 position_percentage = convert2Proportional(floor(offset), scene);

View File

@ -13,7 +13,6 @@ uniform vec2 screen;
uniform int color; uniform int color;
void main() { void main() {
// Convert to opengl coordinates: // Convert to opengl coordinates:
vec2 position_percentage = (start + vertex_pos*size)/screen; vec2 position_percentage = (start + vertex_pos*size)/screen;
startCoord.x = start.x; startCoord.x = start.x;

View File

@ -14,7 +14,6 @@ uniform vec2 screen;
uniform int color; uniform int color;
void main() { void main() {
// Convert to opengl coordinates: // Convert to opengl coordinates:
vec2 position_percentage = (start + vertex_pos*size)/screen; vec2 position_percentage = (start + vertex_pos*size)/screen;
startCoord.x = start.x; startCoord.x = start.x;

View File

@ -331,5 +331,3 @@ fn patestCallback(
addMusic(buffer); addMusic(buffer);
return 0; return 0;
} }

View File

@ -8,7 +8,7 @@ var failed: bool = false;
fn printError(msg: []const u8, filePath: []const u8, data: []const u8, charIndex: usize) void { fn printError(msg: []const u8, filePath: []const u8, data: []const u8, charIndex: usize) void {
var lineStart: usize = 0; var lineStart: usize = 0;
var lineNumber: usize = 1; var lineNumber: usize = 1;
var lineEnd: usize = 0; var lineEnd: usize = data.len;
for(data[0..charIndex], 0..) |c, i| { for(data[0..charIndex], 0..) |c, i| {
if(c == '\n') { if(c == '\n') {
lineStart = i + 1; lineStart = i + 1;
@ -47,6 +47,9 @@ fn checkFile(dir: std.fs.Dir, filePath: []const u8) !void {
switch(c) { switch(c) {
'\n' => { '\n' => {
lineStart = true; lineStart = true;
if(i != 0 and (data[i - 1] == ' ' or data[i - 1] == '\t')) {
printError("Line contains trailing whitespaces. Please remove them.", filePath, data, i - 1);
}
}, },
'\r' => { '\r' => {
printError("Incorrect line ending \\r. Please configure your editor to use LF instead CRLF.", filePath, data, i); printError("Incorrect line ending \\r. Please configure your editor to use LF instead CRLF.", filePath, data, i);
@ -62,6 +65,9 @@ fn checkFile(dir: std.fs.Dir, filePath: []const u8) !void {
} }
} }
} }
if(data.len != 0 and data[data.len - 1] != '\n' or (data.len > 2 and data[data.len - 2] == '\n')) {
printError("File should end with a single empty line", filePath, data, data.len - 1);
}
} }
fn checkDirectory(dir: std.fs.Dir) !void { fn checkDirectory(dir: std.fs.Dir) !void {

View File

@ -1054,9 +1054,7 @@ pub const Item = union(enum) { // MARK: Item
pub fn deinit(self: Item) void { pub fn deinit(self: Item) void {
switch(self) { switch(self) {
.baseItem => { .baseItem => {},
},
.tool => |_tool| { .tool => |_tool| {
_tool.deinit(); _tool.deinit();
}, },

View File

@ -178,5 +178,5 @@ const SimpleStructure = struct {
}, },
} }
self.model.generate(px, py, relZ, chunk, caveMap, &seed, isCeiling); self.model.generate(px, py, relZ, chunk, caveMap, &seed, isCeiling);
} }
}; };