{"record":{"id":"000fab9861e10496","repo":"astral-sh/ruff","slug":"expected-comparison-operator","errorCode":null,"errorMessage":"Expected comparison operator","messagePattern":"Expected comparison operator","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ruff_linter/src/rules/flake8_simplify/rules/yoda_conditions.rs","lineNumber":199,"sourceCode":"            } => CompOp::LessThanEqual {\n                whitespace_before: or_space(whitespace_before),\n                whitespace_after: or_space(whitespace_after),\n            },\n            CompOp::Equal {\n                whitespace_before,\n                whitespace_after,\n            } => CompOp::Equal {\n                whitespace_before: or_space(whitespace_before),\n                whitespace_after: or_space(whitespace_after),\n            },\n            CompOp::NotEqual {\n                whitespace_before,\n                whitespace_after,\n            } => CompOp::NotEqual {\n                whitespace_before: or_space(whitespace_before),\n                whitespace_after: or_space(whitespace_after),\n            },\n            _ => panic!(\"Expected comparison operator\"),\n        };\n\n        Ok(expression)\n    })\n}\n\n/// SIM300\npub(crate) fn yoda_conditions(checker: &Checker, compare: &ast::ExprCompare) {\n    let Some((left, op, right)) = compare.as_single() else {\n        return;\n    };\n\n    if !matches!(\n        op,\n        CmpOp::Eq | CmpOp::NotEq | CmpOp::Lt | CmpOp::LtE | CmpOp::Gt | CmpOp::GtE,\n    ) {\n        return;\n    }","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/astral-sh/ruff/blob/15f3fe6b15a5f00172f34b0f542f8ea277f5a586/crates/ruff_linter/src/rules/flake8_simplify/rules/yoda_conditions.rs#L181-L217","documentation":"An unreachable! in reverse_comparison (used by the yoda-conditions fixer): the CST comparison operator being rewritten is not one of the operators the fixer knows how to flip. Since the caller already validated the expression, hitting this arm indicates a mismatch between detection and fixing logic.","triggerScenarios":"Thrown at crates/ruff_linter/src/rules/flake8_simplify/rules/yoda_conditions.rs:200 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add a match arm for the missing operator in reverse_comparison","Restrict the rule trigger to operators the fixer supports"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"15f3fe6b15a5f00172f34b0f542f8ea277f5a586","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}