From 07b6b7401f56ca75d1478fbe0c68f4093365cac1 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 20 Jun 2023 21:56:40 -0400 Subject: [PATCH] Move `copyright` rules to `flake8_copyright` module (#5236) ## Summary I initially wanted this category to be more general and decoupled from the plugin, but I got some feedback that the titling felt inconsistent with others. --- crates/ruff/src/checkers/physical_lines.rs | 2 +- crates/ruff/src/codes.rs | 2 +- ...ruff__rules__copyright__tests__notice.snap | 4 - ...ules__copyright__tests__notice_with_c.snap | 4 - ...s__copyright__tests__notice_with_caps.snap | 4 - ...__copyright__tests__notice_with_range.snap | 4 - ...__rules__copyright__tests__small_file.snap | 4 - ...rules__copyright__tests__valid_author.snap | 4 - .../{copyright => flake8_copyright}/mod.rs | 6 +- .../rules/missing_copyright_notice.rs | 6 +- .../rules/mod.rs | 0 .../settings.rs | 4 +- ...ke8_copyright__tests__invalid_author.snap} | 2 +- ...flake8_copyright__tests__late_notice.snap} | 2 +- ...ules__flake8_copyright__tests__notice.snap | 4 + ...lake8_copyright__tests__notice_with_c.snap | 4 + ...e8_copyright__tests__notice_with_caps.snap | 4 + ...8_copyright__tests__notice_with_range.snap | 4 + ...__flake8_copyright__tests__small_file.snap | 4 + ...flake8_copyright__tests__valid_author.snap | 4 + crates/ruff/src/rules/mod.rs | 2 +- crates/ruff/src/settings/configuration.rs | 12 +-- crates/ruff/src/settings/defaults.rs | 6 +- crates/ruff/src/settings/mod.rs | 14 ++-- crates/ruff/src/settings/options.rs | 6 +- crates/ruff_wasm/src/lib.rs | 12 +-- ruff.schema.json | 80 +++++++++---------- 27 files changed, 102 insertions(+), 102 deletions(-) delete mode 100644 crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__notice.snap delete mode 100644 crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__notice_with_c.snap delete mode 100644 crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__notice_with_caps.snap delete mode 100644 crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__notice_with_range.snap delete mode 100644 crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__small_file.snap delete mode 100644 crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__valid_author.snap rename crates/ruff/src/rules/{copyright => flake8_copyright}/mod.rs (96%) rename crates/ruff/src/rules/{copyright => flake8_copyright}/rules/missing_copyright_notice.rs (88%) rename crates/ruff/src/rules/{copyright => flake8_copyright}/rules/mod.rs (100%) rename crates/ruff/src/rules/{copyright => flake8_copyright}/settings.rs (97%) rename crates/ruff/src/rules/{copyright/snapshots/ruff__rules__copyright__tests__invalid_author.snap => flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__invalid_author.snap} (73%) rename crates/ruff/src/rules/{copyright/snapshots/ruff__rules__copyright__tests__late_notice.snap => flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__late_notice.snap} (86%) create mode 100644 crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice.snap create mode 100644 crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_c.snap create mode 100644 crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_caps.snap create mode 100644 crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_range.snap create mode 100644 crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__small_file.snap create mode 100644 crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__valid_author.snap diff --git a/crates/ruff/src/checkers/physical_lines.rs b/crates/ruff/src/checkers/physical_lines.rs index 9882bc86efef9..1a553f3d7dffe 100644 --- a/crates/ruff/src/checkers/physical_lines.rs +++ b/crates/ruff/src/checkers/physical_lines.rs @@ -8,7 +8,7 @@ use ruff_python_ast::source_code::{Indexer, Locator, Stylist}; use ruff_python_whitespace::UniversalNewlines; use crate::registry::Rule; -use crate::rules::copyright::rules::missing_copyright_notice; +use crate::rules::flake8_copyright::rules::missing_copyright_notice; use crate::rules::flake8_executable::helpers::{extract_shebang, ShebangDirective}; use crate::rules::flake8_executable::rules::{ shebang_missing, shebang_newline, shebang_not_executable, shebang_python, shebang_whitespace, diff --git a/crates/ruff/src/codes.rs b/crates/ruff/src/codes.rs index 78356ead86426..68409be315be7 100644 --- a/crates/ruff/src/codes.rs +++ b/crates/ruff/src/codes.rs @@ -375,7 +375,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Flake8Simplify, "910") => (RuleGroup::Unspecified, rules::flake8_simplify::rules::DictGetWithNoneDefault), // copyright - (Copyright, "001") => (RuleGroup::Nursery, rules::copyright::rules::MissingCopyrightNotice), + (Copyright, "001") => (RuleGroup::Nursery, rules::flake8_copyright::rules::MissingCopyrightNotice), // pyupgrade (Pyupgrade, "001") => (RuleGroup::Unspecified, rules::pyupgrade::rules::UselessMetaclassType), diff --git a/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__notice.snap b/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__notice.snap deleted file mode 100644 index 2a35fab682f29..0000000000000 --- a/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__notice.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/copyright/mod.rs ---- - diff --git a/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__notice_with_c.snap b/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__notice_with_c.snap deleted file mode 100644 index 2a35fab682f29..0000000000000 --- a/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__notice_with_c.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/copyright/mod.rs ---- - diff --git a/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__notice_with_caps.snap b/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__notice_with_caps.snap deleted file mode 100644 index 2a35fab682f29..0000000000000 --- a/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__notice_with_caps.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/copyright/mod.rs ---- - diff --git a/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__notice_with_range.snap b/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__notice_with_range.snap deleted file mode 100644 index 2a35fab682f29..0000000000000 --- a/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__notice_with_range.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/copyright/mod.rs ---- - diff --git a/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__small_file.snap b/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__small_file.snap deleted file mode 100644 index 2a35fab682f29..0000000000000 --- a/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__small_file.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/copyright/mod.rs ---- - diff --git a/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__valid_author.snap b/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__valid_author.snap deleted file mode 100644 index 2a35fab682f29..0000000000000 --- a/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__valid_author.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/copyright/mod.rs ---- - diff --git a/crates/ruff/src/rules/copyright/mod.rs b/crates/ruff/src/rules/flake8_copyright/mod.rs similarity index 96% rename from crates/ruff/src/rules/copyright/mod.rs rename to crates/ruff/src/rules/flake8_copyright/mod.rs index ceadac5efb0f8..576d9daedfebe 100644 --- a/crates/ruff/src/rules/copyright/mod.rs +++ b/crates/ruff/src/rules/flake8_copyright/mod.rs @@ -75,7 +75,7 @@ import os "# .trim(), &settings::Settings { - copyright: super::settings::Settings { + flake8_copyright: super::settings::Settings { author: Some("Ruff".to_string()), ..super::settings::Settings::default() }, @@ -95,7 +95,7 @@ import os "# .trim(), &settings::Settings { - copyright: super::settings::Settings { + flake8_copyright: super::settings::Settings { author: Some("Ruff".to_string()), ..super::settings::Settings::default() }, @@ -113,7 +113,7 @@ import os "# .trim(), &settings::Settings { - copyright: super::settings::Settings { + flake8_copyright: super::settings::Settings { min_file_size: 256, ..super::settings::Settings::default() }, diff --git a/crates/ruff/src/rules/copyright/rules/missing_copyright_notice.rs b/crates/ruff/src/rules/flake8_copyright/rules/missing_copyright_notice.rs similarity index 88% rename from crates/ruff/src/rules/copyright/rules/missing_copyright_notice.rs rename to crates/ruff/src/rules/flake8_copyright/rules/missing_copyright_notice.rs index 00ceccffee4d8..ce3cca98c7d77 100644 --- a/crates/ruff/src/rules/copyright/rules/missing_copyright_notice.rs +++ b/crates/ruff/src/rules/flake8_copyright/rules/missing_copyright_notice.rs @@ -28,7 +28,7 @@ pub(crate) fn missing_copyright_notice( settings: &Settings, ) -> Option { // Ignore files that are too small to contain a copyright notice. - if locator.len() < settings.copyright.min_file_size { + if locator.len() < settings.flake8_copyright.min_file_size { return None; } @@ -40,8 +40,8 @@ pub(crate) fn missing_copyright_notice( }; // Locate the copyright notice. - if let Some(match_) = settings.copyright.notice_rgx.find(contents) { - match settings.copyright.author { + if let Some(match_) = settings.flake8_copyright.notice_rgx.find(contents) { + match settings.flake8_copyright.author { Some(ref author) => { // Ensure that it's immediately followed by the author. if contents[match_.end()..].trim_start().starts_with(author) { diff --git a/crates/ruff/src/rules/copyright/rules/mod.rs b/crates/ruff/src/rules/flake8_copyright/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/copyright/rules/mod.rs rename to crates/ruff/src/rules/flake8_copyright/rules/mod.rs diff --git a/crates/ruff/src/rules/copyright/settings.rs b/crates/ruff/src/rules/flake8_copyright/settings.rs similarity index 97% rename from crates/ruff/src/rules/copyright/settings.rs rename to crates/ruff/src/rules/flake8_copyright/settings.rs index f3e400ca25a00..f4f8e0c17eca1 100644 --- a/crates/ruff/src/rules/copyright/settings.rs +++ b/crates/ruff/src/rules/flake8_copyright/settings.rs @@ -1,4 +1,4 @@ -//! Settings for the `copyright` plugin. +//! Settings for the `flake8-copyright` plugin. use once_cell::sync::Lazy; use regex::Regex; @@ -12,7 +12,7 @@ use ruff_macros::{CacheKey, CombineOptions, ConfigurationOptions}; #[serde( deny_unknown_fields, rename_all = "kebab-case", - rename = "CopyrightOptions" + rename = "Flake8CopyrightOptions" )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub struct Options { diff --git a/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__invalid_author.snap b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__invalid_author.snap similarity index 73% rename from crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__invalid_author.snap rename to crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__invalid_author.snap index 2b09c763512b6..4393791320ec8 100644 --- a/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__invalid_author.snap +++ b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__invalid_author.snap @@ -1,5 +1,5 @@ --- -source: crates/ruff/src/rules/copyright/mod.rs +source: crates/ruff/src/rules/flake8_copyright/mod.rs --- :1:1: CPY001 Missing copyright notice at top of file | diff --git a/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__late_notice.snap b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__late_notice.snap similarity index 86% rename from crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__late_notice.snap rename to crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__late_notice.snap index 0bc581e98d6a4..17efa2aa8d190 100644 --- a/crates/ruff/src/rules/copyright/snapshots/ruff__rules__copyright__tests__late_notice.snap +++ b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__late_notice.snap @@ -1,5 +1,5 @@ --- -source: crates/ruff/src/rules/copyright/mod.rs +source: crates/ruff/src/rules/flake8_copyright/mod.rs --- :1:1: CPY001 Missing copyright notice at top of file | diff --git a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice.snap b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice.snap new file mode 100644 index 0000000000000..383a7b0dacf48 --- /dev/null +++ b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff/src/rules/flake8_copyright/mod.rs +--- + diff --git a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_c.snap b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_c.snap new file mode 100644 index 0000000000000..383a7b0dacf48 --- /dev/null +++ b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_c.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff/src/rules/flake8_copyright/mod.rs +--- + diff --git a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_caps.snap b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_caps.snap new file mode 100644 index 0000000000000..383a7b0dacf48 --- /dev/null +++ b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_caps.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff/src/rules/flake8_copyright/mod.rs +--- + diff --git a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_range.snap b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_range.snap new file mode 100644 index 0000000000000..383a7b0dacf48 --- /dev/null +++ b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_range.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff/src/rules/flake8_copyright/mod.rs +--- + diff --git a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__small_file.snap b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__small_file.snap new file mode 100644 index 0000000000000..383a7b0dacf48 --- /dev/null +++ b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__small_file.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff/src/rules/flake8_copyright/mod.rs +--- + diff --git a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__valid_author.snap b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__valid_author.snap new file mode 100644 index 0000000000000..383a7b0dacf48 --- /dev/null +++ b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__valid_author.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff/src/rules/flake8_copyright/mod.rs +--- + diff --git a/crates/ruff/src/rules/mod.rs b/crates/ruff/src/rules/mod.rs index 4a12fb0319c70..e8fd430cb0212 100644 --- a/crates/ruff/src/rules/mod.rs +++ b/crates/ruff/src/rules/mod.rs @@ -1,6 +1,5 @@ #![allow(clippy::useless_format)] pub mod airflow; -pub mod copyright; pub mod eradicate; pub mod flake8_2020; pub mod flake8_annotations; @@ -12,6 +11,7 @@ pub mod flake8_bugbear; pub mod flake8_builtins; pub mod flake8_commas; pub mod flake8_comprehensions; +pub mod flake8_copyright; pub mod flake8_datetimez; pub mod flake8_debugger; pub mod flake8_django; diff --git a/crates/ruff/src/settings/configuration.rs b/crates/ruff/src/settings/configuration.rs index 213128b966b6f..16143a83cba06 100644 --- a/crates/ruff/src/settings/configuration.rs +++ b/crates/ruff/src/settings/configuration.rs @@ -16,8 +16,8 @@ use crate::fs; use crate::line_width::{LineLength, TabSize}; use crate::rule_selector::RuleSelector; use crate::rules::{ - copyright, flake8_annotations, flake8_bandit, flake8_bugbear, flake8_builtins, - flake8_comprehensions, flake8_errmsg, flake8_gettext, flake8_implicit_str_concat, + flake8_annotations, flake8_bandit, flake8_bugbear, flake8_builtins, flake8_comprehensions, + flake8_copyright, flake8_errmsg, flake8_gettext, flake8_implicit_str_concat, flake8_import_conventions, flake8_pytest_style, flake8_quotes, flake8_self, flake8_tidy_imports, flake8_type_checking, flake8_unused_arguments, isort, mccabe, pep8_naming, pycodestyle, pydocstyle, pyflakes, pylint, @@ -75,14 +75,14 @@ pub struct Configuration { pub flake8_bugbear: Option, pub flake8_builtins: Option, pub flake8_comprehensions: Option, - pub copyright: Option, + pub flake8_copyright: Option, pub flake8_errmsg: Option, + pub flake8_gettext: Option, pub flake8_implicit_str_concat: Option, pub flake8_import_conventions: Option, pub flake8_pytest_style: Option, pub flake8_quotes: Option, pub flake8_self: Option, - pub flake8_gettext: Option, pub flake8_tidy_imports: Option, pub flake8_type_checking: Option, pub flake8_unused_arguments: Option, @@ -229,7 +229,7 @@ impl Configuration { flake8_bugbear: options.flake8_bugbear, flake8_builtins: options.flake8_builtins, flake8_comprehensions: options.flake8_comprehensions, - copyright: options.copyright, + flake8_copyright: options.flake8_copyright, flake8_errmsg: options.flake8_errmsg, flake8_gettext: options.flake8_gettext, flake8_implicit_str_concat: options.flake8_implicit_str_concat, @@ -308,7 +308,7 @@ impl Configuration { flake8_comprehensions: self .flake8_comprehensions .combine(config.flake8_comprehensions), - copyright: self.copyright.combine(config.copyright), + flake8_copyright: self.flake8_copyright.combine(config.flake8_copyright), flake8_errmsg: self.flake8_errmsg.combine(config.flake8_errmsg), flake8_gettext: self.flake8_gettext.combine(config.flake8_gettext), flake8_implicit_str_concat: self diff --git a/crates/ruff/src/settings/defaults.rs b/crates/ruff/src/settings/defaults.rs index 129c3a16f26ca..8ae6d16e73eeb 100644 --- a/crates/ruff/src/settings/defaults.rs +++ b/crates/ruff/src/settings/defaults.rs @@ -10,8 +10,8 @@ use crate::line_width::{LineLength, TabSize}; use crate::registry::Linter; use crate::rule_selector::{prefix_to_selector, RuleSelector}; use crate::rules::{ - copyright, flake8_annotations, flake8_bandit, flake8_bugbear, flake8_builtins, - flake8_comprehensions, flake8_errmsg, flake8_gettext, flake8_implicit_str_concat, + flake8_annotations, flake8_bandit, flake8_bugbear, flake8_builtins, flake8_comprehensions, + flake8_copyright, flake8_errmsg, flake8_gettext, flake8_implicit_str_concat, flake8_import_conventions, flake8_pytest_style, flake8_quotes, flake8_self, flake8_tidy_imports, flake8_type_checking, flake8_unused_arguments, isort, mccabe, pep8_naming, pycodestyle, pydocstyle, pyflakes, pylint, @@ -96,7 +96,7 @@ impl Default for Settings { flake8_bugbear: flake8_bugbear::settings::Settings::default(), flake8_builtins: flake8_builtins::settings::Settings::default(), flake8_comprehensions: flake8_comprehensions::settings::Settings::default(), - copyright: copyright::settings::Settings::default(), + flake8_copyright: flake8_copyright::settings::Settings::default(), flake8_errmsg: flake8_errmsg::settings::Settings::default(), flake8_implicit_str_concat: flake8_implicit_str_concat::settings::Settings::default(), flake8_import_conventions: flake8_import_conventions::settings::Settings::default(), diff --git a/crates/ruff/src/settings/mod.rs b/crates/ruff/src/settings/mod.rs index 9a36b599080b4..0f7b961734e0a 100644 --- a/crates/ruff/src/settings/mod.rs +++ b/crates/ruff/src/settings/mod.rs @@ -16,8 +16,8 @@ use ruff_macros::CacheKey; use crate::registry::{Rule, RuleNamespace, RuleSet, INCOMPATIBLE_CODES}; use crate::rule_selector::{RuleSelector, Specificity}; use crate::rules::{ - copyright, flake8_annotations, flake8_bandit, flake8_bugbear, flake8_builtins, - flake8_comprehensions, flake8_errmsg, flake8_gettext, flake8_implicit_str_concat, + flake8_annotations, flake8_bandit, flake8_bugbear, flake8_builtins, flake8_comprehensions, + flake8_copyright, flake8_errmsg, flake8_gettext, flake8_implicit_str_concat, flake8_import_conventions, flake8_pytest_style, flake8_quotes, flake8_self, flake8_tidy_imports, flake8_type_checking, flake8_unused_arguments, isort, mccabe, pep8_naming, pycodestyle, pydocstyle, pyflakes, pylint, @@ -112,11 +112,11 @@ pub struct Settings { pub flake8_bugbear: flake8_bugbear::settings::Settings, pub flake8_builtins: flake8_builtins::settings::Settings, pub flake8_comprehensions: flake8_comprehensions::settings::Settings, - pub copyright: copyright::settings::Settings, + pub flake8_copyright: flake8_copyright::settings::Settings, pub flake8_errmsg: flake8_errmsg::settings::Settings, + pub flake8_gettext: flake8_gettext::settings::Settings, pub flake8_implicit_str_concat: flake8_implicit_str_concat::settings::Settings, pub flake8_import_conventions: flake8_import_conventions::settings::Settings, - pub flake8_gettext: flake8_gettext::settings::Settings, pub flake8_pytest_style: flake8_pytest_style::settings::Settings, pub flake8_quotes: flake8_quotes::settings::Settings, pub flake8_self: flake8_self::settings::Settings, @@ -210,9 +210,9 @@ impl Settings { .flake8_comprehensions .map(flake8_comprehensions::settings::Settings::from) .unwrap_or_default(), - copyright: config - .copyright - .map(copyright::settings::Settings::try_from) + flake8_copyright: config + .flake8_copyright + .map(flake8_copyright::settings::Settings::try_from) .transpose()? .unwrap_or_default(), flake8_errmsg: config diff --git a/crates/ruff/src/settings/options.rs b/crates/ruff/src/settings/options.rs index 7015b29b60e32..ea18f0cb6de88 100644 --- a/crates/ruff/src/settings/options.rs +++ b/crates/ruff/src/settings/options.rs @@ -8,8 +8,8 @@ use ruff_macros::ConfigurationOptions; use crate::line_width::{LineLength, TabSize}; use crate::rule_selector::RuleSelector; use crate::rules::{ - copyright, flake8_annotations, flake8_bandit, flake8_bugbear, flake8_builtins, - flake8_comprehensions, flake8_errmsg, flake8_gettext, flake8_implicit_str_concat, + flake8_annotations, flake8_bandit, flake8_bugbear, flake8_builtins, flake8_comprehensions, + flake8_copyright, flake8_errmsg, flake8_gettext, flake8_implicit_str_concat, flake8_import_conventions, flake8_pytest_style, flake8_quotes, flake8_self, flake8_tidy_imports, flake8_type_checking, flake8_unused_arguments, isort, mccabe, pep8_naming, pycodestyle, pydocstyle, pyflakes, pylint, @@ -499,7 +499,7 @@ pub struct Options { pub flake8_comprehensions: Option, #[option_group] /// Options for the `copyright` plugin. - pub copyright: Option, + pub flake8_copyright: Option, #[option_group] /// Options for the `flake8-errmsg` plugin. pub flake8_errmsg: Option, diff --git a/crates/ruff_wasm/src/lib.rs b/crates/ruff_wasm/src/lib.rs index dce7b797973e3..2a449d0864e44 100644 --- a/crates/ruff_wasm/src/lib.rs +++ b/crates/ruff_wasm/src/lib.rs @@ -9,8 +9,8 @@ use ruff::line_width::{LineLength, TabSize}; use ruff::linter::{check_path, LinterResult}; use ruff::registry::AsRule; use ruff::rules::{ - copyright, flake8_annotations, flake8_bandit, flake8_bugbear, flake8_builtins, - flake8_comprehensions, flake8_errmsg, flake8_gettext, flake8_implicit_str_concat, + flake8_annotations, flake8_bandit, flake8_bugbear, flake8_builtins, flake8_comprehensions, + flake8_copyright, flake8_errmsg, flake8_gettext, flake8_implicit_str_concat, flake8_import_conventions, flake8_pytest_style, flake8_quotes, flake8_self, flake8_tidy_imports, flake8_type_checking, flake8_unused_arguments, isort, mccabe, pep8_naming, pycodestyle, pydocstyle, pyflakes, pylint, @@ -138,11 +138,8 @@ pub fn defaultSettings() -> Result { flake8_bugbear: Some(flake8_bugbear::settings::Settings::default().into()), flake8_builtins: Some(flake8_builtins::settings::Settings::default().into()), flake8_comprehensions: Some(flake8_comprehensions::settings::Settings::default().into()), - copyright: Some(copyright::settings::Settings::default().into()), + flake8_copyright: Some(flake8_copyright::settings::Settings::default().into()), flake8_errmsg: Some(flake8_errmsg::settings::Settings::default().into()), - flake8_pytest_style: Some(flake8_pytest_style::settings::Settings::default().into()), - flake8_quotes: Some(flake8_quotes::settings::Settings::default().into()), - flake8_self: Some(flake8_self::settings::Settings::default().into()), flake8_gettext: Some(flake8_gettext::settings::Settings::default().into()), flake8_implicit_str_concat: Some( flake8_implicit_str_concat::settings::Settings::default().into(), @@ -150,6 +147,9 @@ pub fn defaultSettings() -> Result { flake8_import_conventions: Some( flake8_import_conventions::settings::Settings::default().into(), ), + flake8_pytest_style: Some(flake8_pytest_style::settings::Settings::default().into()), + flake8_quotes: Some(flake8_quotes::settings::Settings::default().into()), + flake8_self: Some(flake8_self::settings::Settings::default().into()), flake8_tidy_imports: Some(flake8_tidy_imports::settings::Settings::default().into()), flake8_type_checking: Some(flake8_type_checking::settings::Settings::default().into()), flake8_unused_arguments: Some( diff --git a/ruff.schema.json b/ruff.schema.json index c74c74e26b729..77cd975fac15f 100644 --- a/ruff.schema.json +++ b/ruff.schema.json @@ -32,17 +32,6 @@ "null" ] }, - "copyright": { - "description": "Options for the `copyright` plugin.", - "anyOf": [ - { - "$ref": "#/definitions/CopyrightOptions" - }, - { - "type": "null" - } - ] - }, "dummy-variable-rgx": { "description": "A regular expression used to identify \"dummy\" variables, or those which should be ignored when enforcing (e.g.) unused-variable rules. The default expression matches `_`, `__`, and `_var`, but not `_var_`.", "type": [ @@ -209,6 +198,17 @@ } ] }, + "flake8-copyright": { + "description": "Options for the `copyright` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/Flake8CopyrightOptions" + }, + { + "type": "null" + } + ] + }, "flake8-errmsg": { "description": "Options for the `flake8-errmsg` plugin.", "anyOf": [ @@ -631,35 +631,6 @@ } ] }, - "CopyrightOptions": { - "type": "object", - "properties": { - "author": { - "description": "Author to enforce within the copyright notice. If provided, the author must be present immediately following the copyright notice.", - "type": [ - "string", - "null" - ] - }, - "min-file-size": { - "description": "A minimum file size (in bytes) required for a copyright notice to be enforced. By default, all files are validated.", - "type": [ - "integer", - "null" - ], - "format": "uint", - "minimum": 0.0 - }, - "notice-rgx": { - "description": "The regular expression used to match the copyright notice, compiled with the [`regex`](https://docs.rs/regex/latest/regex/) crate.\n\nDefaults to `(?i)Copyright\\s+(\\(C\\)\\s+)?\\d{4}(-\\d{4})*`, which matches the following: - `Copyright 2023` - `Copyright (C) 2023` - `Copyright 2021-2023` - `Copyright (C) 2021-2023`", - "type": [ - "string", - "null" - ] - } - }, - "additionalProperties": false - }, "Flake8AnnotationsOptions": { "type": "object", "properties": { @@ -779,6 +750,35 @@ }, "additionalProperties": false }, + "Flake8CopyrightOptions": { + "type": "object", + "properties": { + "author": { + "description": "Author to enforce within the copyright notice. If provided, the author must be present immediately following the copyright notice.", + "type": [ + "string", + "null" + ] + }, + "min-file-size": { + "description": "A minimum file size (in bytes) required for a copyright notice to be enforced. By default, all files are validated.", + "type": [ + "integer", + "null" + ], + "format": "uint", + "minimum": 0.0 + }, + "notice-rgx": { + "description": "The regular expression used to match the copyright notice, compiled with the [`regex`](https://docs.rs/regex/latest/regex/) crate.\n\nDefaults to `(?i)Copyright\\s+(\\(C\\)\\s+)?\\d{4}(-\\d{4})*`, which matches the following: - `Copyright 2023` - `Copyright (C) 2023` - `Copyright 2021-2023` - `Copyright (C) 2021-2023`", + "type": [ + "string", + "null" + ] + } + }, + "additionalProperties": false + }, "Flake8ErrMsgOptions": { "type": "object", "properties": {