Set default `max-complexity` to 10 for empty McCabe settings (#6073)

Closes https://github.com/astral-sh/ruff/issues/6058.
This commit is contained in:
Charlie Marsh 2023-07-25 11:38:19 -04:00 committed by GitHub
parent 670db1db4b
commit c996b614fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -31,16 +31,20 @@ pub struct Settings {
pub max_complexity: usize, pub max_complexity: usize,
} }
const DEFAULT_MAX_COMPLEXITY: usize = 10;
impl Default for Settings { impl Default for Settings {
fn default() -> Self { fn default() -> Self {
Self { max_complexity: 10 } Self {
max_complexity: DEFAULT_MAX_COMPLEXITY,
}
} }
} }
impl From<Options> for Settings { impl From<Options> for Settings {
fn from(options: Options) -> Self { fn from(options: Options) -> Self {
Self { Self {
max_complexity: options.max_complexity.unwrap_or_default(), max_complexity: options.max_complexity.unwrap_or(DEFAULT_MAX_COMPLEXITY),
} }
} }
} }