From 431bc8b645af3c6002d892a40509a0f8c5907bf7 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 20 Feb 2024 11:39:35 -0500 Subject: [PATCH] =?UTF-8?q?Allow=20=C2=A9=20in=20copyright=20notices?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruff_linter/src/rules/flake8_copyright/mod.rs | 14 ++++++++++++++ .../src/rules/flake8_copyright/settings.rs | 2 +- ...e8_copyright__tests__notice_with_unicode_c.snap | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__notice_with_unicode_c.snap diff --git a/crates/ruff_linter/src/rules/flake8_copyright/mod.rs b/crates/ruff_linter/src/rules/flake8_copyright/mod.rs index 534f2eaf09547a..7b760f72bf4271 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 9f76e763cf8808..34a5c06d350cad 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 00000000000000..314ed9c4f967d1 --- /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 +--- +