{"record":{"id":"20a9dd04b38e86ad","repo":"astral-sh/ruff","slug":"unsupported-serialization-format-for-statistics","errorCode":null,"errorMessage":"Unsupported serialization format for statistics: {:?}","messagePattern":"Unsupported serialization format for statistics: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ruff/src/printer.rs","lineNumber":388,"sourceCode":"                                &partially_fixable\n                            } else {\n                                unfixable\n                            }\n                        } else {\n                            \"\"\n                        },\n                        statistic.name,\n                    )?;\n                }\n\n                self.write_summary_text(writer, diagnostics)?;\n                return Ok(());\n            }\n            OutputFormat::Json => {\n                writeln!(writer, \"{}\", serde_json::to_string_pretty(&statistics)?)?;\n            }\n            _ => {\n                anyhow::bail!(\n                    \"Unsupported serialization format for statistics: {:?}\",\n                    self.format\n                )\n            }\n        }\n\n        writer.flush()?;\n\n        Ok(())\n    }\n\n    pub(crate) fn write_continuously(\n        &self,\n        writer: &mut dyn Write,\n        diagnostics: &Diagnostics,\n        preview: PreviewMode,\n        prefer_rule_codes: bool,\n    ) -> Result<()> {","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/astral-sh/ruff/blob/672bb4edf04c84f8b0753346359daee4057158f2/crates/ruff/src/printer.rs#L370-L406","documentation":"`--statistics` is implemented only for the text formats (full/concise) and json; requesting statistics with any other `--output-format` reaches this bail and names the unsupported format.","triggerScenarios":"`ruff check --statistics --output-format sarif` (likewise json-lines, azure, github, gitlab, pylint).","commonSituations":"CI configs that set a global machine-readable format and then add --statistics; pipelines copied from jobs that never combined the two flags.","solutions":["Remove --output-format for the statistics run; the default (full) prints text statistics","Use `ruff check --statistics --output-format json` for machine-readable statistics","Scope format flags per command instead of globally in CI configuration"],"exampleFix":"# before\nruff check --statistics --output-format sarif src/\n\n# after\nruff check --statistics --output-format json src/","handlingStrategy":"validation","validationCode":"case \"$fmt\" in\n  full|concise|json) ruff check --statistics --output-format \"$fmt\" \"$@\" ;;\n  *) echo \"--statistics supports only full, concise, or json output\" >&2; exit 1 ;;\nesac","typeGuard":"fn supports_statistics(format: OutputFormat) -> bool {\n    matches!(format, OutputFormat::Full | OutputFormat::Concise | OutputFormat::Json)\n}","tryCatchPattern":null,"preventionTips":["Keep --statistics runs in their own CI step without inheriting a global output format","Use json when statistics must be machine-parsed","Document in CI config which flags are compatible with each output format"],"tags":["cli","output-format","statistics"],"backgroundTag":null,"analyzedSha":"672bb4edf04c84f8b0753346359daee4057158f2","analyzedAt":"2026-08-16T08:54:05.464Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}