From c996b614fe38c162927dbf9f26c8c291fd937da0 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 25 Jul 2023 11:38:19 -0400 Subject: [PATCH] Set default `max-complexity` to 10 for empty McCabe settings (#6073) Closes https://github.com/astral-sh/ruff/issues/6058. --- crates/ruff/src/rules/mccabe/settings.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/ruff/src/rules/mccabe/settings.rs b/crates/ruff/src/rules/mccabe/settings.rs index eb8daa8dccc56..bb9cae8093233 100644 --- a/crates/ruff/src/rules/mccabe/settings.rs +++ b/crates/ruff/src/rules/mccabe/settings.rs @@ -31,16 +31,20 @@ pub struct Settings { pub max_complexity: usize, } +const DEFAULT_MAX_COMPLEXITY: usize = 10; + impl Default for Settings { fn default() -> Self { - Self { max_complexity: 10 } + Self { + max_complexity: DEFAULT_MAX_COMPLEXITY, + } } } impl From for Settings { fn from(options: Options) -> Self { Self { - max_complexity: options.max_complexity.unwrap_or_default(), + max_complexity: options.max_complexity.unwrap_or(DEFAULT_MAX_COMPLEXITY), } } }