From 350409c38b43b8bb7fd75c2cc5d98d9cc2122483 Mon Sep 17 00:00:00 2001 From: weartist Date: Sun, 20 Apr 2025 19:35:33 +0800 Subject: [PATCH 1/5] add fix safety section to docs --- .../flake8_errmsg/rules/string_in_exception.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs b/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs index 9c55e2fad3..ed041cb4d6 100644 --- a/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs +++ b/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs @@ -47,6 +47,11 @@ use crate::Locator; /// raise RuntimeError(msg) /// RuntimeError: 'Some value' is incorrect /// ``` +/// +/// ## Fix safety +/// This rule's fix is marked as unsafe because comments associated with the +/// exception argument may not be reliably matched to their original code +/// positions after the fix is applied. #[derive(ViolationMetadata)] pub(crate) struct RawStringInException; @@ -102,6 +107,11 @@ impl Violation for RawStringInException { /// raise RuntimeError(msg) /// RuntimeError: 'Some value' is incorrect /// ``` +/// +/// ## Fix safety +/// This rule's fix is marked as unsafe because comments associated with the +/// exception argument may not be reliably matched to their original code +/// positions after the fix is applied. #[derive(ViolationMetadata)] pub(crate) struct FStringInException; @@ -158,6 +168,11 @@ impl Violation for FStringInException { /// raise RuntimeError(msg) /// RuntimeError: 'Some value' is incorrect /// ``` +/// +/// ## Fix safety +/// This rule's fix is marked as unsafe because comments associated with the +/// exception argument may not be reliably matched to their original code +/// positions after the fix is applied. #[derive(ViolationMetadata)] pub(crate) struct DotFormatInException; From 412c308011ae72855d0e703052549cbe097b4ef8 Mon Sep 17 00:00:00 2001 From: weartist Date: Sun, 20 Apr 2025 19:52:33 +0800 Subject: [PATCH 2/5] adjust doc --- .../src/rules/flake8_errmsg/rules/string_in_exception.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs b/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs index ed041cb4d6..dda27c6602 100644 --- a/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs +++ b/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs @@ -47,7 +47,7 @@ use crate::Locator; /// raise RuntimeError(msg) /// RuntimeError: 'Some value' is incorrect /// ``` -/// +/// /// ## Fix safety /// This rule's fix is marked as unsafe because comments associated with the /// exception argument may not be reliably matched to their original code @@ -107,7 +107,7 @@ impl Violation for RawStringInException { /// raise RuntimeError(msg) /// RuntimeError: 'Some value' is incorrect /// ``` -/// +/// /// ## Fix safety /// This rule's fix is marked as unsafe because comments associated with the /// exception argument may not be reliably matched to their original code @@ -168,7 +168,7 @@ impl Violation for FStringInException { /// raise RuntimeError(msg) /// RuntimeError: 'Some value' is incorrect /// ``` -/// +/// /// ## Fix safety /// This rule's fix is marked as unsafe because comments associated with the /// exception argument may not be reliably matched to their original code From 2800591d9cdfaf19dec976bcb27df8f91a05e916 Mon Sep 17 00:00:00 2001 From: weartist Date: Sun, 20 Apr 2025 21:38:04 +0800 Subject: [PATCH 3/5] adjust doc --- .../rules/string_in_exception.rs | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs b/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs index dda27c6602..0efb2603a1 100644 --- a/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs +++ b/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs @@ -49,9 +49,11 @@ use crate::Locator; /// ``` /// /// ## Fix safety -/// This rule's fix is marked as unsafe because comments associated with the -/// exception argument may not be reliably matched to their original code -/// positions after the fix is applied. +/// This rule's fix is marked as unsafe because: +/// - Comments associated with the exception argument may not be reliably matched +/// to their original code positions after the fix is applied. +/// - The introduced `msg` variable may shadow an existing variable in the same +/// scope, potentially changing program behavior. #[derive(ViolationMetadata)] pub(crate) struct RawStringInException; @@ -109,9 +111,11 @@ impl Violation for RawStringInException { /// ``` /// /// ## Fix safety -/// This rule's fix is marked as unsafe because comments associated with the -/// exception argument may not be reliably matched to their original code -/// positions after the fix is applied. +/// This rule's fix is marked as unsafe because: +/// - Comments associated with the exception argument may not be reliably matched +/// to their original code positions after the fix is applied. +/// - The introduced `msg` variable may shadow an existing variable in the same +/// scope, potentially changing program behavior. #[derive(ViolationMetadata)] pub(crate) struct FStringInException; @@ -170,9 +174,11 @@ impl Violation for FStringInException { /// ``` /// /// ## Fix safety -/// This rule's fix is marked as unsafe because comments associated with the -/// exception argument may not be reliably matched to their original code -/// positions after the fix is applied. +/// This rule's fix is marked as unsafe because: +/// - Comments associated with the exception argument may not be reliably matched +/// to their original code positions after the fix is applied. +/// - The introduced `msg` variable may shadow an existing variable in the same +/// scope, potentially changing program behavior. #[derive(ViolationMetadata)] pub(crate) struct DotFormatInException; From fb40d0ca285fe1e4664a7a64ac1021d2254e74bf Mon Sep 17 00:00:00 2001 From: weartist Date: Mon, 21 Apr 2025 23:00:59 +0800 Subject: [PATCH 4/5] adjust doc --- .../src/rules/flake8_errmsg/rules/string_in_exception.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs b/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs index 0efb2603a1..1e274f3e75 100644 --- a/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs +++ b/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs @@ -111,7 +111,7 @@ impl Violation for RawStringInException { /// ``` /// /// ## Fix safety -/// This rule's fix is marked as unsafe because: +/// This fix is marked as unsafe because: /// - Comments associated with the exception argument may not be reliably matched /// to their original code positions after the fix is applied. /// - The introduced `msg` variable may shadow an existing variable in the same From 84ac862778a7ea11a314e097c9f0173f79fbc949 Mon Sep 17 00:00:00 2001 From: weartist Date: Mon, 21 Apr 2025 23:01:32 +0800 Subject: [PATCH 5/5] adjust doc --- .../src/rules/flake8_errmsg/rules/string_in_exception.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs b/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs index 1e274f3e75..6c1190678e 100644 --- a/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs +++ b/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs @@ -49,7 +49,7 @@ use crate::Locator; /// ``` /// /// ## Fix safety -/// This rule's fix is marked as unsafe because: +/// This fix is marked as unsafe because: /// - Comments associated with the exception argument may not be reliably matched /// to their original code positions after the fix is applied. /// - The introduced `msg` variable may shadow an existing variable in the same @@ -174,7 +174,7 @@ impl Violation for FStringInException { /// ``` /// /// ## Fix safety -/// This rule's fix is marked as unsafe because: +/// This fix is marked as unsafe because: /// - Comments associated with the exception argument may not be reliably matched /// to their original code positions after the fix is applied. /// - The introduced `msg` variable may shadow an existing variable in the same