mirror of https://github.com/astral-sh/ruff
Disallow rule names starting with avoid-*
This commit is contained in:
parent
1a97de0b01
commit
ec63658250
|
|
@ -1193,7 +1193,7 @@ For more, see [flake8-quotes](https://pypi.org/project/flake8-quotes/) on PyPI.
|
|||
| Q000 | [bad-quotes-inline-string](https://github.com/charliermarsh/ruff/blob/main/docs/rules/bad-quotes-inline-string.md) | Double quotes found but single quotes preferred | 🛠 |
|
||||
| Q001 | [bad-quotes-multiline-string](https://github.com/charliermarsh/ruff/blob/main/docs/rules/bad-quotes-multiline-string.md) | Double quote multiline found but single quotes preferred | 🛠 |
|
||||
| Q002 | [bad-quotes-docstring](https://github.com/charliermarsh/ruff/blob/main/docs/rules/bad-quotes-docstring.md) | Double quote docstring found but single quotes preferred | 🛠 |
|
||||
| Q003 | [avoid-quote-escape](https://github.com/charliermarsh/ruff/blob/main/docs/rules/avoid-quote-escape.md) | Change outer quotes to avoid escaping inner quotes | 🛠 |
|
||||
| Q003 | [avoidable-escaped-quote](https://github.com/charliermarsh/ruff/blob/main/docs/rules/avoidable-escaped-quote.md) | Change outer quotes to avoid escaping inner quotes | 🛠 |
|
||||
|
||||
### flake8-return (RET)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
avoid-*
|
||||
do-not-*
|
||||
uses-*
|
||||
*-used
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ pub fn check_tokens(
|
|||
let enforce_quotes = settings.rules.enabled(&Rule::BadQuotesInlineString)
|
||||
|| settings.rules.enabled(&Rule::BadQuotesMultilineString)
|
||||
|| settings.rules.enabled(&Rule::BadQuotesDocstring)
|
||||
|| settings.rules.enabled(&Rule::AvoidQuoteEscape);
|
||||
|| settings.rules.enabled(&Rule::AvoidableEscapedQuote);
|
||||
let enforce_commented_out_code = settings.rules.enabled(&Rule::CommentedOutCode);
|
||||
let enforce_compound_statements = settings
|
||||
.rules
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ ruff_macros::define_rule_mapping!(
|
|||
Q000 => rules::flake8_quotes::rules::BadQuotesInlineString,
|
||||
Q001 => rules::flake8_quotes::rules::BadQuotesMultilineString,
|
||||
Q002 => rules::flake8_quotes::rules::BadQuotesDocstring,
|
||||
Q003 => rules::flake8_quotes::rules::AvoidQuoteEscape,
|
||||
Q003 => rules::flake8_quotes::rules::AvoidableEscapedQuote,
|
||||
// flake8-annotations
|
||||
ANN001 => rules::flake8_annotations::rules::MissingTypeFunctionArgument,
|
||||
ANN002 => rules::flake8_annotations::rules::MissingTypeArgs,
|
||||
|
|
@ -759,7 +759,7 @@ impl Rule {
|
|||
Rule::AmbiguousUnicodeCharacterComment
|
||||
| Rule::AmbiguousUnicodeCharacterDocstring
|
||||
| Rule::AmbiguousUnicodeCharacterString
|
||||
| Rule::AvoidQuoteEscape
|
||||
| Rule::AvoidableEscapedQuote
|
||||
| Rule::BadQuotesDocstring
|
||||
| Rule::BadQuotesInlineString
|
||||
| Rule::BadQuotesMultilineString
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ mod tests {
|
|||
Rule::BadQuotesInlineString,
|
||||
Rule::BadQuotesMultilineString,
|
||||
Rule::BadQuotesDocstring,
|
||||
Rule::AvoidQuoteEscape,
|
||||
Rule::AvoidableEscapedQuote,
|
||||
])
|
||||
},
|
||||
)?;
|
||||
|
|
@ -65,7 +65,7 @@ mod tests {
|
|||
Rule::BadQuotesInlineString,
|
||||
Rule::BadQuotesMultilineString,
|
||||
Rule::BadQuotesDocstring,
|
||||
Rule::AvoidQuoteEscape,
|
||||
Rule::AvoidableEscapedQuote,
|
||||
])
|
||||
},
|
||||
)?;
|
||||
|
|
@ -98,7 +98,7 @@ mod tests {
|
|||
Rule::BadQuotesInlineString,
|
||||
Rule::BadQuotesMultilineString,
|
||||
Rule::BadQuotesDocstring,
|
||||
Rule::AvoidQuoteEscape,
|
||||
Rule::AvoidableEscapedQuote,
|
||||
])
|
||||
},
|
||||
)?;
|
||||
|
|
@ -131,7 +131,7 @@ mod tests {
|
|||
Rule::BadQuotesInlineString,
|
||||
Rule::BadQuotesMultilineString,
|
||||
Rule::BadQuotesDocstring,
|
||||
Rule::AvoidQuoteEscape,
|
||||
Rule::AvoidableEscapedQuote,
|
||||
])
|
||||
},
|
||||
)?;
|
||||
|
|
|
|||
|
|
@ -162,9 +162,9 @@ define_violation!(
|
|||
/// ```python
|
||||
/// foo = "bar's"
|
||||
/// ```
|
||||
pub struct AvoidQuoteEscape;
|
||||
pub struct AvoidableEscapedQuote;
|
||||
);
|
||||
impl AlwaysAutofixableViolation for AvoidQuoteEscape {
|
||||
impl AlwaysAutofixableViolation for AvoidableEscapedQuote {
|
||||
#[derive_message_formats]
|
||||
fn message(&self) -> String {
|
||||
format!("Change outer quotes to avoid escaping inner quotes")
|
||||
|
|
@ -379,9 +379,9 @@ fn strings(
|
|||
&& !string_contents.contains(bad_single("es_settings.inline_quotes))
|
||||
{
|
||||
let mut diagnostic =
|
||||
Diagnostic::new(AvoidQuoteEscape, Range::new(*start, *end));
|
||||
Diagnostic::new(AvoidableEscapedQuote, Range::new(*start, *end));
|
||||
if matches!(autofix, flags::Autofix::Enabled)
|
||||
&& settings.rules.should_fix(&Rule::AvoidQuoteEscape)
|
||||
&& settings.rules.should_fix(&Rule::AvoidableEscapedQuote)
|
||||
{
|
||||
let quote = bad_single("es_settings.inline_quotes);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
---
|
||||
source: src/rules/flake8_quotes/mod.rs
|
||||
source: crates/ruff/src/rules/flake8_quotes/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
AvoidQuoteEscape: ~
|
||||
AvoidableEscapedQuote: ~
|
||||
location:
|
||||
row: 1
|
||||
column: 25
|
||||
|
|
@ -21,7 +21,7 @@ expression: diagnostics
|
|||
column: 47
|
||||
parent: ~
|
||||
- kind:
|
||||
AvoidQuoteEscape: ~
|
||||
AvoidableEscapedQuote: ~
|
||||
location:
|
||||
row: 9
|
||||
column: 4
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
---
|
||||
source: src/rules/flake8_quotes/mod.rs
|
||||
source: crates/ruff/src/rules/flake8_quotes/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
AvoidQuoteEscape: ~
|
||||
AvoidableEscapedQuote: ~
|
||||
location:
|
||||
row: 1
|
||||
column: 25
|
||||
|
|
@ -21,7 +21,7 @@ expression: diagnostics
|
|||
column: 47
|
||||
parent: ~
|
||||
- kind:
|
||||
AvoidQuoteEscape: ~
|
||||
AvoidableEscapedQuote: ~
|
||||
location:
|
||||
row: 2
|
||||
column: 25
|
||||
|
|
@ -39,7 +39,7 @@ expression: diagnostics
|
|||
column: 52
|
||||
parent: ~
|
||||
- kind:
|
||||
AvoidQuoteEscape: ~
|
||||
AvoidableEscapedQuote: ~
|
||||
location:
|
||||
row: 10
|
||||
column: 4
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# avoid-quote-escape (Q003)
|
||||
# avoidable-escaped-quote (Q003)
|
||||
|
||||
Derived from the **flake8-quotes** linter.
|
||||
|
||||
Loading…
Reference in New Issue