diff --git a/libs/sqf/src/analyze/lints/s17_var_all_caps.rs b/libs/sqf/src/analyze/lints/s17_var_all_caps.rs index f960e9fb..f2630eda 100644 --- a/libs/sqf/src/analyze/lints/s17_var_all_caps.rs +++ b/libs/sqf/src/analyze/lints/s17_var_all_caps.rs @@ -125,7 +125,7 @@ impl Code for CodeS17VarAllCaps { } fn label_message(&self) -> String { - "All caps variable".to_string() + "all caps variable".to_string() } fn help(&self) -> Option { @@ -175,13 +175,13 @@ impl CodeS17VarAllCaps { }) else { return self; }; - if let Some(l) = diagnostic.labels.get_mut(0) { *l = l.clone().with_message("Used in macro here"); } + if let Some(l) = diagnostic.labels.get_mut(0) { *l = l.clone().with_message("used in macro here"); } diagnostic.labels.push( Label::primary( mapping.original().path().clone(), mapping.original().span(), ) - .with_message("All caps variable"), + .with_message("all caps variable"), ); self.diagnostic = Some(diagnostic); self diff --git a/libs/sqf/src/analyze/lints/s18_in_vehicle_check.rs b/libs/sqf/src/analyze/lints/s18_in_vehicle_check.rs index d2f30d11..cccb3432 100644 --- a/libs/sqf/src/analyze/lints/s18_in_vehicle_check.rs +++ b/libs/sqf/src/analyze/lints/s18_in_vehicle_check.rs @@ -126,14 +126,14 @@ impl Code for CodeS18InVehicleCheck { } fn message(&self) -> String { - "Using `vehicle` to check if a unit is in a vehicle is innefficient".to_string() + "Using `vehicle` to check if a unit is in a vehicle is inefficient".to_string() } fn label_message(&self) -> String { if self.negated { - "Innefficient \"in vehicle\" check".to_string() + "inefficient \"in vehicle\" check".to_string() } else { - "Innefficient \"not in vehicle\" check".to_string() + "inefficient \"not in vehicle\" check".to_string() } } diff --git a/libs/sqf/src/analyze/lints/s24_marker_spam.rs b/libs/sqf/src/analyze/lints/s24_marker_spam.rs index 7c6cf3ce..060f8537 100644 --- a/libs/sqf/src/analyze/lints/s24_marker_spam.rs +++ b/libs/sqf/src/analyze/lints/s24_marker_spam.rs @@ -182,7 +182,7 @@ impl CodeS24MarkerSpam { diag = diag.with_label(Label::secondary( info.0, info.1, - ).with_message("Last marker update, should remain global")); + ).with_message("last marker update, should remain global")); for (cmd, span) in self.calls.iter().rev().skip(1) { let Some(info) = get_span_info(span, processed) else { continue; @@ -190,7 +190,7 @@ impl CodeS24MarkerSpam { diag = diag.with_label(Label::primary( info.0, info.1, - ).with_message(format!("Use {cmd}Local"))); + ).with_message(format!("use {cmd}Local"))); } self.diagnostic = Some(diag); self diff --git a/libs/sqf/tests/snapshots/lints__simple_s17_var_all_caps.snap b/libs/sqf/tests/snapshots/lints__simple_s17_var_all_caps.snap index a64987dd..b3ddab6f 100644 --- a/libs/sqf/tests/snapshots/lints__simple_s17_var_all_caps.snap +++ b/libs/sqf/tests/snapshots/lints__simple_s17_var_all_caps.snap @@ -6,7 +6,7 @@ expression: lint(stringify! (s17_var_all_caps)) โ”Œโ”€ s17_var_all_caps.sqf:7:19 โ”‚ 7 โ”‚ private _z = _y + DO_NOT_EXIST; - โ”‚ ^^^^^^^^^^^^ All caps variable + โ”‚ ^^^^^^^^^^^^ all caps variable โ”‚ = note: All caps variables are usually reserved for macros @@ -15,7 +15,7 @@ expression: lint(stringify! (s17_var_all_caps)) โ”Œโ”€ s17_var_all_caps.sqf:8:19 โ”‚ 8 โ”‚ private _w = _z + TPYO; - โ”‚ ^^^^ All caps variable + โ”‚ ^^^^ all caps variable โ”‚ = note: All caps variables are usually reserved for macros = help: did you mean `TYPO`? @@ -25,9 +25,9 @@ expression: lint(stringify! (s17_var_all_caps)) โ”Œโ”€ s17_var_all_caps.sqf:3:27 โ”‚ 3 โ”‚ #define NESTED systemChat UNDEFINED - โ”‚ ^^^^^^^^^ All caps variable + โ”‚ ^^^^^^^^^ all caps variable ยท 9 โ”‚ NESTED; - โ”‚ ^^^^^^ Used in macro here + โ”‚ ^^^^^^ used in macro here โ”‚ = note: All caps variables are usually reserved for macros diff --git a/libs/sqf/tests/snapshots/lints__simple_s18_in_vehicle_check.snap b/libs/sqf/tests/snapshots/lints__simple_s18_in_vehicle_check.snap index 9255bd2b..612af681 100644 --- a/libs/sqf/tests/snapshots/lints__simple_s18_in_vehicle_check.snap +++ b/libs/sqf/tests/snapshots/lints__simple_s18_in_vehicle_check.snap @@ -2,19 +2,19 @@ source: libs/sqf/tests/lints.rs expression: lint(stringify! (s18_in_vehicle_check)) --- -help[L-S18]: Using `vehicle` to check if a unit is in a vehicle is innefficient +help[L-S18]: Using `vehicle` to check if a unit is in a vehicle is inefficient โ”Œโ”€ s18_in_vehicle_check.sqf:1:5 โ”‚ 1 โ”‚ if (vehicle player != player) then { - โ”‚ ^^^^^^^^^^^^^^^^^^^^^^^^ Innefficient "in vehicle" check + โ”‚ ^^^^^^^^^^^^^^^^^^^^^^^^ inefficient "in vehicle" check โ”‚ = try: !isNull objectParent player -help[L-S18]: Using `vehicle` to check if a unit is in a vehicle is innefficient +help[L-S18]: Using `vehicle` to check if a unit is in a vehicle is inefficient โ”Œโ”€ s18_in_vehicle_check.sqf:5:21 โ”‚ 5 โ”‚ if (alive _unit && {_unit == vehicle _unit}) then { - โ”‚ ^^^^^^^^^^^^^^^^^^^^^^ Innefficient "not in vehicle" check + โ”‚ ^^^^^^^^^^^^^^^^^^^^^^ inefficient "not in vehicle" check โ”‚ = try: isNull objectParent _unit diff --git a/libs/sqf/tests/snapshots/lints__simple_s24_marker_spam.snap b/libs/sqf/tests/snapshots/lints__simple_s24_marker_spam.snap index a6bd272d..1bbb30c6 100644 --- a/libs/sqf/tests/snapshots/lints__simple_s24_marker_spam.snap +++ b/libs/sqf/tests/snapshots/lints__simple_s24_marker_spam.snap @@ -6,13 +6,13 @@ expression: lint(stringify! (s24_marker_spam)) โ”Œโ”€ s24_marker_spam.sqf:4:13 โ”‚ 4 โ”‚ _marker setMarkerShape "ICON"; - โ”‚ ^^^^^^^^^^^^^^ Use setMarkerShapeLocal + โ”‚ ^^^^^^^^^^^^^^ use setMarkerShapeLocal 5 โ”‚ _marker setMarkerType "hd_dot"; - โ”‚ ^^^^^^^^^^^^^ Use setMarkerTypeLocal + โ”‚ ^^^^^^^^^^^^^ use setMarkerTypeLocal 6 โ”‚ _marker setMarkerColor "ColorRed"; - โ”‚ ^^^^^^^^^^^^^^ Use setMarkerColorLocal + โ”‚ ^^^^^^^^^^^^^^ use setMarkerColorLocal 7 โ”‚ _marker setMarkerSize [1, 1]; - โ”‚ ------------- Last marker update, should remain global + โ”‚ ------------- last marker update, should remain global โ”‚ = note: Global marker commands update the entire state of the marker = help: Using `setMarker*Local` on all except the last call reduces network updates @@ -22,11 +22,11 @@ expression: lint(stringify! (s24_marker_spam)) โ”Œโ”€ s24_marker_spam.sqf:12:10 โ”‚ 12 โ”‚ "m1" setMarkerShape "ICON"; - โ”‚ ^^^^^^^^^^^^^^ Use setMarkerShapeLocal + โ”‚ ^^^^^^^^^^^^^^ use setMarkerShapeLocal 13 โ”‚ "m1" setMarkerType "hd_dot"; - โ”‚ ^^^^^^^^^^^^^ Use setMarkerTypeLocal + โ”‚ ^^^^^^^^^^^^^ use setMarkerTypeLocal 14 โ”‚ "m1" setMarkerSize [1, 1]; - โ”‚ ------------- Last marker update, should remain global + โ”‚ ------------- last marker update, should remain global โ”‚ = note: Global marker commands update the entire state of the marker = help: Using `setMarker*Local` on all except the last call reduces network updates @@ -36,9 +36,9 @@ expression: lint(stringify! (s24_marker_spam)) โ”Œโ”€ s24_marker_spam.sqf:20:13 โ”‚ 20 โ”‚ _marker setMarkerShape "ICON"; - โ”‚ ^^^^^^^^^^^^^^ Use setMarkerShapeLocal + โ”‚ ^^^^^^^^^^^^^^ use setMarkerShapeLocal 21 โ”‚ _marker setMarkerType "hd_dot"; - โ”‚ ------------- Last marker update, should remain global + โ”‚ ------------- last marker update, should remain global โ”‚ = note: Global marker commands update the entire state of the marker = help: Using `setMarker*Local` on all except the last call reduces network updates @@ -48,9 +48,9 @@ expression: lint(stringify! (s24_marker_spam)) โ”Œโ”€ s24_marker_spam.sqf:23:13 โ”‚ 23 โ”‚ _marker setMarkerColor "ColorRed"; - โ”‚ ^^^^^^^^^^^^^^ Use setMarkerColorLocal + โ”‚ ^^^^^^^^^^^^^^ use setMarkerColorLocal 24 โ”‚ _marker setMarkerSize [1, 1]; - โ”‚ ------------- Last marker update, should remain global + โ”‚ ------------- last marker update, should remain global โ”‚ = note: Global marker commands update the entire state of the marker = help: Using `setMarker*Local` on all except the last call reduces network updates diff --git a/libs/workspace/src/reporting/diagnostic/label.rs b/libs/workspace/src/reporting/diagnostic/label.rs index 73f88076..471f8bde 100644 --- a/libs/workspace/src/reporting/diagnostic/label.rs +++ b/libs/workspace/src/reporting/diagnostic/label.rs @@ -49,6 +49,14 @@ impl Label { let mut label = codespan_reporting::diagnostic::Label::new(self.style, &self.file, self.span.clone()); if let Some(message) = &self.message { + debug_assert!( + message.is_empty() + || message + .chars() + .next() + .map_or(true, |c| c.is_lowercase() || !c.is_alphabetic()), + "All label messages should be lowercase (except for text copied from the source)" + ); label = label.with_message(message.clone()); } label