mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 13:25:17 +00:00
[pylint] Implement too-many-public-methods
rule (PLR0904) (#6179)
Implement https://pylint.pycqa.org/en/latest/user_guide/messages/refactor/too-many-public-methods.html Confusingly the rule page mentions a max of 7 while in practice it is 20. https://github.com/search?q=repo%3Apylint-dev%2Fpylint+max-public-methods&type=code ## Summary Implement pylint's R0904 ## Test Plan Unit tests.
This commit is contained in:
parent
36fa1fe359
commit
04183b0299
12 changed files with 283 additions and 2 deletions
|
@ -2155,6 +2155,13 @@ pub struct PylintOptions {
|
|||
/// Maximum number of statements allowed for a function or method body (see:
|
||||
/// `PLR0915`).
|
||||
pub max_statements: Option<usize>,
|
||||
#[option(
|
||||
default = r"20",
|
||||
value_type = "int",
|
||||
example = r"max-public-methods = 20"
|
||||
)]
|
||||
/// Maximum number of public methods allowed for a class (see: `PLR0904`).
|
||||
pub max_public_methods: Option<usize>,
|
||||
}
|
||||
|
||||
impl PylintOptions {
|
||||
|
@ -2168,6 +2175,9 @@ impl PylintOptions {
|
|||
max_returns: self.max_returns.unwrap_or(defaults.max_returns),
|
||||
max_branches: self.max_branches.unwrap_or(defaults.max_branches),
|
||||
max_statements: self.max_statements.unwrap_or(defaults.max_statements),
|
||||
max_public_methods: self
|
||||
.max_public_methods
|
||||
.unwrap_or(defaults.max_public_methods),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue