|
| 1 | +--- |
| 2 | +title:Ruff |
| 3 | +sidebar_label:Ruff |
| 4 | +description:Overview of CodeRabbit's supported linters and security analysis tools. |
| 5 | +sidebar_position:1 |
| 6 | +--- |
| 7 | + |
| 8 | +Ruff is a linter and code formatter for Python. |
| 9 | + |
| 10 | +##Settings |
| 11 | + |
| 12 | +Ruff supports the following config files: |
| 13 | + |
| 14 | +-`pyproject.toml` |
| 15 | +-`ruff.toml` |
| 16 | +-`.ruff.toml` |
| 17 | + |
| 18 | +CodeRabbit will use the following settings if no config file is found: |
| 19 | + |
| 20 | +###Chill |
| 21 | + |
| 22 | +```toml |
| 23 | +[lint] |
| 24 | +select = [ |
| 25 | +# pycodestyle subset rules |
| 26 | +"E7", |
| 27 | +"E9", |
| 28 | +# Pyflakes |
| 29 | +"F", |
| 30 | +# flake8-bugbear |
| 31 | +"B", |
| 32 | +# flake8-simplify |
| 33 | +"SIM", |
| 34 | +# isort subset rules |
| 35 | +"I002", |
| 36 | +] |
| 37 | +[lint.per-file-ignores] |
| 38 | +"**/__init__.py" = ["E402"] |
| 39 | +"**/conftest.py" = ["E402"] |
| 40 | +``` |
| 41 | + |
| 42 | +###Assertive |
| 43 | + |
| 44 | +```toml |
| 45 | +[lint] |
| 46 | +select = [ |
| 47 | +# pycodestyle subset rules |
| 48 | +"E7", |
| 49 | +"E9", |
| 50 | +# Pyflakes |
| 51 | +"F", |
| 52 | +# flake8-bugbear |
| 53 | +"B", |
| 54 | +# flake8-simplify |
| 55 | +"SIM", |
| 56 | +# isort subset rules |
| 57 | +"I002", |
| 58 | +# pycodestyle subset rules |
| 59 | +"E4", |
| 60 | +"E101", |
| 61 | +# mccabe |
| 62 | +"C90", |
| 63 | +# flake8-annotations |
| 64 | +"ANN", |
| 65 | +# flake8-async |
| 66 | +"ASYNC", |
| 67 | +# flake8-trio |
| 68 | +"TRIO", |
| 69 | +# flake8-bandit |
| 70 | +"S", |
| 71 | +# flake8-blind-except |
| 72 | +"BLE", |
| 73 | +# flake8-boolean-trap |
| 74 | +"FBT", |
| 75 | +# flake8-commas |
| 76 | +"COM", |
| 77 | +# flake8-comprehensions |
| 78 | +"C4", |
| 79 | +# flake8-datetimez |
| 80 | +"DTZ", |
| 81 | +# flake8-debugger |
| 82 | +"T10", |
| 83 | +# flake8-django |
| 84 | +"DJ", |
| 85 | +# flake8-executable |
| 86 | +"EXE", |
| 87 | +# flake8-implicit-str-concat |
| 88 | +"ISC", |
| 89 | +# flake8-logging |
| 90 | +"LOG", |
| 91 | +# flake8-logging-format |
| 92 | +"G", |
| 93 | +# flake8-pie |
| 94 | +"PIE", |
| 95 | +# flake8-pytest-style |
| 96 | +"PT", |
| 97 | +# flake8-raise |
| 98 | +"RSE", |
| 99 | +# flake8-return |
| 100 | +"RET", |
| 101 | +# flake8-unused-arguments |
| 102 | +"ARG", |
| 103 | +# tryceratops |
| 104 | +"TRY", |
| 105 | +# flynt |
| 106 | +"FLY", |
| 107 | +# Ruff-specific rules |
| 108 | +"RUF", |
| 109 | +# pyupgrade |
| 110 | +"UP", |
| 111 | +] |
| 112 | +[lint.per-file-ignores] |
| 113 | +"**/__init__.py" = ["E402"] |
| 114 | +"**/conftest.py" = ["E402"] |
| 115 | +"**/*_test.py" = ["S101"] |
| 116 | +"**/test_*.py" = ["S101"] |
| 117 | +"**/{test,tests}/**/*.py" = ["S101"] |
| 118 | +``` |
| 119 | + |
| 120 | +Links: |
| 121 | + |
| 122 | +-[Ruff](https://docs.astral.sh/ruff/configuration/) |