1
1
use std:: path:: Path ;
2
2
3
+ use crate :: codes:: Rule ;
4
+ use crate :: comments:: shebang:: ShebangDirective ;
5
+ use crate :: settings:: LinterSettings ;
3
6
use ruff_diagnostics:: Diagnostic ;
4
7
use ruff_python_trivia:: CommentRanges ;
5
8
use ruff_source_file:: Locator ;
@@ -9,8 +12,6 @@ pub(crate) use shebang_missing_python::*;
9
12
pub ( crate ) use shebang_not_executable:: * ;
10
13
pub ( crate ) use shebang_not_first_line:: * ;
11
14
12
- use crate :: comments:: shebang:: ShebangDirective ;
13
-
14
15
mod shebang_leading_whitespace;
15
16
mod shebang_missing_executable_file;
16
17
mod shebang_missing_python;
@@ -22,6 +23,7 @@ pub(crate) fn from_tokens(
22
23
path : & Path ,
23
24
locator : & Locator ,
24
25
comment_ranges : & CommentRanges ,
26
+ settings : & LinterSettings ,
25
27
) {
26
28
let mut has_any_shebang = false ;
27
29
for range in comment_ranges {
@@ -33,8 +35,10 @@ pub(crate) fn from_tokens(
33
35
diagnostics. push ( diagnostic) ;
34
36
}
35
37
36
- if let Some ( diagnostic) = shebang_not_executable ( path, range) {
37
- diagnostics. push ( diagnostic) ;
38
+ if settings. rules . enabled ( Rule :: ShebangNotExecutable ) {
39
+ if let Some ( diagnostic) = shebang_not_executable ( path, range) {
40
+ diagnostics. push ( diagnostic) ;
41
+ }
38
42
}
39
43
40
44
if let Some ( diagnostic) = shebang_leading_whitespace ( range, locator) {
@@ -48,8 +52,10 @@ pub(crate) fn from_tokens(
48
52
}
49
53
50
54
if !has_any_shebang {
51
- if let Some ( diagnostic) = shebang_missing_executable_file ( path) {
52
- diagnostics. push ( diagnostic) ;
55
+ if settings. rules . enabled ( Rule :: ShebangMissingExecutableFile ) {
56
+ if let Some ( diagnostic) = shebang_missing_executable_file ( path) {
57
+ diagnostics. push ( diagnostic) ;
58
+ }
53
59
}
54
60
}
55
61
}
0 commit comments