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

Code before:
                    entry.disabled_codes.push(code_str);
                }
            } else if let DisableEnableComments::Disable(comment) = &suppression.comments {
                // UnmatchedSuppressionComment
                if unmatched_ranges.insert(comment.range) {
                    context.report_diagnostic_if_enabled(
                        UnmatchedSuppressionComment {},
                        comment.range,
                    );
                }
            }
        }

        for group in grouped_diagnostics.values() {
            if group.any_invalid() {
                Suppressions::report_suppression_codes(
                    context,
                    locator,
                    group.suppression,
                    &group.invalid_codes,
                    true,
                    InvalidRuleCode {
                        rule_code: group
                            .invalid_codes
                            .iter()
                            .map(ToString::to_string)
                            .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,
                    UnusedNOQA {
                        codes: Some(UnusedCodes {
                            disabled: group
                                .disabled_codes
                                .iter()
                                .map(ToString::to_string)
                                .collect_vec(),
                            duplicated: group
                                .duplicated_codes
                                .iter()

Review comment (suggestion):
I think `join` will handle this automatically:


```suggestion
```

Code after:
                                duplicated: group
                                    .duplicated_codes
                                    .iter()
                                    .map(ToString::to_string)
                                    .collect_vec(),
                                unmatched: group
                                    .unused_codes
                                    .iter()
                                    .map(ToString::to_string)
                                    .collect_vec(),
                                ..Default::default()
                            }),
                            kind: UnusedNOQAKind::Suppression,
                        },
                    );
                }
                grouped_diagnostic = None;
            }

            let code_str = suppression.code.as_str();

            if !code_is_valid(&suppression.code, &context.settings().external) {
                // InvalidRuleCode
                let (_key, group) = grouped_diagnostic
                    .get_or_insert_with(|| (key, SuppressionDiagnostic::new(suppression)));
                group.invalid_codes.push(code_str);
            } else if !suppression.used.get() {
                // UnusedNOQA
                let Ok(rule) = Rule::from_code(
                    get_redirect_target(&suppression.code).unwrap_or(&suppression.code),
                ) else {
                    continue; // "external" lint code, don't treat it as unused
                };

                let (_key, group) = grouped_diagnostic
                    .get_or_insert_with(|| (key, SuppressionDiagnostic::new(suppression)));

                if context.is_rule_enabled(rule) {
                    if suppression
                        .comments
                        .disable_comment()
                        .codes_as_str(locator.contents())
                        .filter(|code| *code == code_str)
                        .count()
                        > 1
                    {
                        group.duplicated_codes.push(code_str);
                    } else {
                        group.unused_codes.push(code_str);
                    }
                } else {