mirror of https://github.com/astral-sh/ruff
Move DJ014->DJ100 and DJ015->DJ101
This commit is contained in:
parent
bfc179440e
commit
ec2c18294e
|
|
@ -3,11 +3,11 @@ from . import views
|
|||
|
||||
# Errors - missing trailing slash
|
||||
urlpatterns = [
|
||||
path("help", views.help_view), # DJ014
|
||||
path("about", views.about_view), # DJ014
|
||||
path("contact", views.contact_view), # DJ014
|
||||
path("api/users", views.users_view), # DJ014
|
||||
path("blog/posts", views.posts_view), # DJ014
|
||||
path("help", views.help_view), # DJ100
|
||||
path("about", views.about_view), # DJ100
|
||||
path("contact", views.contact_view), # DJ100
|
||||
path("api/users", views.users_view), # DJ100
|
||||
path("blog/posts", views.posts_view), # DJ100
|
||||
]
|
||||
|
||||
# OK - has trailing slash
|
||||
|
|
@ -34,13 +34,13 @@ urlpatterns_params = [
|
|||
# Mixed cases
|
||||
urlpatterns_mixed = [
|
||||
path("good/", views.good_view),
|
||||
path("bad", views.bad_view), # DJ014
|
||||
path("bad", views.bad_view), # DJ100
|
||||
path("also-good/", views.also_good_view),
|
||||
path("also-bad", views.also_bad_view), # DJ014
|
||||
path("also-bad", views.also_bad_view), # DJ100
|
||||
]
|
||||
|
||||
# Error - missing trail slash and argument should stay in message
|
||||
urlpatterns_params_bad = [
|
||||
path("bad/<slug:slug>", views.bad_view), # DJ014
|
||||
path("<slug:slug>", views.bad_view), # DJ014
|
||||
path("bad/<slug:slug>", views.bad_view), # DJ100
|
||||
path("<slug:slug>", views.bad_view), # DJ100
|
||||
]
|
||||
|
|
@ -3,8 +3,8 @@ from . import views
|
|||
|
||||
# Test that custom path functions are also checked
|
||||
urlpatterns_custom = [
|
||||
mypath("help", views.help_view), # DJ014
|
||||
mypath("about", views.about_view), # DJ014
|
||||
mypath("help", views.help_view), # DJ100
|
||||
mypath("about", views.about_view), # DJ100
|
||||
]
|
||||
|
||||
# OK - custom path with trailing slash
|
||||
|
|
@ -15,8 +15,8 @@ urlpatterns_custom_ok = [
|
|||
|
||||
# Test multiple violations in same list
|
||||
urlpatterns_multiple = [
|
||||
mypath("api/users", views.users_view), # DJ014
|
||||
mypath("api/posts", views.posts_view), # DJ014
|
||||
mypath("api/users", views.users_view), # DJ100
|
||||
mypath("api/posts", views.posts_view), # DJ100
|
||||
mypath("api/comments/", views.comments_view), # OK
|
||||
]
|
||||
|
||||
|
|
@ -3,11 +3,11 @@ from . import views
|
|||
|
||||
# Errors - leading slash
|
||||
urlpatterns = [
|
||||
path("/help/", views.help_view), # DJ015
|
||||
path("/about/", views.about_view), # DJ015
|
||||
path("/contact/", views.contact_view), # DJ015
|
||||
path("/api/users/", views.users_view), # DJ015
|
||||
path("/blog/posts/", views.posts_view), # DJ015
|
||||
path("/help/", views.help_view), # DJ101
|
||||
path("/about/", views.about_view), # DJ101
|
||||
path("/contact/", views.contact_view), # DJ101
|
||||
path("/api/users/", views.users_view), # DJ101
|
||||
path("/blog/posts/", views.posts_view), # DJ101
|
||||
]
|
||||
|
||||
# OK - no leading slash
|
||||
|
|
@ -34,21 +34,21 @@ urlpatterns_params = [
|
|||
# Mixed cases
|
||||
urlpatterns_mixed = [
|
||||
path("good/", views.good_view),
|
||||
path("/bad/", views.bad_view), # DJ015
|
||||
path("/bad/", views.bad_view), # DJ101
|
||||
path("also-good/", views.also_good_view),
|
||||
path("/also-bad/", views.also_bad_view), # DJ015
|
||||
path("/also-bad/", views.also_bad_view), # DJ101
|
||||
]
|
||||
|
||||
# Edge cases with different quote styles
|
||||
urlpatterns_quotes = [
|
||||
path('/single-quote/', views.single_quote_view), # DJ015
|
||||
path("/double-quote/", views.double_quote_view), # DJ015
|
||||
path('''/triple-single/''', views.triple_single_view), # DJ015
|
||||
path("""/triple-double/""", views.triple_double_view), # DJ015
|
||||
path('/single-quote/', views.single_quote_view), # DJ101
|
||||
path("/double-quote/", views.double_quote_view), # DJ101
|
||||
path('''/triple-single/''', views.triple_single_view), # DJ101
|
||||
path("""/triple-double/""", views.triple_double_view), # DJ101
|
||||
]
|
||||
|
||||
# Error - leading trail slash and argument should stay in message
|
||||
urlpatterns_params_bad = [
|
||||
path("/bad/<slug:slug>/", views.bad_view), # DJ015
|
||||
path("/<slug:slug>", views.bad_view), # DJ015
|
||||
path("/bad/<slug:slug>/", views.bad_view), # DJ101
|
||||
path("/<slug:slug>", views.bad_view), # DJ101
|
||||
]
|
||||
|
|
@ -3,8 +3,8 @@ from . import views
|
|||
|
||||
# Test that custom path functions are also checked for leading slashes
|
||||
urlpatterns_custom = [
|
||||
mypath("/help/", views.help_view), # DJ015
|
||||
mypath("/about/", views.about_view), # DJ015
|
||||
mypath("/help/", views.help_view), # DJ101
|
||||
mypath("/about/", views.about_view), # DJ101
|
||||
]
|
||||
|
||||
# OK - custom path without leading slash
|
||||
|
|
@ -15,8 +15,8 @@ urlpatterns_custom_ok = [
|
|||
|
||||
# Test multiple violations in same list
|
||||
urlpatterns_multiple = [
|
||||
mypath("/api/users/", views.users_view), # DJ015
|
||||
mypath("/api/posts/", views.posts_view), # DJ015
|
||||
mypath("/api/users/", views.users_view), # DJ101
|
||||
mypath("/api/posts/", views.posts_view), # DJ101
|
||||
mypath("api/comments/", views.comments_view), # OK
|
||||
]
|
||||
|
||||
|
|
@ -1100,8 +1100,8 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> {
|
|||
(Flake8Django, "008") => rules::flake8_django::rules::DjangoModelWithoutDunderStr,
|
||||
(Flake8Django, "012") => rules::flake8_django::rules::DjangoUnorderedBodyContentInModel,
|
||||
(Flake8Django, "013") => rules::flake8_django::rules::DjangoNonLeadingReceiverDecorator,
|
||||
(Flake8Django, "014") => rules::flake8_django::rules::DjangoURLPathWithoutTrailingSlash,
|
||||
(Flake8Django, "015") => rules::flake8_django::rules::DjangoURLPathWithLeadingSlash,
|
||||
(Flake8Django, "100") => rules::flake8_django::rules::DjangoURLPathWithoutTrailingSlash,
|
||||
(Flake8Django, "101") => rules::flake8_django::rules::DjangoURLPathWithLeadingSlash,
|
||||
|
||||
// flynt
|
||||
// Reserved: (Flynt, "001") => Rule: :StringConcatenationToFString,
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ mod tests {
|
|||
#[test_case(Rule::DjangoExcludeWithModelForm, Path::new("DJ006.py"))]
|
||||
#[test_case(Rule::DjangoAllWithModelForm, Path::new("DJ007.py"))]
|
||||
#[test_case(Rule::DjangoModelWithoutDunderStr, Path::new("DJ008.py"))]
|
||||
#[test_case(Rule::DjangoURLPathWithoutTrailingSlash, Path::new("DJ014.py"))]
|
||||
#[test_case(Rule::DjangoURLPathWithLeadingSlash, Path::new("DJ015.py"))]
|
||||
#[test_case(Rule::DjangoURLPathWithoutTrailingSlash, Path::new("DJ100.py"))]
|
||||
#[test_case(Rule::DjangoURLPathWithLeadingSlash, Path::new("DJ101.py"))]
|
||||
#[test_case(Rule::DjangoUnorderedBodyContentInModel, Path::new("DJ012.py"))]
|
||||
#[test_case(Rule::DjangoNonLeadingReceiverDecorator, Path::new("DJ013.py"))]
|
||||
fn rules(rule_code: Rule, path: &Path) -> Result<()> {
|
||||
|
|
@ -34,23 +34,23 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_additional_path_functions_dj014() -> Result<()> {
|
||||
fn test_additional_path_functions_dj100() -> Result<()> {
|
||||
let mut settings =
|
||||
settings::LinterSettings::for_rule(Rule::DjangoURLPathWithoutTrailingSlash);
|
||||
settings.flake8_django.additional_path_functions = vec!["mytools.path".to_string()];
|
||||
|
||||
let diagnostics = test_path(Path::new("flake8_django/DJ014_custom_paths.py"), &settings)?;
|
||||
assert_diagnostics!("DJ014_custom_paths.py", diagnostics);
|
||||
let diagnostics = test_path(Path::new("flake8_django/DJ100_custom_paths.py"), &settings)?;
|
||||
assert_diagnostics!("DJ100_custom_paths.py", diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_additional_path_functions_dj015() -> Result<()> {
|
||||
fn test_additional_path_functions_dj101() -> Result<()> {
|
||||
let mut settings = settings::LinterSettings::for_rule(Rule::DjangoURLPathWithLeadingSlash);
|
||||
settings.flake8_django.additional_path_functions = vec!["mytools.path".to_string()];
|
||||
|
||||
let diagnostics = test_path(Path::new("flake8_django/DJ015_custom_paths.py"), &settings)?;
|
||||
assert_diagnostics!("DJ015_custom_paths.py", diagnostics);
|
||||
let diagnostics = test_path(Path::new("flake8_django/DJ101_custom_paths.py"), &settings)?;
|
||||
assert_diagnostics!("DJ101_custom_paths.py", diagnostics);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ impl AlwaysFixableViolation for DjangoURLPathWithLeadingSlash {
|
|||
}
|
||||
}
|
||||
|
||||
/// DJ015
|
||||
/// DJ101
|
||||
pub(crate) fn url_path_with_leading_slash(checker: &Checker, call: &ast::ExprCall) {
|
||||
// Check if this is a call to django.urls.path or any additional configured path functions
|
||||
let is_path_function = checker
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ impl AlwaysFixableViolation for DjangoURLPathWithoutTrailingSlash {
|
|||
}
|
||||
}
|
||||
|
||||
/// DJ014
|
||||
/// DJ100
|
||||
pub(crate) fn url_path_without_trailing_slash(checker: &Checker, call: &ast::ExprCall) {
|
||||
// Check if this is a call to django.urls.path or any additional configured path functions
|
||||
let is_path_function = checker
|
||||
|
|
|
|||
|
|
@ -1,176 +0,0 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/flake8_django/mod.rs
|
||||
---
|
||||
DJ014 [*] URL route `help` is missing a trailing slash
|
||||
--> DJ014.py:6:10
|
||||
|
|
||||
4 | # Errors - missing trailing slash
|
||||
5 | urlpatterns = [
|
||||
6 | path("help", views.help_view), # DJ014
|
||||
| ^^^^^^
|
||||
7 | path("about", views.about_view), # DJ014
|
||||
8 | path("contact", views.contact_view), # DJ014
|
||||
|
|
||||
help: Add trailing slash
|
||||
3 |
|
||||
4 | # Errors - missing trailing slash
|
||||
5 | urlpatterns = [
|
||||
- path("help", views.help_view), # DJ014
|
||||
6 + path("help/", views.help_view), # DJ014
|
||||
7 | path("about", views.about_view), # DJ014
|
||||
8 | path("contact", views.contact_view), # DJ014
|
||||
9 | path("api/users", views.users_view), # DJ014
|
||||
|
||||
DJ014 [*] URL route `about` is missing a trailing slash
|
||||
--> DJ014.py:7:10
|
||||
|
|
||||
5 | urlpatterns = [
|
||||
6 | path("help", views.help_view), # DJ014
|
||||
7 | path("about", views.about_view), # DJ014
|
||||
| ^^^^^^^
|
||||
8 | path("contact", views.contact_view), # DJ014
|
||||
9 | path("api/users", views.users_view), # DJ014
|
||||
|
|
||||
help: Add trailing slash
|
||||
4 | # Errors - missing trailing slash
|
||||
5 | urlpatterns = [
|
||||
6 | path("help", views.help_view), # DJ014
|
||||
- path("about", views.about_view), # DJ014
|
||||
7 + path("about/", views.about_view), # DJ014
|
||||
8 | path("contact", views.contact_view), # DJ014
|
||||
9 | path("api/users", views.users_view), # DJ014
|
||||
10 | path("blog/posts", views.posts_view), # DJ014
|
||||
|
||||
DJ014 [*] URL route `contact` is missing a trailing slash
|
||||
--> DJ014.py:8:10
|
||||
|
|
||||
6 | path("help", views.help_view), # DJ014
|
||||
7 | path("about", views.about_view), # DJ014
|
||||
8 | path("contact", views.contact_view), # DJ014
|
||||
| ^^^^^^^^^
|
||||
9 | path("api/users", views.users_view), # DJ014
|
||||
10 | path("blog/posts", views.posts_view), # DJ014
|
||||
|
|
||||
help: Add trailing slash
|
||||
5 | urlpatterns = [
|
||||
6 | path("help", views.help_view), # DJ014
|
||||
7 | path("about", views.about_view), # DJ014
|
||||
- path("contact", views.contact_view), # DJ014
|
||||
8 + path("contact/", views.contact_view), # DJ014
|
||||
9 | path("api/users", views.users_view), # DJ014
|
||||
10 | path("blog/posts", views.posts_view), # DJ014
|
||||
11 | ]
|
||||
|
||||
DJ014 [*] URL route `api/users` is missing a trailing slash
|
||||
--> DJ014.py:9:10
|
||||
|
|
||||
7 | path("about", views.about_view), # DJ014
|
||||
8 | path("contact", views.contact_view), # DJ014
|
||||
9 | path("api/users", views.users_view), # DJ014
|
||||
| ^^^^^^^^^^^
|
||||
10 | path("blog/posts", views.posts_view), # DJ014
|
||||
11 | ]
|
||||
|
|
||||
help: Add trailing slash
|
||||
6 | path("help", views.help_view), # DJ014
|
||||
7 | path("about", views.about_view), # DJ014
|
||||
8 | path("contact", views.contact_view), # DJ014
|
||||
- path("api/users", views.users_view), # DJ014
|
||||
9 + path("api/users/", views.users_view), # DJ014
|
||||
10 | path("blog/posts", views.posts_view), # DJ014
|
||||
11 | ]
|
||||
12 |
|
||||
|
||||
DJ014 [*] URL route `blog/posts` is missing a trailing slash
|
||||
--> DJ014.py:10:10
|
||||
|
|
||||
8 | path("contact", views.contact_view), # DJ014
|
||||
9 | path("api/users", views.users_view), # DJ014
|
||||
10 | path("blog/posts", views.posts_view), # DJ014
|
||||
| ^^^^^^^^^^^^
|
||||
11 | ]
|
||||
|
|
||||
help: Add trailing slash
|
||||
7 | path("about", views.about_view), # DJ014
|
||||
8 | path("contact", views.contact_view), # DJ014
|
||||
9 | path("api/users", views.users_view), # DJ014
|
||||
- path("blog/posts", views.posts_view), # DJ014
|
||||
10 + path("blog/posts/", views.posts_view), # DJ014
|
||||
11 | ]
|
||||
12 |
|
||||
13 | # OK - has trailing slash
|
||||
|
||||
DJ014 [*] URL route `bad` is missing a trailing slash
|
||||
--> DJ014.py:37:10
|
||||
|
|
||||
35 | urlpatterns_mixed = [
|
||||
36 | path("good/", views.good_view),
|
||||
37 | path("bad", views.bad_view), # DJ014
|
||||
| ^^^^^
|
||||
38 | path("also-good/", views.also_good_view),
|
||||
39 | path("also-bad", views.also_bad_view), # DJ014
|
||||
|
|
||||
help: Add trailing slash
|
||||
34 | # Mixed cases
|
||||
35 | urlpatterns_mixed = [
|
||||
36 | path("good/", views.good_view),
|
||||
- path("bad", views.bad_view), # DJ014
|
||||
37 + path("bad/", views.bad_view), # DJ014
|
||||
38 | path("also-good/", views.also_good_view),
|
||||
39 | path("also-bad", views.also_bad_view), # DJ014
|
||||
40 | ]
|
||||
|
||||
DJ014 [*] URL route `also-bad` is missing a trailing slash
|
||||
--> DJ014.py:39:10
|
||||
|
|
||||
37 | path("bad", views.bad_view), # DJ014
|
||||
38 | path("also-good/", views.also_good_view),
|
||||
39 | path("also-bad", views.also_bad_view), # DJ014
|
||||
| ^^^^^^^^^^
|
||||
40 | ]
|
||||
|
|
||||
help: Add trailing slash
|
||||
36 | path("good/", views.good_view),
|
||||
37 | path("bad", views.bad_view), # DJ014
|
||||
38 | path("also-good/", views.also_good_view),
|
||||
- path("also-bad", views.also_bad_view), # DJ014
|
||||
39 + path("also-bad/", views.also_bad_view), # DJ014
|
||||
40 | ]
|
||||
41 |
|
||||
42 | # Error - missing trail slash and argument should stay in message
|
||||
|
||||
DJ014 [*] URL route `bad/<slug:slug>` is missing a trailing slash
|
||||
--> DJ014.py:44:10
|
||||
|
|
||||
42 | # Error - missing trail slash and argument should stay in message
|
||||
43 | urlpatterns_params_bad = [
|
||||
44 | path("bad/<slug:slug>", views.bad_view), # DJ014
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
45 | path("<slug:slug>", views.bad_view), # DJ014
|
||||
46 | ]
|
||||
|
|
||||
help: Add trailing slash
|
||||
41 |
|
||||
42 | # Error - missing trail slash and argument should stay in message
|
||||
43 | urlpatterns_params_bad = [
|
||||
- path("bad/<slug:slug>", views.bad_view), # DJ014
|
||||
44 + path("bad/<slug:slug>/", views.bad_view), # DJ014
|
||||
45 | path("<slug:slug>", views.bad_view), # DJ014
|
||||
46 | ]
|
||||
|
||||
DJ014 [*] URL route `<slug:slug>` is missing a trailing slash
|
||||
--> DJ014.py:45:10
|
||||
|
|
||||
43 | urlpatterns_params_bad = [
|
||||
44 | path("bad/<slug:slug>", views.bad_view), # DJ014
|
||||
45 | path("<slug:slug>", views.bad_view), # DJ014
|
||||
| ^^^^^^^^^^^^^
|
||||
46 | ]
|
||||
|
|
||||
help: Add trailing slash
|
||||
42 | # Error - missing trail slash and argument should stay in message
|
||||
43 | urlpatterns_params_bad = [
|
||||
44 | path("bad/<slug:slug>", views.bad_view), # DJ014
|
||||
- path("<slug:slug>", views.bad_view), # DJ014
|
||||
45 + path("<slug:slug>/", views.bad_view), # DJ014
|
||||
46 | ]
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/flake8_django/mod.rs
|
||||
---
|
||||
DJ014 [*] URL route `help` is missing a trailing slash
|
||||
--> DJ014_custom_paths.py:6:12
|
||||
|
|
||||
4 | # Test that custom path functions are also checked
|
||||
5 | urlpatterns_custom = [
|
||||
6 | mypath("help", views.help_view), # DJ014
|
||||
| ^^^^^^
|
||||
7 | mypath("about", views.about_view), # DJ014
|
||||
8 | ]
|
||||
|
|
||||
help: Add trailing slash
|
||||
3 |
|
||||
4 | # Test that custom path functions are also checked
|
||||
5 | urlpatterns_custom = [
|
||||
- mypath("help", views.help_view), # DJ014
|
||||
6 + mypath("help/", views.help_view), # DJ014
|
||||
7 | mypath("about", views.about_view), # DJ014
|
||||
8 | ]
|
||||
9 |
|
||||
|
||||
DJ014 [*] URL route `about` is missing a trailing slash
|
||||
--> DJ014_custom_paths.py:7:12
|
||||
|
|
||||
5 | urlpatterns_custom = [
|
||||
6 | mypath("help", views.help_view), # DJ014
|
||||
7 | mypath("about", views.about_view), # DJ014
|
||||
| ^^^^^^^
|
||||
8 | ]
|
||||
|
|
||||
help: Add trailing slash
|
||||
4 | # Test that custom path functions are also checked
|
||||
5 | urlpatterns_custom = [
|
||||
6 | mypath("help", views.help_view), # DJ014
|
||||
- mypath("about", views.about_view), # DJ014
|
||||
7 + mypath("about/", views.about_view), # DJ014
|
||||
8 | ]
|
||||
9 |
|
||||
10 | # OK - custom path with trailing slash
|
||||
|
||||
DJ014 [*] URL route `api/users` is missing a trailing slash
|
||||
--> DJ014_custom_paths.py:18:12
|
||||
|
|
||||
16 | # Test multiple violations in same list
|
||||
17 | urlpatterns_multiple = [
|
||||
18 | mypath("api/users", views.users_view), # DJ014
|
||||
| ^^^^^^^^^^^
|
||||
19 | mypath("api/posts", views.posts_view), # DJ014
|
||||
20 | mypath("api/comments/", views.comments_view), # OK
|
||||
|
|
||||
help: Add trailing slash
|
||||
15 |
|
||||
16 | # Test multiple violations in same list
|
||||
17 | urlpatterns_multiple = [
|
||||
- mypath("api/users", views.users_view), # DJ014
|
||||
18 + mypath("api/users/", views.users_view), # DJ014
|
||||
19 | mypath("api/posts", views.posts_view), # DJ014
|
||||
20 | mypath("api/comments/", views.comments_view), # OK
|
||||
21 | ]
|
||||
|
||||
DJ014 [*] URL route `api/posts` is missing a trailing slash
|
||||
--> DJ014_custom_paths.py:19:12
|
||||
|
|
||||
17 | urlpatterns_multiple = [
|
||||
18 | mypath("api/users", views.users_view), # DJ014
|
||||
19 | mypath("api/posts", views.posts_view), # DJ014
|
||||
| ^^^^^^^^^^^
|
||||
20 | mypath("api/comments/", views.comments_view), # OK
|
||||
21 | ]
|
||||
|
|
||||
help: Add trailing slash
|
||||
16 | # Test multiple violations in same list
|
||||
17 | urlpatterns_multiple = [
|
||||
18 | mypath("api/users", views.users_view), # DJ014
|
||||
- mypath("api/posts", views.posts_view), # DJ014
|
||||
19 + mypath("api/posts/", views.posts_view), # DJ014
|
||||
20 | mypath("api/comments/", views.comments_view), # OK
|
||||
21 | ]
|
||||
22 |
|
||||
|
|
@ -1,255 +0,0 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/flake8_django/mod.rs
|
||||
---
|
||||
DJ015 [*] URL route `/help/` has an unnecessary leading slash
|
||||
--> DJ015.py:6:10
|
||||
|
|
||||
4 | # Errors - leading slash
|
||||
5 | urlpatterns = [
|
||||
6 | path("/help/", views.help_view), # DJ015
|
||||
| ^^^^^^^^
|
||||
7 | path("/about/", views.about_view), # DJ015
|
||||
8 | path("/contact/", views.contact_view), # DJ015
|
||||
|
|
||||
help: Remove leading slash
|
||||
3 |
|
||||
4 | # Errors - leading slash
|
||||
5 | urlpatterns = [
|
||||
- path("/help/", views.help_view), # DJ015
|
||||
6 + path("help/", views.help_view), # DJ015
|
||||
7 | path("/about/", views.about_view), # DJ015
|
||||
8 | path("/contact/", views.contact_view), # DJ015
|
||||
9 | path("/api/users/", views.users_view), # DJ015
|
||||
|
||||
DJ015 [*] URL route `/about/` has an unnecessary leading slash
|
||||
--> DJ015.py:7:10
|
||||
|
|
||||
5 | urlpatterns = [
|
||||
6 | path("/help/", views.help_view), # DJ015
|
||||
7 | path("/about/", views.about_view), # DJ015
|
||||
| ^^^^^^^^^
|
||||
8 | path("/contact/", views.contact_view), # DJ015
|
||||
9 | path("/api/users/", views.users_view), # DJ015
|
||||
|
|
||||
help: Remove leading slash
|
||||
4 | # Errors - leading slash
|
||||
5 | urlpatterns = [
|
||||
6 | path("/help/", views.help_view), # DJ015
|
||||
- path("/about/", views.about_view), # DJ015
|
||||
7 + path("about/", views.about_view), # DJ015
|
||||
8 | path("/contact/", views.contact_view), # DJ015
|
||||
9 | path("/api/users/", views.users_view), # DJ015
|
||||
10 | path("/blog/posts/", views.posts_view), # DJ015
|
||||
|
||||
DJ015 [*] URL route `/contact/` has an unnecessary leading slash
|
||||
--> DJ015.py:8:10
|
||||
|
|
||||
6 | path("/help/", views.help_view), # DJ015
|
||||
7 | path("/about/", views.about_view), # DJ015
|
||||
8 | path("/contact/", views.contact_view), # DJ015
|
||||
| ^^^^^^^^^^^
|
||||
9 | path("/api/users/", views.users_view), # DJ015
|
||||
10 | path("/blog/posts/", views.posts_view), # DJ015
|
||||
|
|
||||
help: Remove leading slash
|
||||
5 | urlpatterns = [
|
||||
6 | path("/help/", views.help_view), # DJ015
|
||||
7 | path("/about/", views.about_view), # DJ015
|
||||
- path("/contact/", views.contact_view), # DJ015
|
||||
8 + path("contact/", views.contact_view), # DJ015
|
||||
9 | path("/api/users/", views.users_view), # DJ015
|
||||
10 | path("/blog/posts/", views.posts_view), # DJ015
|
||||
11 | ]
|
||||
|
||||
DJ015 [*] URL route `/api/users/` has an unnecessary leading slash
|
||||
--> DJ015.py:9:10
|
||||
|
|
||||
7 | path("/about/", views.about_view), # DJ015
|
||||
8 | path("/contact/", views.contact_view), # DJ015
|
||||
9 | path("/api/users/", views.users_view), # DJ015
|
||||
| ^^^^^^^^^^^^^
|
||||
10 | path("/blog/posts/", views.posts_view), # DJ015
|
||||
11 | ]
|
||||
|
|
||||
help: Remove leading slash
|
||||
6 | path("/help/", views.help_view), # DJ015
|
||||
7 | path("/about/", views.about_view), # DJ015
|
||||
8 | path("/contact/", views.contact_view), # DJ015
|
||||
- path("/api/users/", views.users_view), # DJ015
|
||||
9 + path("api/users/", views.users_view), # DJ015
|
||||
10 | path("/blog/posts/", views.posts_view), # DJ015
|
||||
11 | ]
|
||||
12 |
|
||||
|
||||
DJ015 [*] URL route `/blog/posts/` has an unnecessary leading slash
|
||||
--> DJ015.py:10:10
|
||||
|
|
||||
8 | path("/contact/", views.contact_view), # DJ015
|
||||
9 | path("/api/users/", views.users_view), # DJ015
|
||||
10 | path("/blog/posts/", views.posts_view), # DJ015
|
||||
| ^^^^^^^^^^^^^^
|
||||
11 | ]
|
||||
|
|
||||
help: Remove leading slash
|
||||
7 | path("/about/", views.about_view), # DJ015
|
||||
8 | path("/contact/", views.contact_view), # DJ015
|
||||
9 | path("/api/users/", views.users_view), # DJ015
|
||||
- path("/blog/posts/", views.posts_view), # DJ015
|
||||
10 + path("blog/posts/", views.posts_view), # DJ015
|
||||
11 | ]
|
||||
12 |
|
||||
13 | # OK - no leading slash
|
||||
|
||||
DJ015 [*] URL route `/bad/` has an unnecessary leading slash
|
||||
--> DJ015.py:37:10
|
||||
|
|
||||
35 | urlpatterns_mixed = [
|
||||
36 | path("good/", views.good_view),
|
||||
37 | path("/bad/", views.bad_view), # DJ015
|
||||
| ^^^^^^^
|
||||
38 | path("also-good/", views.also_good_view),
|
||||
39 | path("/also-bad/", views.also_bad_view), # DJ015
|
||||
|
|
||||
help: Remove leading slash
|
||||
34 | # Mixed cases
|
||||
35 | urlpatterns_mixed = [
|
||||
36 | path("good/", views.good_view),
|
||||
- path("/bad/", views.bad_view), # DJ015
|
||||
37 + path("bad/", views.bad_view), # DJ015
|
||||
38 | path("also-good/", views.also_good_view),
|
||||
39 | path("/also-bad/", views.also_bad_view), # DJ015
|
||||
40 | ]
|
||||
|
||||
DJ015 [*] URL route `/also-bad/` has an unnecessary leading slash
|
||||
--> DJ015.py:39:10
|
||||
|
|
||||
37 | path("/bad/", views.bad_view), # DJ015
|
||||
38 | path("also-good/", views.also_good_view),
|
||||
39 | path("/also-bad/", views.also_bad_view), # DJ015
|
||||
| ^^^^^^^^^^^^
|
||||
40 | ]
|
||||
|
|
||||
help: Remove leading slash
|
||||
36 | path("good/", views.good_view),
|
||||
37 | path("/bad/", views.bad_view), # DJ015
|
||||
38 | path("also-good/", views.also_good_view),
|
||||
- path("/also-bad/", views.also_bad_view), # DJ015
|
||||
39 + path("also-bad/", views.also_bad_view), # DJ015
|
||||
40 | ]
|
||||
41 |
|
||||
42 | # Edge cases with different quote styles
|
||||
|
||||
DJ015 [*] URL route `/single-quote/` has an unnecessary leading slash
|
||||
--> DJ015.py:44:10
|
||||
|
|
||||
42 | # Edge cases with different quote styles
|
||||
43 | urlpatterns_quotes = [
|
||||
44 | path('/single-quote/', views.single_quote_view), # DJ015
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
45 | path("/double-quote/", views.double_quote_view), # DJ015
|
||||
46 | path('''/triple-single/''', views.triple_single_view), # DJ015
|
||||
|
|
||||
help: Remove leading slash
|
||||
41 |
|
||||
42 | # Edge cases with different quote styles
|
||||
43 | urlpatterns_quotes = [
|
||||
- path('/single-quote/', views.single_quote_view), # DJ015
|
||||
44 + path('single-quote/', views.single_quote_view), # DJ015
|
||||
45 | path("/double-quote/", views.double_quote_view), # DJ015
|
||||
46 | path('''/triple-single/''', views.triple_single_view), # DJ015
|
||||
47 | path("""/triple-double/""", views.triple_double_view), # DJ015
|
||||
|
||||
DJ015 [*] URL route `/double-quote/` has an unnecessary leading slash
|
||||
--> DJ015.py:45:10
|
||||
|
|
||||
43 | urlpatterns_quotes = [
|
||||
44 | path('/single-quote/', views.single_quote_view), # DJ015
|
||||
45 | path("/double-quote/", views.double_quote_view), # DJ015
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
46 | path('''/triple-single/''', views.triple_single_view), # DJ015
|
||||
47 | path("""/triple-double/""", views.triple_double_view), # DJ015
|
||||
|
|
||||
help: Remove leading slash
|
||||
42 | # Edge cases with different quote styles
|
||||
43 | urlpatterns_quotes = [
|
||||
44 | path('/single-quote/', views.single_quote_view), # DJ015
|
||||
- path("/double-quote/", views.double_quote_view), # DJ015
|
||||
45 + path("double-quote/", views.double_quote_view), # DJ015
|
||||
46 | path('''/triple-single/''', views.triple_single_view), # DJ015
|
||||
47 | path("""/triple-double/""", views.triple_double_view), # DJ015
|
||||
48 | ]
|
||||
|
||||
DJ015 [*] URL route `/triple-single/` has an unnecessary leading slash
|
||||
--> DJ015.py:46:10
|
||||
|
|
||||
44 | path('/single-quote/', views.single_quote_view), # DJ015
|
||||
45 | path("/double-quote/", views.double_quote_view), # DJ015
|
||||
46 | path('''/triple-single/''', views.triple_single_view), # DJ015
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
47 | path("""/triple-double/""", views.triple_double_view), # DJ015
|
||||
48 | ]
|
||||
|
|
||||
help: Remove leading slash
|
||||
43 | urlpatterns_quotes = [
|
||||
44 | path('/single-quote/', views.single_quote_view), # DJ015
|
||||
45 | path("/double-quote/", views.double_quote_view), # DJ015
|
||||
- path('''/triple-single/''', views.triple_single_view), # DJ015
|
||||
46 + path('''triple-single/''', views.triple_single_view), # DJ015
|
||||
47 | path("""/triple-double/""", views.triple_double_view), # DJ015
|
||||
48 | ]
|
||||
49 |
|
||||
|
||||
DJ015 [*] URL route `/triple-double/` has an unnecessary leading slash
|
||||
--> DJ015.py:47:10
|
||||
|
|
||||
45 | path("/double-quote/", views.double_quote_view), # DJ015
|
||||
46 | path('''/triple-single/''', views.triple_single_view), # DJ015
|
||||
47 | path("""/triple-double/""", views.triple_double_view), # DJ015
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
48 | ]
|
||||
|
|
||||
help: Remove leading slash
|
||||
44 | path('/single-quote/', views.single_quote_view), # DJ015
|
||||
45 | path("/double-quote/", views.double_quote_view), # DJ015
|
||||
46 | path('''/triple-single/''', views.triple_single_view), # DJ015
|
||||
- path("""/triple-double/""", views.triple_double_view), # DJ015
|
||||
47 + path("""triple-double/""", views.triple_double_view), # DJ015
|
||||
48 | ]
|
||||
49 |
|
||||
50 | # Error - leading trail slash and argument should stay in message
|
||||
|
||||
DJ015 [*] URL route `/bad/<slug:slug>/` has an unnecessary leading slash
|
||||
--> DJ015.py:52:10
|
||||
|
|
||||
50 | # Error - leading trail slash and argument should stay in message
|
||||
51 | urlpatterns_params_bad = [
|
||||
52 | path("/bad/<slug:slug>/", views.bad_view), # DJ015
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
53 | path("/<slug:slug>", views.bad_view), # DJ015
|
||||
54 | ]
|
||||
|
|
||||
help: Remove leading slash
|
||||
49 |
|
||||
50 | # Error - leading trail slash and argument should stay in message
|
||||
51 | urlpatterns_params_bad = [
|
||||
- path("/bad/<slug:slug>/", views.bad_view), # DJ015
|
||||
52 + path("bad/<slug:slug>/", views.bad_view), # DJ015
|
||||
53 | path("/<slug:slug>", views.bad_view), # DJ015
|
||||
54 | ]
|
||||
|
||||
DJ015 [*] URL route `/<slug:slug>` has an unnecessary leading slash
|
||||
--> DJ015.py:53:10
|
||||
|
|
||||
51 | urlpatterns_params_bad = [
|
||||
52 | path("/bad/<slug:slug>/", views.bad_view), # DJ015
|
||||
53 | path("/<slug:slug>", views.bad_view), # DJ015
|
||||
| ^^^^^^^^^^^^^^
|
||||
54 | ]
|
||||
|
|
||||
help: Remove leading slash
|
||||
50 | # Error - leading trail slash and argument should stay in message
|
||||
51 | urlpatterns_params_bad = [
|
||||
52 | path("/bad/<slug:slug>/", views.bad_view), # DJ015
|
||||
- path("/<slug:slug>", views.bad_view), # DJ015
|
||||
53 + path("<slug:slug>", views.bad_view), # DJ015
|
||||
54 | ]
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/flake8_django/mod.rs
|
||||
---
|
||||
DJ015 [*] URL route `/help/` has an unnecessary leading slash
|
||||
--> DJ015_custom_paths.py:6:12
|
||||
|
|
||||
4 | # Test that custom path functions are also checked for leading slashes
|
||||
5 | urlpatterns_custom = [
|
||||
6 | mypath("/help/", views.help_view), # DJ015
|
||||
| ^^^^^^^^
|
||||
7 | mypath("/about/", views.about_view), # DJ015
|
||||
8 | ]
|
||||
|
|
||||
help: Remove leading slash
|
||||
3 |
|
||||
4 | # Test that custom path functions are also checked for leading slashes
|
||||
5 | urlpatterns_custom = [
|
||||
- mypath("/help/", views.help_view), # DJ015
|
||||
6 + mypath("help/", views.help_view), # DJ015
|
||||
7 | mypath("/about/", views.about_view), # DJ015
|
||||
8 | ]
|
||||
9 |
|
||||
|
||||
DJ015 [*] URL route `/about/` has an unnecessary leading slash
|
||||
--> DJ015_custom_paths.py:7:12
|
||||
|
|
||||
5 | urlpatterns_custom = [
|
||||
6 | mypath("/help/", views.help_view), # DJ015
|
||||
7 | mypath("/about/", views.about_view), # DJ015
|
||||
| ^^^^^^^^^
|
||||
8 | ]
|
||||
|
|
||||
help: Remove leading slash
|
||||
4 | # Test that custom path functions are also checked for leading slashes
|
||||
5 | urlpatterns_custom = [
|
||||
6 | mypath("/help/", views.help_view), # DJ015
|
||||
- mypath("/about/", views.about_view), # DJ015
|
||||
7 + mypath("about/", views.about_view), # DJ015
|
||||
8 | ]
|
||||
9 |
|
||||
10 | # OK - custom path without leading slash
|
||||
|
||||
DJ015 [*] URL route `/api/users/` has an unnecessary leading slash
|
||||
--> DJ015_custom_paths.py:18:12
|
||||
|
|
||||
16 | # Test multiple violations in same list
|
||||
17 | urlpatterns_multiple = [
|
||||
18 | mypath("/api/users/", views.users_view), # DJ015
|
||||
| ^^^^^^^^^^^^^
|
||||
19 | mypath("/api/posts/", views.posts_view), # DJ015
|
||||
20 | mypath("api/comments/", views.comments_view), # OK
|
||||
|
|
||||
help: Remove leading slash
|
||||
15 |
|
||||
16 | # Test multiple violations in same list
|
||||
17 | urlpatterns_multiple = [
|
||||
- mypath("/api/users/", views.users_view), # DJ015
|
||||
18 + mypath("api/users/", views.users_view), # DJ015
|
||||
19 | mypath("/api/posts/", views.posts_view), # DJ015
|
||||
20 | mypath("api/comments/", views.comments_view), # OK
|
||||
21 | ]
|
||||
|
||||
DJ015 [*] URL route `/api/posts/` has an unnecessary leading slash
|
||||
--> DJ015_custom_paths.py:19:12
|
||||
|
|
||||
17 | urlpatterns_multiple = [
|
||||
18 | mypath("/api/users/", views.users_view), # DJ015
|
||||
19 | mypath("/api/posts/", views.posts_view), # DJ015
|
||||
| ^^^^^^^^^^^^^
|
||||
20 | mypath("api/comments/", views.comments_view), # OK
|
||||
21 | ]
|
||||
|
|
||||
help: Remove leading slash
|
||||
16 | # Test multiple violations in same list
|
||||
17 | urlpatterns_multiple = [
|
||||
18 | mypath("/api/users/", views.users_view), # DJ015
|
||||
- mypath("/api/posts/", views.posts_view), # DJ015
|
||||
19 + mypath("api/posts/", views.posts_view), # DJ015
|
||||
20 | mypath("api/comments/", views.comments_view), # OK
|
||||
21 | ]
|
||||
22 |
|
||||
|
|
@ -0,0 +1,176 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/flake8_django/mod.rs
|
||||
---
|
||||
DJ100 [*] URL route `help` is missing a trailing slash
|
||||
--> DJ100.py:6:10
|
||||
|
|
||||
4 | # Errors - missing trailing slash
|
||||
5 | urlpatterns = [
|
||||
6 | path("help", views.help_view), # DJ100
|
||||
| ^^^^^^
|
||||
7 | path("about", views.about_view), # DJ100
|
||||
8 | path("contact", views.contact_view), # DJ100
|
||||
|
|
||||
help: Add trailing slash
|
||||
3 |
|
||||
4 | # Errors - missing trailing slash
|
||||
5 | urlpatterns = [
|
||||
- path("help", views.help_view), # DJ100
|
||||
6 + path("help/", views.help_view), # DJ100
|
||||
7 | path("about", views.about_view), # DJ100
|
||||
8 | path("contact", views.contact_view), # DJ100
|
||||
9 | path("api/users", views.users_view), # DJ100
|
||||
|
||||
DJ100 [*] URL route `about` is missing a trailing slash
|
||||
--> DJ100.py:7:10
|
||||
|
|
||||
5 | urlpatterns = [
|
||||
6 | path("help", views.help_view), # DJ100
|
||||
7 | path("about", views.about_view), # DJ100
|
||||
| ^^^^^^^
|
||||
8 | path("contact", views.contact_view), # DJ100
|
||||
9 | path("api/users", views.users_view), # DJ100
|
||||
|
|
||||
help: Add trailing slash
|
||||
4 | # Errors - missing trailing slash
|
||||
5 | urlpatterns = [
|
||||
6 | path("help", views.help_view), # DJ100
|
||||
- path("about", views.about_view), # DJ100
|
||||
7 + path("about/", views.about_view), # DJ100
|
||||
8 | path("contact", views.contact_view), # DJ100
|
||||
9 | path("api/users", views.users_view), # DJ100
|
||||
10 | path("blog/posts", views.posts_view), # DJ100
|
||||
|
||||
DJ100 [*] URL route `contact` is missing a trailing slash
|
||||
--> DJ100.py:8:10
|
||||
|
|
||||
6 | path("help", views.help_view), # DJ100
|
||||
7 | path("about", views.about_view), # DJ100
|
||||
8 | path("contact", views.contact_view), # DJ100
|
||||
| ^^^^^^^^^
|
||||
9 | path("api/users", views.users_view), # DJ100
|
||||
10 | path("blog/posts", views.posts_view), # DJ100
|
||||
|
|
||||
help: Add trailing slash
|
||||
5 | urlpatterns = [
|
||||
6 | path("help", views.help_view), # DJ100
|
||||
7 | path("about", views.about_view), # DJ100
|
||||
- path("contact", views.contact_view), # DJ100
|
||||
8 + path("contact/", views.contact_view), # DJ100
|
||||
9 | path("api/users", views.users_view), # DJ100
|
||||
10 | path("blog/posts", views.posts_view), # DJ100
|
||||
11 | ]
|
||||
|
||||
DJ100 [*] URL route `api/users` is missing a trailing slash
|
||||
--> DJ100.py:9:10
|
||||
|
|
||||
7 | path("about", views.about_view), # DJ100
|
||||
8 | path("contact", views.contact_view), # DJ100
|
||||
9 | path("api/users", views.users_view), # DJ100
|
||||
| ^^^^^^^^^^^
|
||||
10 | path("blog/posts", views.posts_view), # DJ100
|
||||
11 | ]
|
||||
|
|
||||
help: Add trailing slash
|
||||
6 | path("help", views.help_view), # DJ100
|
||||
7 | path("about", views.about_view), # DJ100
|
||||
8 | path("contact", views.contact_view), # DJ100
|
||||
- path("api/users", views.users_view), # DJ100
|
||||
9 + path("api/users/", views.users_view), # DJ100
|
||||
10 | path("blog/posts", views.posts_view), # DJ100
|
||||
11 | ]
|
||||
12 |
|
||||
|
||||
DJ100 [*] URL route `blog/posts` is missing a trailing slash
|
||||
--> DJ100.py:10:10
|
||||
|
|
||||
8 | path("contact", views.contact_view), # DJ100
|
||||
9 | path("api/users", views.users_view), # DJ100
|
||||
10 | path("blog/posts", views.posts_view), # DJ100
|
||||
| ^^^^^^^^^^^^
|
||||
11 | ]
|
||||
|
|
||||
help: Add trailing slash
|
||||
7 | path("about", views.about_view), # DJ100
|
||||
8 | path("contact", views.contact_view), # DJ100
|
||||
9 | path("api/users", views.users_view), # DJ100
|
||||
- path("blog/posts", views.posts_view), # DJ100
|
||||
10 + path("blog/posts/", views.posts_view), # DJ100
|
||||
11 | ]
|
||||
12 |
|
||||
13 | # OK - has trailing slash
|
||||
|
||||
DJ100 [*] URL route `bad` is missing a trailing slash
|
||||
--> DJ100.py:37:10
|
||||
|
|
||||
35 | urlpatterns_mixed = [
|
||||
36 | path("good/", views.good_view),
|
||||
37 | path("bad", views.bad_view), # DJ100
|
||||
| ^^^^^
|
||||
38 | path("also-good/", views.also_good_view),
|
||||
39 | path("also-bad", views.also_bad_view), # DJ100
|
||||
|
|
||||
help: Add trailing slash
|
||||
34 | # Mixed cases
|
||||
35 | urlpatterns_mixed = [
|
||||
36 | path("good/", views.good_view),
|
||||
- path("bad", views.bad_view), # DJ100
|
||||
37 + path("bad/", views.bad_view), # DJ100
|
||||
38 | path("also-good/", views.also_good_view),
|
||||
39 | path("also-bad", views.also_bad_view), # DJ100
|
||||
40 | ]
|
||||
|
||||
DJ100 [*] URL route `also-bad` is missing a trailing slash
|
||||
--> DJ100.py:39:10
|
||||
|
|
||||
37 | path("bad", views.bad_view), # DJ100
|
||||
38 | path("also-good/", views.also_good_view),
|
||||
39 | path("also-bad", views.also_bad_view), # DJ100
|
||||
| ^^^^^^^^^^
|
||||
40 | ]
|
||||
|
|
||||
help: Add trailing slash
|
||||
36 | path("good/", views.good_view),
|
||||
37 | path("bad", views.bad_view), # DJ100
|
||||
38 | path("also-good/", views.also_good_view),
|
||||
- path("also-bad", views.also_bad_view), # DJ100
|
||||
39 + path("also-bad/", views.also_bad_view), # DJ100
|
||||
40 | ]
|
||||
41 |
|
||||
42 | # Error - missing trail slash and argument should stay in message
|
||||
|
||||
DJ100 [*] URL route `bad/<slug:slug>` is missing a trailing slash
|
||||
--> DJ100.py:44:10
|
||||
|
|
||||
42 | # Error - missing trail slash and argument should stay in message
|
||||
43 | urlpatterns_params_bad = [
|
||||
44 | path("bad/<slug:slug>", views.bad_view), # DJ100
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
45 | path("<slug:slug>", views.bad_view), # DJ100
|
||||
46 | ]
|
||||
|
|
||||
help: Add trailing slash
|
||||
41 |
|
||||
42 | # Error - missing trail slash and argument should stay in message
|
||||
43 | urlpatterns_params_bad = [
|
||||
- path("bad/<slug:slug>", views.bad_view), # DJ100
|
||||
44 + path("bad/<slug:slug>/", views.bad_view), # DJ100
|
||||
45 | path("<slug:slug>", views.bad_view), # DJ100
|
||||
46 | ]
|
||||
|
||||
DJ100 [*] URL route `<slug:slug>` is missing a trailing slash
|
||||
--> DJ100.py:45:10
|
||||
|
|
||||
43 | urlpatterns_params_bad = [
|
||||
44 | path("bad/<slug:slug>", views.bad_view), # DJ100
|
||||
45 | path("<slug:slug>", views.bad_view), # DJ100
|
||||
| ^^^^^^^^^^^^^
|
||||
46 | ]
|
||||
|
|
||||
help: Add trailing slash
|
||||
42 | # Error - missing trail slash and argument should stay in message
|
||||
43 | urlpatterns_params_bad = [
|
||||
44 | path("bad/<slug:slug>", views.bad_view), # DJ100
|
||||
- path("<slug:slug>", views.bad_view), # DJ100
|
||||
45 + path("<slug:slug>/", views.bad_view), # DJ100
|
||||
46 | ]
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/flake8_django/mod.rs
|
||||
---
|
||||
DJ100 [*] URL route `help` is missing a trailing slash
|
||||
--> DJ100_custom_paths.py:6:12
|
||||
|
|
||||
4 | # Test that custom path functions are also checked
|
||||
5 | urlpatterns_custom = [
|
||||
6 | mypath("help", views.help_view), # DJ100
|
||||
| ^^^^^^
|
||||
7 | mypath("about", views.about_view), # DJ100
|
||||
8 | ]
|
||||
|
|
||||
help: Add trailing slash
|
||||
3 |
|
||||
4 | # Test that custom path functions are also checked
|
||||
5 | urlpatterns_custom = [
|
||||
- mypath("help", views.help_view), # DJ100
|
||||
6 + mypath("help/", views.help_view), # DJ100
|
||||
7 | mypath("about", views.about_view), # DJ100
|
||||
8 | ]
|
||||
9 |
|
||||
|
||||
DJ100 [*] URL route `about` is missing a trailing slash
|
||||
--> DJ100_custom_paths.py:7:12
|
||||
|
|
||||
5 | urlpatterns_custom = [
|
||||
6 | mypath("help", views.help_view), # DJ100
|
||||
7 | mypath("about", views.about_view), # DJ100
|
||||
| ^^^^^^^
|
||||
8 | ]
|
||||
|
|
||||
help: Add trailing slash
|
||||
4 | # Test that custom path functions are also checked
|
||||
5 | urlpatterns_custom = [
|
||||
6 | mypath("help", views.help_view), # DJ100
|
||||
- mypath("about", views.about_view), # DJ100
|
||||
7 + mypath("about/", views.about_view), # DJ100
|
||||
8 | ]
|
||||
9 |
|
||||
10 | # OK - custom path with trailing slash
|
||||
|
||||
DJ100 [*] URL route `api/users` is missing a trailing slash
|
||||
--> DJ100_custom_paths.py:18:12
|
||||
|
|
||||
16 | # Test multiple violations in same list
|
||||
17 | urlpatterns_multiple = [
|
||||
18 | mypath("api/users", views.users_view), # DJ100
|
||||
| ^^^^^^^^^^^
|
||||
19 | mypath("api/posts", views.posts_view), # DJ100
|
||||
20 | mypath("api/comments/", views.comments_view), # OK
|
||||
|
|
||||
help: Add trailing slash
|
||||
15 |
|
||||
16 | # Test multiple violations in same list
|
||||
17 | urlpatterns_multiple = [
|
||||
- mypath("api/users", views.users_view), # DJ100
|
||||
18 + mypath("api/users/", views.users_view), # DJ100
|
||||
19 | mypath("api/posts", views.posts_view), # DJ100
|
||||
20 | mypath("api/comments/", views.comments_view), # OK
|
||||
21 | ]
|
||||
|
||||
DJ100 [*] URL route `api/posts` is missing a trailing slash
|
||||
--> DJ100_custom_paths.py:19:12
|
||||
|
|
||||
17 | urlpatterns_multiple = [
|
||||
18 | mypath("api/users", views.users_view), # DJ100
|
||||
19 | mypath("api/posts", views.posts_view), # DJ100
|
||||
| ^^^^^^^^^^^
|
||||
20 | mypath("api/comments/", views.comments_view), # OK
|
||||
21 | ]
|
||||
|
|
||||
help: Add trailing slash
|
||||
16 | # Test multiple violations in same list
|
||||
17 | urlpatterns_multiple = [
|
||||
18 | mypath("api/users", views.users_view), # DJ100
|
||||
- mypath("api/posts", views.posts_view), # DJ100
|
||||
19 + mypath("api/posts/", views.posts_view), # DJ100
|
||||
20 | mypath("api/comments/", views.comments_view), # OK
|
||||
21 | ]
|
||||
22 |
|
||||
|
|
@ -0,0 +1,255 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/flake8_django/mod.rs
|
||||
---
|
||||
DJ101 [*] URL route `/help/` has an unnecessary leading slash
|
||||
--> DJ101.py:6:10
|
||||
|
|
||||
4 | # Errors - leading slash
|
||||
5 | urlpatterns = [
|
||||
6 | path("/help/", views.help_view), # DJ101
|
||||
| ^^^^^^^^
|
||||
7 | path("/about/", views.about_view), # DJ101
|
||||
8 | path("/contact/", views.contact_view), # DJ101
|
||||
|
|
||||
help: Remove leading slash
|
||||
3 |
|
||||
4 | # Errors - leading slash
|
||||
5 | urlpatterns = [
|
||||
- path("/help/", views.help_view), # DJ101
|
||||
6 + path("help/", views.help_view), # DJ101
|
||||
7 | path("/about/", views.about_view), # DJ101
|
||||
8 | path("/contact/", views.contact_view), # DJ101
|
||||
9 | path("/api/users/", views.users_view), # DJ101
|
||||
|
||||
DJ101 [*] URL route `/about/` has an unnecessary leading slash
|
||||
--> DJ101.py:7:10
|
||||
|
|
||||
5 | urlpatterns = [
|
||||
6 | path("/help/", views.help_view), # DJ101
|
||||
7 | path("/about/", views.about_view), # DJ101
|
||||
| ^^^^^^^^^
|
||||
8 | path("/contact/", views.contact_view), # DJ101
|
||||
9 | path("/api/users/", views.users_view), # DJ101
|
||||
|
|
||||
help: Remove leading slash
|
||||
4 | # Errors - leading slash
|
||||
5 | urlpatterns = [
|
||||
6 | path("/help/", views.help_view), # DJ101
|
||||
- path("/about/", views.about_view), # DJ101
|
||||
7 + path("about/", views.about_view), # DJ101
|
||||
8 | path("/contact/", views.contact_view), # DJ101
|
||||
9 | path("/api/users/", views.users_view), # DJ101
|
||||
10 | path("/blog/posts/", views.posts_view), # DJ101
|
||||
|
||||
DJ101 [*] URL route `/contact/` has an unnecessary leading slash
|
||||
--> DJ101.py:8:10
|
||||
|
|
||||
6 | path("/help/", views.help_view), # DJ101
|
||||
7 | path("/about/", views.about_view), # DJ101
|
||||
8 | path("/contact/", views.contact_view), # DJ101
|
||||
| ^^^^^^^^^^^
|
||||
9 | path("/api/users/", views.users_view), # DJ101
|
||||
10 | path("/blog/posts/", views.posts_view), # DJ101
|
||||
|
|
||||
help: Remove leading slash
|
||||
5 | urlpatterns = [
|
||||
6 | path("/help/", views.help_view), # DJ101
|
||||
7 | path("/about/", views.about_view), # DJ101
|
||||
- path("/contact/", views.contact_view), # DJ101
|
||||
8 + path("contact/", views.contact_view), # DJ101
|
||||
9 | path("/api/users/", views.users_view), # DJ101
|
||||
10 | path("/blog/posts/", views.posts_view), # DJ101
|
||||
11 | ]
|
||||
|
||||
DJ101 [*] URL route `/api/users/` has an unnecessary leading slash
|
||||
--> DJ101.py:9:10
|
||||
|
|
||||
7 | path("/about/", views.about_view), # DJ101
|
||||
8 | path("/contact/", views.contact_view), # DJ101
|
||||
9 | path("/api/users/", views.users_view), # DJ101
|
||||
| ^^^^^^^^^^^^^
|
||||
10 | path("/blog/posts/", views.posts_view), # DJ101
|
||||
11 | ]
|
||||
|
|
||||
help: Remove leading slash
|
||||
6 | path("/help/", views.help_view), # DJ101
|
||||
7 | path("/about/", views.about_view), # DJ101
|
||||
8 | path("/contact/", views.contact_view), # DJ101
|
||||
- path("/api/users/", views.users_view), # DJ101
|
||||
9 + path("api/users/", views.users_view), # DJ101
|
||||
10 | path("/blog/posts/", views.posts_view), # DJ101
|
||||
11 | ]
|
||||
12 |
|
||||
|
||||
DJ101 [*] URL route `/blog/posts/` has an unnecessary leading slash
|
||||
--> DJ101.py:10:10
|
||||
|
|
||||
8 | path("/contact/", views.contact_view), # DJ101
|
||||
9 | path("/api/users/", views.users_view), # DJ101
|
||||
10 | path("/blog/posts/", views.posts_view), # DJ101
|
||||
| ^^^^^^^^^^^^^^
|
||||
11 | ]
|
||||
|
|
||||
help: Remove leading slash
|
||||
7 | path("/about/", views.about_view), # DJ101
|
||||
8 | path("/contact/", views.contact_view), # DJ101
|
||||
9 | path("/api/users/", views.users_view), # DJ101
|
||||
- path("/blog/posts/", views.posts_view), # DJ101
|
||||
10 + path("blog/posts/", views.posts_view), # DJ101
|
||||
11 | ]
|
||||
12 |
|
||||
13 | # OK - no leading slash
|
||||
|
||||
DJ101 [*] URL route `/bad/` has an unnecessary leading slash
|
||||
--> DJ101.py:37:10
|
||||
|
|
||||
35 | urlpatterns_mixed = [
|
||||
36 | path("good/", views.good_view),
|
||||
37 | path("/bad/", views.bad_view), # DJ101
|
||||
| ^^^^^^^
|
||||
38 | path("also-good/", views.also_good_view),
|
||||
39 | path("/also-bad/", views.also_bad_view), # DJ101
|
||||
|
|
||||
help: Remove leading slash
|
||||
34 | # Mixed cases
|
||||
35 | urlpatterns_mixed = [
|
||||
36 | path("good/", views.good_view),
|
||||
- path("/bad/", views.bad_view), # DJ101
|
||||
37 + path("bad/", views.bad_view), # DJ101
|
||||
38 | path("also-good/", views.also_good_view),
|
||||
39 | path("/also-bad/", views.also_bad_view), # DJ101
|
||||
40 | ]
|
||||
|
||||
DJ101 [*] URL route `/also-bad/` has an unnecessary leading slash
|
||||
--> DJ101.py:39:10
|
||||
|
|
||||
37 | path("/bad/", views.bad_view), # DJ101
|
||||
38 | path("also-good/", views.also_good_view),
|
||||
39 | path("/also-bad/", views.also_bad_view), # DJ101
|
||||
| ^^^^^^^^^^^^
|
||||
40 | ]
|
||||
|
|
||||
help: Remove leading slash
|
||||
36 | path("good/", views.good_view),
|
||||
37 | path("/bad/", views.bad_view), # DJ101
|
||||
38 | path("also-good/", views.also_good_view),
|
||||
- path("/also-bad/", views.also_bad_view), # DJ101
|
||||
39 + path("also-bad/", views.also_bad_view), # DJ101
|
||||
40 | ]
|
||||
41 |
|
||||
42 | # Edge cases with different quote styles
|
||||
|
||||
DJ101 [*] URL route `/single-quote/` has an unnecessary leading slash
|
||||
--> DJ101.py:44:10
|
||||
|
|
||||
42 | # Edge cases with different quote styles
|
||||
43 | urlpatterns_quotes = [
|
||||
44 | path('/single-quote/', views.single_quote_view), # DJ101
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
45 | path("/double-quote/", views.double_quote_view), # DJ101
|
||||
46 | path('''/triple-single/''', views.triple_single_view), # DJ101
|
||||
|
|
||||
help: Remove leading slash
|
||||
41 |
|
||||
42 | # Edge cases with different quote styles
|
||||
43 | urlpatterns_quotes = [
|
||||
- path('/single-quote/', views.single_quote_view), # DJ101
|
||||
44 + path('single-quote/', views.single_quote_view), # DJ101
|
||||
45 | path("/double-quote/", views.double_quote_view), # DJ101
|
||||
46 | path('''/triple-single/''', views.triple_single_view), # DJ101
|
||||
47 | path("""/triple-double/""", views.triple_double_view), # DJ101
|
||||
|
||||
DJ101 [*] URL route `/double-quote/` has an unnecessary leading slash
|
||||
--> DJ101.py:45:10
|
||||
|
|
||||
43 | urlpatterns_quotes = [
|
||||
44 | path('/single-quote/', views.single_quote_view), # DJ101
|
||||
45 | path("/double-quote/", views.double_quote_view), # DJ101
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
46 | path('''/triple-single/''', views.triple_single_view), # DJ101
|
||||
47 | path("""/triple-double/""", views.triple_double_view), # DJ101
|
||||
|
|
||||
help: Remove leading slash
|
||||
42 | # Edge cases with different quote styles
|
||||
43 | urlpatterns_quotes = [
|
||||
44 | path('/single-quote/', views.single_quote_view), # DJ101
|
||||
- path("/double-quote/", views.double_quote_view), # DJ101
|
||||
45 + path("double-quote/", views.double_quote_view), # DJ101
|
||||
46 | path('''/triple-single/''', views.triple_single_view), # DJ101
|
||||
47 | path("""/triple-double/""", views.triple_double_view), # DJ101
|
||||
48 | ]
|
||||
|
||||
DJ101 [*] URL route `/triple-single/` has an unnecessary leading slash
|
||||
--> DJ101.py:46:10
|
||||
|
|
||||
44 | path('/single-quote/', views.single_quote_view), # DJ101
|
||||
45 | path("/double-quote/", views.double_quote_view), # DJ101
|
||||
46 | path('''/triple-single/''', views.triple_single_view), # DJ101
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
47 | path("""/triple-double/""", views.triple_double_view), # DJ101
|
||||
48 | ]
|
||||
|
|
||||
help: Remove leading slash
|
||||
43 | urlpatterns_quotes = [
|
||||
44 | path('/single-quote/', views.single_quote_view), # DJ101
|
||||
45 | path("/double-quote/", views.double_quote_view), # DJ101
|
||||
- path('''/triple-single/''', views.triple_single_view), # DJ101
|
||||
46 + path('''triple-single/''', views.triple_single_view), # DJ101
|
||||
47 | path("""/triple-double/""", views.triple_double_view), # DJ101
|
||||
48 | ]
|
||||
49 |
|
||||
|
||||
DJ101 [*] URL route `/triple-double/` has an unnecessary leading slash
|
||||
--> DJ101.py:47:10
|
||||
|
|
||||
45 | path("/double-quote/", views.double_quote_view), # DJ101
|
||||
46 | path('''/triple-single/''', views.triple_single_view), # DJ101
|
||||
47 | path("""/triple-double/""", views.triple_double_view), # DJ101
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
48 | ]
|
||||
|
|
||||
help: Remove leading slash
|
||||
44 | path('/single-quote/', views.single_quote_view), # DJ101
|
||||
45 | path("/double-quote/", views.double_quote_view), # DJ101
|
||||
46 | path('''/triple-single/''', views.triple_single_view), # DJ101
|
||||
- path("""/triple-double/""", views.triple_double_view), # DJ101
|
||||
47 + path("""triple-double/""", views.triple_double_view), # DJ101
|
||||
48 | ]
|
||||
49 |
|
||||
50 | # Error - leading trail slash and argument should stay in message
|
||||
|
||||
DJ101 [*] URL route `/bad/<slug:slug>/` has an unnecessary leading slash
|
||||
--> DJ101.py:52:10
|
||||
|
|
||||
50 | # Error - leading trail slash and argument should stay in message
|
||||
51 | urlpatterns_params_bad = [
|
||||
52 | path("/bad/<slug:slug>/", views.bad_view), # DJ101
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
53 | path("/<slug:slug>", views.bad_view), # DJ101
|
||||
54 | ]
|
||||
|
|
||||
help: Remove leading slash
|
||||
49 |
|
||||
50 | # Error - leading trail slash and argument should stay in message
|
||||
51 | urlpatterns_params_bad = [
|
||||
- path("/bad/<slug:slug>/", views.bad_view), # DJ101
|
||||
52 + path("bad/<slug:slug>/", views.bad_view), # DJ101
|
||||
53 | path("/<slug:slug>", views.bad_view), # DJ101
|
||||
54 | ]
|
||||
|
||||
DJ101 [*] URL route `/<slug:slug>` has an unnecessary leading slash
|
||||
--> DJ101.py:53:10
|
||||
|
|
||||
51 | urlpatterns_params_bad = [
|
||||
52 | path("/bad/<slug:slug>/", views.bad_view), # DJ101
|
||||
53 | path("/<slug:slug>", views.bad_view), # DJ101
|
||||
| ^^^^^^^^^^^^^^
|
||||
54 | ]
|
||||
|
|
||||
help: Remove leading slash
|
||||
50 | # Error - leading trail slash and argument should stay in message
|
||||
51 | urlpatterns_params_bad = [
|
||||
52 | path("/bad/<slug:slug>/", views.bad_view), # DJ101
|
||||
- path("/<slug:slug>", views.bad_view), # DJ101
|
||||
53 + path("<slug:slug>", views.bad_view), # DJ101
|
||||
54 | ]
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/flake8_django/mod.rs
|
||||
---
|
||||
DJ101 [*] URL route `/help/` has an unnecessary leading slash
|
||||
--> DJ101_custom_paths.py:6:12
|
||||
|
|
||||
4 | # Test that custom path functions are also checked for leading slashes
|
||||
5 | urlpatterns_custom = [
|
||||
6 | mypath("/help/", views.help_view), # DJ101
|
||||
| ^^^^^^^^
|
||||
7 | mypath("/about/", views.about_view), # DJ101
|
||||
8 | ]
|
||||
|
|
||||
help: Remove leading slash
|
||||
3 |
|
||||
4 | # Test that custom path functions are also checked for leading slashes
|
||||
5 | urlpatterns_custom = [
|
||||
- mypath("/help/", views.help_view), # DJ101
|
||||
6 + mypath("help/", views.help_view), # DJ101
|
||||
7 | mypath("/about/", views.about_view), # DJ101
|
||||
8 | ]
|
||||
9 |
|
||||
|
||||
DJ101 [*] URL route `/about/` has an unnecessary leading slash
|
||||
--> DJ101_custom_paths.py:7:12
|
||||
|
|
||||
5 | urlpatterns_custom = [
|
||||
6 | mypath("/help/", views.help_view), # DJ101
|
||||
7 | mypath("/about/", views.about_view), # DJ101
|
||||
| ^^^^^^^^^
|
||||
8 | ]
|
||||
|
|
||||
help: Remove leading slash
|
||||
4 | # Test that custom path functions are also checked for leading slashes
|
||||
5 | urlpatterns_custom = [
|
||||
6 | mypath("/help/", views.help_view), # DJ101
|
||||
- mypath("/about/", views.about_view), # DJ101
|
||||
7 + mypath("about/", views.about_view), # DJ101
|
||||
8 | ]
|
||||
9 |
|
||||
10 | # OK - custom path without leading slash
|
||||
|
||||
DJ101 [*] URL route `/api/users/` has an unnecessary leading slash
|
||||
--> DJ101_custom_paths.py:18:12
|
||||
|
|
||||
16 | # Test multiple violations in same list
|
||||
17 | urlpatterns_multiple = [
|
||||
18 | mypath("/api/users/", views.users_view), # DJ101
|
||||
| ^^^^^^^^^^^^^
|
||||
19 | mypath("/api/posts/", views.posts_view), # DJ101
|
||||
20 | mypath("api/comments/", views.comments_view), # OK
|
||||
|
|
||||
help: Remove leading slash
|
||||
15 |
|
||||
16 | # Test multiple violations in same list
|
||||
17 | urlpatterns_multiple = [
|
||||
- mypath("/api/users/", views.users_view), # DJ101
|
||||
18 + mypath("api/users/", views.users_view), # DJ101
|
||||
19 | mypath("/api/posts/", views.posts_view), # DJ101
|
||||
20 | mypath("api/comments/", views.comments_view), # OK
|
||||
21 | ]
|
||||
|
||||
DJ101 [*] URL route `/api/posts/` has an unnecessary leading slash
|
||||
--> DJ101_custom_paths.py:19:12
|
||||
|
|
||||
17 | urlpatterns_multiple = [
|
||||
18 | mypath("/api/users/", views.users_view), # DJ101
|
||||
19 | mypath("/api/posts/", views.posts_view), # DJ101
|
||||
| ^^^^^^^^^^^^^
|
||||
20 | mypath("api/comments/", views.comments_view), # OK
|
||||
21 | ]
|
||||
|
|
||||
help: Remove leading slash
|
||||
16 | # Test multiple violations in same list
|
||||
17 | urlpatterns_multiple = [
|
||||
18 | mypath("/api/users/", views.users_view), # DJ101
|
||||
- mypath("/api/posts/", views.posts_view), # DJ101
|
||||
19 + mypath("api/posts/", views.posts_view), # DJ101
|
||||
20 | mypath("api/comments/", views.comments_view), # OK
|
||||
21 | ]
|
||||
22 |
|
||||
|
|
@ -3197,8 +3197,10 @@
|
|||
"DJ01",
|
||||
"DJ012",
|
||||
"DJ013",
|
||||
"DJ014",
|
||||
"DJ015",
|
||||
"DJ1",
|
||||
"DJ10",
|
||||
"DJ100",
|
||||
"DJ101",
|
||||
"DOC",
|
||||
"DOC1",
|
||||
"DOC10",
|
||||
|
|
|
|||
Loading…
Reference in New Issue