diff --git a/libs/config/src/analyze/lints/c11_file_type.rs b/libs/config/src/analyze/lints/c11_file_type.rs index 6cc1e621..8a2b9c58 100644 --- a/libs/config/src/analyze/lints/c11_file_type.rs +++ b/libs/config/src/analyze/lints/c11_file_type.rs @@ -26,11 +26,11 @@ impl Lint for LintC11FileType { fn documentation(&self) -> &'static str { r#"### Configuration -- **allow_no_extension**: Allow properties to not have a file extension, default is `true`. +- **allow_no_extension**: Allow properties to not have a file extension, default is `false`. ```toml [lints.config.file_type] -options.allow_no_extension = false +options.allow_no_extension = true ``` ### Example @@ -114,7 +114,7 @@ impl LintRunner for Runner { let allow_no_extension = if let Some(toml::Value::Boolean(allow_no_extension)) = config.option("allow_no_extension") { *allow_no_extension } else { - true + false }; // Arrays if let Value::Array(values) = value { @@ -138,6 +138,10 @@ impl LintRunner for Runner { fn check(name: &str, value: &Str, allow_no_extension: bool, processed: &Processed, config: &LintConfig) -> Option> { let value_str = value.value(); + // Skip if it contains no backslashes, probably a class name + if !value_str.contains('\\') { + return None; + } if name == "sound" && value_str.starts_with("db") { return None; } diff --git a/libs/config/tests/lints/c11_file_type.hpp b/libs/config/tests/lints/c11_file_type.hpp index dc702210..4f363bf8 100644 --- a/libs/config/tests/lints/c11_file_type.hpp +++ b/libs/config/tests/lints/c11_file_type.hpp @@ -1,7 +1,9 @@ class CfgVehicles { class MyVehicle { - model = "test.p3d"; - editorPreview = "test.jgp"; - wounds[] = {"would1.pac", "wound2.paa", "wound3.png"}; + model = "x\mod\test.p3d"; + uimodel = "x\mod\test_no_path"; + editorPreview = "x\mod\test.jgp"; + wounds[] = {"x\mod\would1.pac", "x\mod\wound2.paa", "x\mod\wound3.png"}; + modelspecial = "class_name"; }; }; diff --git a/libs/config/tests/snapshots/lints__config_error_c11_file_type.snap b/libs/config/tests/snapshots/lints__config_error_c11_file_type.snap index 6ab18568..9d3ccdfa 100644 --- a/libs/config/tests/snapshots/lints__config_error_c11_file_type.snap +++ b/libs/config/tests/snapshots/lints__config_error_c11_file_type.snap @@ -2,19 +2,26 @@ source: libs/config/tests/lints.rs expression: lint(stringify! (c11_file_type)) --- +warning[L-C11ME]: a property that references a file is missing a file extension + ┌─ c11_file_type.hpp:4:20 + │ +4 │ uimodel = "x\mod\test_no_path"; + │ ^^^^^^^^^^^^^^^^^^ missing file extension + + warning[L-C11UE]: a property that references a file has an unusual file type - ┌─ c11_file_type.hpp:4:31 + ┌─ c11_file_type.hpp:5:37 │ -4 │ editorPreview = "test.jgp"; - │ ^^^ unusual file type +5 │ editorPreview = "x\mod\test.jgp"; + │ ^^^ unusual file type │ = note: expected file type jpg warning[L-C11UE]: a property that references a file has an unusual file type - ┌─ c11_file_type.hpp:5:57 + ┌─ c11_file_type.hpp:6:75 │ -5 │ wounds[] = {"would1.pac", "wound2.paa", "wound3.png"}; - │ ^^^ unusual file type +6 │ wounds[] = {"x\mod\would1.pac", "x\mod\wound2.paa", "x\mod\wound3.png"}; + │ ^^^ unusual file type │ = note: expected file type paa