Skip to content

Commit cdb89eb

Browse files
committed
(tests) Test unused file level directives are flagged
1 parent 05d4958 commit cdb89eb

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# ruff: noqa: F841 -- intentional unused file directive; will be removed

crates/ruff_linter/src/rules/ruff/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,16 @@ mod tests {
314314
Ok(())
315315
}
316316

317+
#[test]
318+
fn ruff_noqa_filedirective_unused() -> Result<()> {
319+
let diagnostics = test_path(
320+
Path::new("ruff/RUF100_6.py"),
321+
&settings::LinterSettings::for_rules(vec![Rule::UnusedNOQA]),
322+
)?;
323+
assert_messages!(diagnostics);
324+
Ok(())
325+
}
326+
317327
#[test]
318328
fn ruff_per_file_ignores() -> Result<()> {
319329
let diagnostics = test_path(
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
source: crates/ruff_linter/src/rules/ruff/mod.rs
3+
---
4+
RUF100_6.py:1:1: RUF100 [*] Unused `noqa` directive (non-enabled: `F841`)
5+
|
6+
1 | # ruff: noqa: F841 -- intentional unused file directive; will be removed
7+
| ^^^^^^^^^^^^^^^^^^ RUF100
8+
|
9+
= help: Remove unused `noqa` directive
10+
11+
Safe fix
12+
1 |-# ruff: noqa: F841 -- intentional unused file directive; will be removed
13+
1 |+

0 commit comments

Comments
 (0)