Repository: astral-sh/ruff
File: crates/ruff_linter/src/suppression.rs (Rust)

Code before:
        };
        let Some(range) = span.range() else {
            return false;
        };

        for suppression in &self.valid {
            let suppression_code =
                get_redirect_target(suppression.code.as_str()).unwrap_or(suppression.code.as_str());
            if *code == suppression_code && suppression.range.contains_range(range) {
                suppression.used.set(true);
                return true;
            }
        }
        false
    }

    pub(crate) fn check_suppressions(&self, context: &LintContext, locator: &Locator) {
        let mut grouped_diagnostic: Option<(TextRange, SuppressionDiagnostic)> = None;
        let mut unmatched_ranges = FxHashSet::default();

        let process_pending_diagnostics =
            |key: Option<TextRange>,
             grouped_diagnostic: &Option<(TextRange, SuppressionDiagnostic)>|
             -> bool {
                if let Some((group_key, group)) = grouped_diagnostic
                    && (key.is_none() || key.is_some_and(|key| key != *group_key))
                {
                    if group.any_invalid() {
                        Suppressions::report_suppression_codes(
                            context,
                            locator,
                            group.suppression,
                            &group.invalid_codes,
                            true,
                            InvalidRuleCode {
                                rule_code: group.invalid_codes.iter().join(", "),
                                kind: InvalidRuleCodeKind::Suppression,
                                whole_comment: group.suppression.codes().len()
                                    == group.invalid_codes.len(),
                            },
                        );
                    }
                    if group.any_unused() {
                        let mut codes = group.disabled_codes.clone();
                        codes.extend(group.unused_codes.clone());
                        Suppressions::report_suppression_codes(
                            context,
                            locator,
                            group.suppression,
                            &codes,
                            false,

Review comment (suggestion):
I think this is:


```suggestion
                    && (key.is_none_or(|key| key != *group_key))
```

Code after:
        };
        let Some(range) = span.range() else {
            return false;
        };

        for suppression in &self.valid {
            let suppression_code =
                get_redirect_target(suppression.code.as_str()).unwrap_or(suppression.code.as_str());
            if *code == suppression_code && suppression.range.contains_range(range) {
                suppression.used.set(true);
                return true;
            }
        }
        false
    }

    pub(crate) fn check_suppressions(&self, context: &LintContext, locator: &Locator) {
        let mut grouped_diagnostic: Option<(TextRange, SuppressionDiagnostic)> = None;
        let mut unmatched_ranges = FxHashSet::default();

        let process_pending_diagnostics =
            |key: Option<TextRange>,
             grouped_diagnostic: &Option<(TextRange, SuppressionDiagnostic)>|
             -> bool {
                if let Some((group_key, group)) = grouped_diagnostic
                    && key.is_none_or(|key| key != *group_key)
                {
                    if group.any_invalid() {
                        Suppressions::report_suppression_codes(
                            context,
                            locator,
                            group.suppression,
                            &group.invalid_codes,
                            true,
                            InvalidRuleCode {
                                rule_code: group.invalid_codes.iter().join(", "),
                                kind: InvalidRuleCodeKind::Suppression,
                                whole_comment: group.suppression.codes().len()
                                    == group.invalid_codes.len(),
                            },
                        );
                    }
                    if group.any_unused() {
                        let mut codes = group.disabled_codes.clone();
                        codes.extend(group.unused_codes.clone());
                        Suppressions::report_suppression_codes(
                            context,
                            locator,
                            group.suppression,
                            &codes,
                            false,