mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:26 +00:00
Rename checks
and plugins
to rules
(#1739)
This commit is contained in:
parent
caf6c65de7
commit
59155ce9f6
195 changed files with 1132 additions and 1192 deletions
|
@ -1903,7 +1903,7 @@ extend-select = ["B", "Q"]
|
|||
A list of check codes that are unsupported by Ruff, but should be
|
||||
preserved when (e.g.) validating `# noqa` directives. Useful for
|
||||
retaining `# noqa` directives that cover plugins not yet implemented
|
||||
in Ruff.
|
||||
by Ruff.
|
||||
|
||||
**Default value**: `[]`
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
}
|
||||
},
|
||||
"external": {
|
||||
"description": "A list of check codes that are unsupported by Ruff, but should be preserved when (e.g.) validating `# noqa` directives. Useful for retaining `# noqa` directives that cover plugins not yet implemented in Ruff.",
|
||||
"description": "A list of check codes that are unsupported by Ruff, but should be preserved when (e.g.) validating `# noqa` directives. Useful for retaining `# noqa` directives that cover plugins not yet implemented by Ruff.",
|
||||
"type": [
|
||||
"array",
|
||||
"null"
|
||||
|
|
|
@ -43,8 +43,8 @@ def main(*, name: str, code: str, plugin: str) -> None:
|
|||
|
||||
with open(os.path.join(ROOT_DIR, f"src/{dir_name(plugin)}/mod.rs"), "w") as fp:
|
||||
for line in content.splitlines():
|
||||
if line.strip() == "fn diagnostics(check_code: RuleCode, path: &Path) -> Result<()> {":
|
||||
indent = line.split("fn diagnostics(check_code: RuleCode, path: &Path) -> Result<()> {")[0]
|
||||
if line.strip() == "fn rules(check_code: RuleCode, path: &Path) -> Result<()> {":
|
||||
indent = line.split("fn rules(check_code: RuleCode, path: &Path) -> Result<()> {")[0]
|
||||
fp.write(f'{indent}#[test_case(RuleCode::{code}, Path::new("{code}.py"); "{code}")]')
|
||||
fp.write("\n")
|
||||
|
||||
|
|
|
@ -31,10 +31,10 @@ def main(*, plugin: str, url: str) -> None:
|
|||
|
||||
# Create the Rust module.
|
||||
os.makedirs(os.path.join(ROOT_DIR, f"src/{dir_name(plugin)}"), exist_ok=True)
|
||||
with open(os.path.join(ROOT_DIR, f"src/{dir_name(plugin)}/plugins.rs"), "a"):
|
||||
with open(os.path.join(ROOT_DIR, f"src/{dir_name(plugin)}/rules"), "a"):
|
||||
pass
|
||||
with open(os.path.join(ROOT_DIR, f"src/{dir_name(plugin)}/mod.rs"), "w+") as fp:
|
||||
fp.write("pub mod plugins;\n")
|
||||
with open(os.path.join(ROOT_DIR, f"src/{dir_name(plugin)}/rules"), "w+") as fp:
|
||||
fp.write("pub mod rules;\n")
|
||||
fp.write("\n")
|
||||
fp.write(
|
||||
"""#[cfg(test)]
|
||||
|
@ -49,7 +49,7 @@ mod tests {
|
|||
use crate::linter::test_path;
|
||||
use crate::settings;
|
||||
|
||||
fn diagnostics(check_code: RuleCode, path: &Path) -> Result<()> {
|
||||
fn rules(check_code: RuleCode, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", check_code.as_ref(), path.to_string_lossy());
|
||||
let diagnostics =test_path(
|
||||
Path::new("./resources/test/fixtures/%s")
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -25,7 +25,7 @@ fn check_import_blocks(
|
|||
for block in tracker.into_iter() {
|
||||
if !block.imports.is_empty() {
|
||||
if let Some(diagnostic) =
|
||||
isort::plugins::check_imports(&block, locator, settings, stylist, autofix, package)
|
||||
isort::rules::check_imports(&block, locator, settings, stylist, autofix, package)
|
||||
{
|
||||
diagnostics.push(diagnostic);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
//! Lint rules based on checking raw physical lines.
|
||||
|
||||
use crate::pycodestyle::checks::{line_too_long, no_newline_at_end_of_file};
|
||||
use crate::pygrep_hooks::plugins::{blanket_noqa, blanket_type_ignore};
|
||||
use crate::pyupgrade::checks::unnecessary_coding_comment;
|
||||
use crate::pycodestyle::rules::{line_too_long, no_newline_at_end_of_file};
|
||||
use crate::pygrep_hooks::rules::{blanket_noqa, blanket_type_ignore};
|
||||
use crate::pyupgrade::rules::unnecessary_coding_comment;
|
||||
use crate::registry::{Diagnostic, RuleCode};
|
||||
use crate::settings::{flags, Settings};
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ use rustpython_parser::lexer::{LexResult, Tok};
|
|||
|
||||
use crate::lex::docstring_detection::StateMachine;
|
||||
use crate::registry::{Diagnostic, RuleCode};
|
||||
use crate::ruff::checks::Context;
|
||||
use crate::ruff::rules::Context;
|
||||
use crate::settings::flags;
|
||||
use crate::source_code_locator::SourceCodeLocator;
|
||||
use crate::{eradicate, flake8_implicit_str_concat, flake8_quotes, pycodestyle, ruff, Settings};
|
||||
|
@ -40,7 +40,7 @@ pub fn check_tokens(
|
|||
// RUF001, RUF002, RUF003
|
||||
if enforce_ambiguous_unicode_character {
|
||||
if matches!(tok, Tok::String { .. } | Tok::Comment(_)) {
|
||||
diagnostics.extend(ruff::checks::ambiguous_unicode_character(
|
||||
diagnostics.extend(ruff::rules::ambiguous_unicode_character(
|
||||
locator,
|
||||
start,
|
||||
end,
|
||||
|
@ -62,7 +62,7 @@ pub fn check_tokens(
|
|||
// flake8-quotes
|
||||
if enforce_quotes {
|
||||
if matches!(tok, Tok::String { .. }) {
|
||||
if let Some(diagnostic) = flake8_quotes::checks::quotes(
|
||||
if let Some(diagnostic) = flake8_quotes::rules::quotes(
|
||||
locator,
|
||||
start,
|
||||
end,
|
||||
|
@ -80,7 +80,7 @@ pub fn check_tokens(
|
|||
if enforce_commented_out_code {
|
||||
if matches!(tok, Tok::Comment(_)) {
|
||||
if let Some(diagnostic) =
|
||||
eradicate::checks::commented_out_code(locator, start, end, settings, autofix)
|
||||
eradicate::rules::commented_out_code(locator, start, end, settings, autofix)
|
||||
{
|
||||
diagnostics.push(diagnostic);
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ pub fn check_tokens(
|
|||
// W605
|
||||
if enforce_invalid_escape_sequence {
|
||||
if matches!(tok, Tok::String { .. }) {
|
||||
diagnostics.extend(pycodestyle::checks::invalid_escape_sequence(
|
||||
diagnostics.extend(pycodestyle::rules::invalid_escape_sequence(
|
||||
locator,
|
||||
start,
|
||||
end,
|
||||
|
@ -104,7 +104,7 @@ pub fn check_tokens(
|
|||
// ISC001, ISC002
|
||||
if enforce_implicit_string_concatenation {
|
||||
diagnostics.extend(
|
||||
flake8_implicit_str_concat::checks::implicit(tokens, locator)
|
||||
flake8_implicit_str_concat::rules::implicit(tokens, locator)
|
||||
.into_iter()
|
||||
.filter(|diagnostic| settings.enabled.contains(diagnostic.kind.code())),
|
||||
);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
pub mod checks;
|
||||
pub mod detection;
|
||||
pub mod rules;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
@ -14,7 +14,7 @@ mod tests {
|
|||
use crate::settings;
|
||||
|
||||
#[test_case(RuleCode::ERA001, Path::new("ERA001.py"); "ERA001")]
|
||||
fn diagnostics(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
fn rules(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy());
|
||||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/eradicate")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pub mod plugins;
|
||||
pub mod rules;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
@ -22,7 +22,7 @@ mod tests {
|
|||
#[test_case(RuleCode::YTT301, Path::new("YTT301.py"); "YTT301")]
|
||||
#[test_case(RuleCode::YTT302, Path::new("YTT302.py"); "YTT302")]
|
||||
#[test_case(RuleCode::YTT303, Path::new("YTT303.py"); "YTT303")]
|
||||
fn diagnostics(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
fn rules(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy());
|
||||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/flake8_2020")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mod fixes;
|
||||
pub mod helpers;
|
||||
pub mod plugins;
|
||||
pub mod rules;
|
||||
pub mod settings;
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
pub mod checks;
|
||||
mod helpers;
|
||||
pub mod rules;
|
||||
pub mod settings;
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -25,7 +25,7 @@ mod tests {
|
|||
#[test_case(RuleCode::S324, Path::new("S324.py"); "S324")]
|
||||
#[test_case(RuleCode::S501, Path::new("S501.py"); "S501")]
|
||||
#[test_case(RuleCode::S506, Path::new("S506.py"); "S506")]
|
||||
fn diagnostics(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
fn rules(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy());
|
||||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/flake8_bandit")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pub mod plugins;
|
||||
pub mod rules;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
@ -13,7 +13,7 @@ mod tests {
|
|||
use crate::settings;
|
||||
|
||||
#[test_case(RuleCode::BLE001, Path::new("BLE.py"); "BLE001")]
|
||||
fn diagnostics(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
fn rules(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy());
|
||||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/flake8_blind_except")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pub mod plugins;
|
||||
pub mod rules;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
@ -15,7 +15,7 @@ mod tests {
|
|||
#[test_case(RuleCode::FBT001, Path::new("FBT.py"); "FBT001")]
|
||||
#[test_case(RuleCode::FBT002, Path::new("FBT.py"); "FBT002")]
|
||||
#[test_case(RuleCode::FBT003, Path::new("FBT.py"); "FBT003")]
|
||||
fn diagnostics(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
fn rules(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy());
|
||||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/flake8_boolean_trap")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pub mod plugins;
|
||||
pub mod rules;
|
||||
pub mod settings;
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -40,7 +40,7 @@ mod tests {
|
|||
#[test_case(RuleCode::B027, Path::new("B027.py"); "B027")]
|
||||
#[test_case(RuleCode::B904, Path::new("B904.py"); "B904")]
|
||||
#[test_case(RuleCode::B905, Path::new("B905.py"); "B905")]
|
||||
fn diagnostics(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
fn rules(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy());
|
||||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/flake8_bugbear")
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::ast::types::Range;
|
|||
use crate::ast::visitor;
|
||||
use crate::ast::visitor::Visitor;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::flake8_bugbear::plugins::mutable_argument_default::is_mutable_func;
|
||||
use crate::flake8_bugbear::rules::mutable_argument_default::is_mutable_func;
|
||||
use crate::registry::{Diagnostic, DiagnosticKind};
|
||||
use crate::violations;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
pub mod checks;
|
||||
pub mod rules;
|
||||
pub mod types;
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -16,7 +16,7 @@ mod tests {
|
|||
#[test_case(RuleCode::A001, Path::new("A001.py"); "A001")]
|
||||
#[test_case(RuleCode::A002, Path::new("A002.py"); "A002")]
|
||||
#[test_case(RuleCode::A003, Path::new("A003.py"); "A003")]
|
||||
fn diagnostics(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
fn rules(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy());
|
||||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/flake8_builtins")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
pub mod checks;
|
||||
mod fixes;
|
||||
pub mod rules;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
@ -30,7 +30,7 @@ mod tests {
|
|||
#[test_case(RuleCode::C416, Path::new("C416.py"); "C416")]
|
||||
#[test_case(RuleCode::C417, Path::new("C417.py"); "C417")]
|
||||
|
||||
fn diagnostics(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
fn rules(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy());
|
||||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/flake8_comprehensions")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pub mod plugins;
|
||||
pub mod rules;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
@ -21,7 +21,7 @@ mod tests {
|
|||
#[test_case(RuleCode::DTZ007, Path::new("DTZ007.py"); "DTZ007")]
|
||||
#[test_case(RuleCode::DTZ011, Path::new("DTZ011.py"); "DTZ011")]
|
||||
#[test_case(RuleCode::DTZ012, Path::new("DTZ012.py"); "DTZ012")]
|
||||
fn diagnostics(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
fn rules(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy());
|
||||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/flake8_datetimez")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pub mod checks;
|
||||
pub mod rules;
|
||||
pub mod types;
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -14,7 +14,7 @@ mod tests {
|
|||
use crate::settings;
|
||||
|
||||
#[test_case(RuleCode::T100, Path::new("T100.py"); "T100")]
|
||||
fn diagnostics(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
fn rules(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy());
|
||||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/flake8_debugger")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pub mod plugins;
|
||||
pub mod rules;
|
||||
pub mod settings;
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pub mod checks;
|
||||
pub mod rules;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
@ -15,7 +15,7 @@ mod tests {
|
|||
#[test_case(RuleCode::ISC001, Path::new("ISC.py"); "ISC001")]
|
||||
#[test_case(RuleCode::ISC002, Path::new("ISC.py"); "ISC002")]
|
||||
#[test_case(RuleCode::ISC003, Path::new("ISC.py"); "ISC003")]
|
||||
fn diagnostics(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
fn rules(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy());
|
||||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/flake8_implicit_str_concat")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pub mod checks;
|
||||
pub mod rules;
|
||||
pub mod settings;
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pub mod plugins;
|
||||
pub mod rules;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
@ -15,7 +15,7 @@ mod tests {
|
|||
#[test_case(RuleCode::PIE790, Path::new("PIE790.py"); "PIE790")]
|
||||
#[test_case(RuleCode::PIE794, Path::new("PIE794.py"); "PIE794")]
|
||||
#[test_case(RuleCode::PIE807, Path::new("PIE807.py"); "PIE807")]
|
||||
fn diagnostics(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
fn rules(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy());
|
||||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/flake8_pie")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pub mod plugins;
|
||||
pub mod rules;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
@ -14,7 +14,7 @@ mod tests {
|
|||
|
||||
#[test_case(RuleCode::T201, Path::new("T201.py"); "T201")]
|
||||
#[test_case(RuleCode::T203, Path::new("T203.py"); "T203")]
|
||||
fn diagnostics(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
fn rules(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy());
|
||||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/flake8_print")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pub mod plugins;
|
||||
pub mod rules;
|
||||
pub mod settings;
|
||||
pub mod types;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pub mod checks;
|
||||
pub mod rules;
|
||||
pub mod settings;
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
mod helpers;
|
||||
pub mod plugins;
|
||||
pub mod rules;
|
||||
mod visitor;
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -21,7 +21,7 @@ mod tests {
|
|||
#[test_case(RuleCode::RET506, Path::new("RET506.py"); "RET506")]
|
||||
#[test_case(RuleCode::RET507, Path::new("RET507.py"); "RET507")]
|
||||
#[test_case(RuleCode::RET508, Path::new("RET508.py"); "RET508")]
|
||||
fn diagnostics(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
fn rules(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy());
|
||||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/flake8_return")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
pub mod plugins;
|
||||
pub mod rules;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
@ -34,7 +34,7 @@ mod tests {
|
|||
#[test_case(RuleCode::SIM222, Path::new("SIM222.py"); "SIM222")]
|
||||
#[test_case(RuleCode::SIM223, Path::new("SIM223.py"); "SIM223")]
|
||||
#[test_case(RuleCode::SIM300, Path::new("SIM300.py"); "SIM300")]
|
||||
fn diagnostics(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
fn rules(rule_code: RuleCode, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy());
|
||||
let diagnostics = test_path(
|
||||
Path::new("./resources/test/fixtures/flake8_simplify")
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue