Find constant predicates that are always true or always false

Proprietary

A comparison whose operands are both constant, such as 1 = 1 or 1 = 0, evaluates the same for every row regardless of the data. Combined with OR an always-true constant makes the whole condition always true, so every row matches and the other filters are ignored; an always-false constant used as a filter can never be satisfied, so the query returns nothing. An always-true constant on its own or joined with AND, a common query-builder idiom, is not flagged.

org.openrewrite.sql.antipattern.FindConstantPredicate

Optional

markSourceBoolean

Whether to mark each occurrence in source, and apply the fix where the rule remediates. Defaults to true; set to false to leave source untouched and report only to the data table, as an analysis-only pipeline requires.

mod run . --recipe=org.openrewrite.sql.antipattern.FindConstantPredicate

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.