diff --git a/crates/ruff/tests/snapshots/show_settings__display_default_settings.snap b/crates/ruff/tests/snapshots/show_settings__display_default_settings.snap index f784ff99a0629..02c735ec3dc94 100644 --- a/crates/ruff/tests/snapshots/show_settings__display_default_settings.snap +++ b/crates/ruff/tests/snapshots/show_settings__display_default_settings.snap @@ -232,7 +232,7 @@ linter.flake8_bandit.check_typed_exception = false linter.flake8_bugbear.extend_immutable_calls = [] linter.flake8_builtins.builtins_ignorelist = [] linter.flake8_comprehensions.allow_dict_calls_with_keyword_arguments = false -linter.flake8_copyright.notice_rgx = (?i)Copyright\s+(\(C\)\s+)?\d{4}(-\d{4})* +linter.flake8_copyright.notice_rgx = (?i)Copyright\s+((?:\(C\)|©)\s+)?\d{4}(-\d{4})* linter.flake8_copyright.author = none linter.flake8_copyright.min_file_size = 0 linter.flake8_errmsg.max_string_length = 0 diff --git a/crates/ruff_linter/src/rules/flake8_copyright/mod.rs b/crates/ruff_linter/src/rules/flake8_copyright/mod.rs index 534f2eaf09547..7b760f72bf427 100644 --- a/crates/ruff_linter/src/rules/flake8_copyright/mod.rs +++ b/crates/ruff_linter/src/rules/flake8_copyright/mod.rs @@ -29,6 +29,20 @@ import os r" # Copyright (C) 2023 +import os +" + .trim(), + &settings::LinterSettings::for_rules(vec![Rule::MissingCopyrightNotice]), + ); + assert_messages!(diagnostics); + } + + #[test] + fn notice_with_unicode_c() { + let diagnostics = test_snippet( + r" +# Copyright © 2023 + import os " .trim(), diff --git a/crates/ruff_linter/src/rules/flake8_copyright/settings.rs b/crates/ruff_linter/src/rules/flake8_copyright/settings.rs index 9f76e763cf880..34a5c06d350ca 100644 --- a/crates/ruff_linter/src/rules/flake8_copyright/settings.rs +++ b/crates/ruff_linter/src/rules/flake8_copyright/settings.rs @@ -15,7 +15,7 @@ pub struct Settings { } pub static COPYRIGHT: Lazy = - Lazy::new(|| Regex::new(r"(?i)Copyright\s+(\(C\)\s+)?\d{4}(-\d{4})*").unwrap()); + Lazy::new(|| Regex::new(r"(?i)Copyright\s+((?:\(C\)|©)\s+)?\d{4}(-\d{4})*").unwrap()); impl Default for Settings { fn default() -> Self { diff --git a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__notice_with_unicode_c.snap b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__notice_with_unicode_c.snap new file mode 100644 index 0000000000000..314ed9c4f967d --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__notice_with_unicode_c.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs +--- + diff --git a/crates/ruff_workspace/src/options.rs b/crates/ruff_workspace/src/options.rs index 89be64b5ebed1..d83a6fb3d346d 100644 --- a/crates/ruff_workspace/src/options.rs +++ b/crates/ruff_workspace/src/options.rs @@ -1123,14 +1123,14 @@ pub struct Flake8CopyrightOptions { /// The regular expression used to match the copyright notice, compiled /// with the [`regex`](https://docs.rs/regex/latest/regex/) crate. /// - /// Defaults to `(?i)Copyright\s+(\(C\)\s+)?\d{4}(-\d{4})*`, which matches + /// Defaults 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` #[option( - default = r#"(?i)Copyright\s+(\(C\)\s+)?\d{4}([-,]\d{4})*"#, + default = r#"(?i)Copyright\s+((?:\(C\)|©)\s+)?\d{4}([-,]\d{4})*"#, value_type = "str", example = r#"notice-rgx = "(?i)Copyright \\(C\\) \\d{4}""# )] diff --git a/ruff.schema.json b/ruff.schema.json index cf905a5a587fc..ae81665c41985 100644 --- a/ruff.schema.json +++ b/ruff.schema.json @@ -953,7 +953,7 @@ "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`", + "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"