Rename ruff crate to ruff_linter (#7529)

This commit is contained in:
Charlie Marsh 2023-09-20 02:38:27 -04:00 committed by GitHub
parent dcbd8eacd8
commit 5849a75223
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4397 changed files with 93921 additions and 93915 deletions

View file

@ -18,12 +18,12 @@ from _utils import ROOT_DIR, dir_name, get_indent, pascal_case
def main(*, plugin: str, url: str, prefix_code: str) -> None:
"""Generate boilerplate for a new plugin."""
# Create the test fixture folder.
(ROOT_DIR / "crates/ruff/resources/test/fixtures" / dir_name(plugin)).mkdir(
(ROOT_DIR / "crates/ruff_linter/resources/test/fixtures" / dir_name(plugin)).mkdir(
exist_ok=True,
)
# Create the Plugin rules module.
plugin_dir = ROOT_DIR / "crates/ruff/src/rules" / dir_name(plugin)
plugin_dir = ROOT_DIR / "crates/ruff_linter/src/rules" / dir_name(plugin)
plugin_dir.mkdir(exist_ok=True)
with (plugin_dir / "mod.rs").open("w+") as fp:
@ -67,16 +67,16 @@ mod tests {
(plugin_dir / "snapshots").mkdir(exist_ok=True)
# Add the plugin to `rules/mod.rs`.
rules_mod_path = ROOT_DIR / "crates/ruff/src/rules/mod.rs"
rules_mod_path = ROOT_DIR / "crates/ruff_linter/src/rules/mod.rs"
lines = rules_mod_path.read_text().strip().splitlines()
lines.append(f"pub mod {dir_name(plugin)};")
lines.sort()
rules_mod_path.write_text("\n".join(lines) + "\n")
# Add the relevant sections to `src/registry.rs`.
content = (ROOT_DIR / "crates/ruff/src/registry.rs").read_text()
content = (ROOT_DIR / "crates/ruff_linter/src/registry.rs").read_text()
with (ROOT_DIR / "crates/ruff/src/registry.rs").open("w") as fp:
with (ROOT_DIR / "crates/ruff_linter/src/registry.rs").open("w") as fp:
for line in content.splitlines():
indent = get_indent(line)
@ -94,14 +94,14 @@ mod tests {
fp.write("\n")
text = ""
with (ROOT_DIR / "crates/ruff/src/codes.rs").open("r") as fp:
with (ROOT_DIR / "crates/ruff_linter/src/codes.rs").open("r") as fp:
while (line := next(fp)).strip() != "// ruff":
text += line
text += " " * 8 + f"// {plugin}\n\n"
text += line
text += fp.read()
with (ROOT_DIR / "crates/ruff/src/codes.rs").open("w") as fp:
with (ROOT_DIR / "crates/ruff_linter/src/codes.rs").open("w") as fp:
fp.write(text)

View file

@ -23,7 +23,7 @@ def main(*, name: str, prefix: str, code: str, linter: str) -> None:
filestem = f"{prefix}{code}" if linter != "pylint" else snake_case(name)
with (
ROOT_DIR
/ "crates/ruff/resources/test/fixtures"
/ "crates/ruff_linter/resources/test/fixtures"
/ dir_name(linter)
/ f"{filestem}.py"
).open(
@ -31,7 +31,7 @@ def main(*, name: str, prefix: str, code: str, linter: str) -> None:
):
pass
plugin_module = ROOT_DIR / "crates/ruff/src/rules" / dir_name(linter)
plugin_module = ROOT_DIR / "crates/ruff_linter/src/rules" / dir_name(linter)
rule_name_snake = snake_case(name)
# Add the relevant `#testcase` macro.
@ -128,7 +128,7 @@ pub(crate) fn {rule_name_snake}(checker: &mut Checker) {{}}
)
text = ""
with (ROOT_DIR / "crates/ruff/src/codes.rs").open("r") as fp:
with (ROOT_DIR / "crates/ruff_linter/src/codes.rs").open("r") as fp:
while (line := next(fp)).strip() != f"// {linter}":
text += line
text += line
@ -147,7 +147,7 @@ pub(crate) fn {rule_name_snake}(checker: &mut Checker) {{}}
text += "".join(lines)
text += "\n"
text += fp.read()
with (ROOT_DIR / "crates/ruff/src/codes.rs").open("w") as fp:
with (ROOT_DIR / "crates/ruff_linter/src/codes.rs").open("w") as fp:
fp.write(text)
_rustfmt(rules_mod)

View file

@ -5,4 +5,4 @@
###
cargo build --release && hyperfine --ignore-failure --warmup 10 \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache"
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache"

View file

@ -20,7 +20,7 @@
# })
hyperfine --ignore-failure --warmup 5 \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --select ALL" \
"flake8 crates/ruff/resources/test/cpython -qq --docstring-convention=all" \
"pycodestyle crates/ruff/resources/test/cpython -qq" \
"pylint crates/ruff/resources/test/cpython -j 0 --recursive=y --disable=E,W,C,R"
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --select ALL" \
"flake8 crates/ruff_linter/resources/test/cpython -qq --docstring-convention=all" \
"pycodestyle crates/ruff_linter/resources/test/cpython -qq" \
"pylint crates/ruff_linter/resources/test/cpython -j 0 --recursive=y --disable=E,W,C,R"

View file

@ -5,8 +5,8 @@
###
hyperfine --ignore-failure --warmup 5 \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache" \
"pyflakes crates/ruff/resources/test/cpython" \
"autoflake --recursive --expand-star-imports --remove-all-unused-imports --remove-unused-variables --remove-duplicate-keys crates/ruff/resources/test/cpython" \
"pycodestyle crates/ruff/resources/test/cpython" \
"flake8 crates/ruff/resources/test/cpython"
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache" \
"pyflakes crates/ruff_linter/resources/test/cpython" \
"autoflake --recursive --expand-star-imports --remove-all-unused-imports --remove-unused-variables --remove-duplicate-keys crates/ruff_linter/resources/test/cpython" \
"pycodestyle crates/ruff_linter/resources/test/cpython" \
"flake8 crates/ruff_linter/resources/test/cpython"

View file

@ -5,39 +5,39 @@
###
cargo build --release && hyperfine --ignore-failure --warmup 10 \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select C90" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select I" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select D" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select UP" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select N" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select YTT" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select ANN" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select S" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select BLE" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select FBT" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select B" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select A" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select C4" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select T10" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select EM" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select ISC" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select ICN" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select T20" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select PT" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select Q" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select RET" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select SIM" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select TID" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select ARG" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select DTZ" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select ERA" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select PD" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select PGH" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select PLC" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select PLE" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select PLR" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select PLW" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select PIE" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select COM" \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select RUF"
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select C90" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select I" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select D" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select UP" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select N" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select YTT" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select ANN" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select S" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select BLE" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select FBT" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select B" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select A" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select C4" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select T10" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select EM" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select ISC" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select ICN" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select T20" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select PT" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select Q" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select RET" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select SIM" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select TID" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select ARG" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select DTZ" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select ERA" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select PD" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select PGH" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select PLC" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select PLE" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select PLR" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select PLW" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select PIE" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select COM" \
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select RUF"

View file

@ -6,7 +6,7 @@
###
hyperfine --ignore-failure --warmup 5 \
"./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent" \
"pycodestyle ./crates/ruff/resources/test/cpython -qq" \
"flake8 ./crates/ruff/resources/test/cpython -qq" \
"pylint ./crates/ruff/resources/test/cpython -j 0 --recursive=y --disable=E,W,C,R"
"./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent" \
"pycodestyle ./crates/ruff_linter/resources/test/cpython -qq" \
"flake8 ./crates/ruff_linter/resources/test/cpython -qq" \
"pylint ./crates/ruff_linter/resources/test/cpython -j 0 --recursive=y --disable=E,W,C,R"

View file

@ -4,4 +4,4 @@
# Setup the CPython repository to enable benchmarking.
###
git clone --branch 3.10 https://github.com/python/cpython.git crates/ruff/resources/test/cpython --filter=blob:none
git clone --branch 3.10 https://github.com/python/cpython.git crates/ruff_linter/resources/test/cpython --filter=blob:none

View file

@ -5,7 +5,7 @@ import json
import subprocess
from pathlib import Path
CONFUSABLES_RS_PATH = "crates/ruff/src/rules/ruff/rules/confusables.rs"
CONFUSABLES_RS_PATH = "crates/ruff_linter/src/rules/ruff/rules/confusables.rs"
AMBIGUOUS_JSON_URL = "https://raw.githubusercontent.com/hediet/vscode-unicode-data/main/out/ambiguous.json"
prelude = """