mirror of
https://github.com/WhatsApp/erlang-language-platform.git
synced 2025-12-23 12:26:48 +00:00
Report an error if given L1500 for elp lint command
Summary: We changed the error code for `unused include` from `L1500` to `W0020`, because the `L` range belongs to diagnostics from the OTP compiler, and it is an ELP-native diagnostic. Report a useful error if `L1500` is passed as the diagnostic filter for `elp lint` Reviewed By: VLanvin Differential Revision: D55186509 fbshipit-source-id: 53a445d51830cbee224277cc1c6a27b086a0adf1
This commit is contained in:
parent
961cf29132
commit
f119709621
3 changed files with 21 additions and 0 deletions
|
|
@ -180,6 +180,11 @@ pub fn do_codemod(cli: &mut dyn Cli, loaded: &mut LoadResult, args: &Lint) -> Re
|
|||
}
|
||||
|
||||
if let Some(diagnostic_filter) = diagnostic_filter {
|
||||
// We have replaced L1500 with W0020. Generate an error if we get L1500.
|
||||
if diagnostic_filter == "L1500" {
|
||||
bail!("Code L1500 has been superseded by W0020");
|
||||
}
|
||||
|
||||
let diagnostic_filter = DiagnosticCode::from(diagnostic_filter.as_str());
|
||||
// Make sure we do not mask the one we explicitly asked for
|
||||
disabled_diagnostics.remove(&diagnostic_filter);
|
||||
|
|
|
|||
|
|
@ -1225,6 +1225,21 @@ mod tests {
|
|||
.expect("Bad test");
|
||||
}
|
||||
|
||||
#[test_case(false ; "rebar")]
|
||||
#[test_case(true ; "buck")]
|
||||
fn lint_errors_on_deprecated_l1500(buck: bool) {
|
||||
let tmp_dir = TempDir::new().expect("Could not create temporary directory");
|
||||
let tmp_path = tmp_dir.path();
|
||||
fs::create_dir_all(tmp_path).expect("Could not create temporary directory path");
|
||||
simple_snapshot_expect_stderror(
|
||||
args_vec!["lint", "--module", "app_a", "--diagnostic-filter", "L1500",],
|
||||
"diagnostics",
|
||||
expect_file!("../resources/test/diagnostics/parse_elp_l1500_deprecated.stdout"),
|
||||
buck,
|
||||
None,
|
||||
)
|
||||
}
|
||||
|
||||
#[test_case(false ; "rebar")]
|
||||
#[test_case(true ; "buck")]
|
||||
fn lint_edoc(buck: bool) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Code L1500 has been superseded by W0020
|
||||
Loading…
Add table
Add a link
Reference in a new issue