Repository: risingwavelabs/risingwave
File: src/meta/src/manager/diagnose.rs (Rust)

Code before:
                row.add_cell("status".into());
                row.add_cell("valid".into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("tier".into());
                row.add_cell(format!("{:?}", license.tier).into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("expires_at".into());
                row.add_cell(expires_at.into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("rwu_limit".into());
                row.add_cell(fmt_option(license.rwu_limit.map(|v| v.get())).into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("cpu_core_limit".into());
                row.add_cell(fmt_option(license.cpu_core_limit()).into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("memory_limit_bytes".into());
                row.add_cell(fmt_option(license.memory_limit()).into());
                table.add_row(row);

                let mut features: Vec<_> = license
                    .tier
                    .available_features()
                    .map(|f| f.name())
                    .collect();
                features.sort_unstable();
                let feature_summary = format_features(&features);

                let mut row = Row::new();
                row.add_cell("available_features".into());
                row.add_cell(feature_summary.into());
                table.add_row(row);
            }
            Err(error) => {
                let mut row = Row::new();
                row.add_cell("status".into());
                row.add_cell("invalid".into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("error".into());
                row.add_cell(error.to_report_string().into());

Review comment (refactor):
The repetitive pattern of creating rows and adding cells can be refactored into a helper function. Consider creating a helper that takes a label and value to reduce code duplication and improve maintainability.

Code after:
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("tier".into());
                row.add_cell(license.tier.name().into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("expires_at".into());
                row.add_cell(expires_at.into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("rwu_limit".into());
                row.add_cell(fmt_option(license.rwu_limit.map(|v| v.get())).into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("cpu_core_limit".into());
                row.add_cell(fmt_option(license.cpu_core_limit()).into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("memory_limit_bytes".into());
                row.add_cell(fmt_option(license.memory_limit()).into());
                table.add_row(row);

                let mut features: Vec<_> = license
                    .tier
                    .available_features()
                    .map(|f| f.name())
                    .collect();
                features.sort_unstable();
                let feature_summary = format_features(&features);

                let mut row = Row::new();
                row.add_cell("available_features".into());
                row.add_cell(feature_summary.into());
                table.add_row(row);
            }
            Err(error) => {
                let mut row = Row::new();
                row.add_cell("status".into());
                row.add_cell("invalid".into());
                table.add_row(row);

                let mut row = Row::new();
                row.add_cell("error".into());
                row.add_cell(error.to_report_string().into());
                table.add_row(row);
            }