Cheap Checks Before the Model
a deterministic static pre-pass
Part of: AI Code Reviewer
Some problems are so mechanical that a regex finds them every time. A bare except: is always worth flagging. So is eval( on anything. Sending those to a model costs tokens, adds latency, and gives you a reviewer that sometimes misses them. A static pre-pass catches the obvious cases with plain code before the model ever runs. Rules as data. Write each check as a row with an id, a category, a severity, and a pattern. Keeping rules as data makes them easy to list in the UI, turn off, or count in an evaluation. A line longer than 79 characters gets a long-line style finding too. That one is a length check, so it sits outside the regex table. Why these rules. - mutable-default catches def add(item, items=[]). The list is created once and shared by every call, which is a real bug that surprises people. - bare-except swallows every error, including the ones you didn't plan for. - eval-exec runs whatever string it is given, which is a security hole when that string comes from a user. - none-compare works but reads oddly, since is None is the idiom. - range-len is slower and noisier than looping over the items directly. Static first, model second. The pre-pass runs in microseconds and is r
Challenge: Run the Pre-Pass