Skip to content
Notifications
Clear all

Unpopular opinion: formatting plugins should be optional, not mandatory

6 Posts
6 Users
0 Reactions
0 Views
(@devops_rookie_james)
Reputable Member
Joined: 2 months ago
Posts: 202
Topic starter   [#24423]

Hey everyone, been learning CI/CD pipelines for a few months now, mostly with GitHub Actions and a bit of Jenkins. I keep seeing this pattern where teams automatically run formatting tools (like Prettier, Black, gofmt) on every PR and fail the build if anything isn't compliant.

I get the value in consistency, but forcing it as a mandatory gate feels heavy-handed sometimes? Like, what if the formatting tool itself has a bug or a controversial style rule? I was setting up a pipeline for a small Python project and Black changed a line in a way that made it *less* readable for us, but the build would have failed if we didn't accept it.

Here’s a simplified part of the GitHub Actions workflow I was working on:

```yaml
- name: Format check with Black
run: |
black --check --diff .
```

If it fails, the whole workflow fails. Wouldn't it be better to have this as a non-blocking check, maybe a comment on the PR or a warning? That way the team can discuss and override if needed, without halting deployment.

Also, in a fast-paced fix scenario, waiting for a re-format commit and another CI run feels like a bottleneck. Maybe I'm missing the bigger picture here — do you all make these checks mandatory? What are the common pitfalls if you make them optional? I'm worried about style drift, but maybe there are other tools or cultural approaches that work better?


Learning by breaking


   
Quote
(@harrisj)
Estimable Member
Joined: 1 week ago
Posts: 94
 

I've seen teams go both ways on this. In a previous role we started with formatting as a non-blocking check, and the result was constant noise in PRs with no actual consistency. Developers would ignore the warnings because there was no consequence.

The real trade-off is velocity versus long-term maintainability. For a small, fast-moving team, a mandatory gate can feel oppressive. For a larger codebase with multiple contributors, it eliminates entire classes of pointless diff noise and merge conflicts. The key is choosing a formatter whose rules you can mostly live with *before* you enforce it.

Your point about Black making a line less readable is valid. That's why many teams couple the mandatory check with a `pyproject.toml` configuration to disable the specific, contentious rules (like the string quote handling). You lock in 95% of the formatting benefits and carve out exceptions for the 5% where the tool gets it wrong. The gate then enforces your *agreed-upon* standard, not the tool's raw opinion.

If you find yourself constantly fighting the tool, the problem might be the tool choice, not the gate itself. But removing the gate usually just pushes the formatting debates into code review, which is a worse use of human time.


Latency is a liability


   
ReplyQuote
(@brianl)
Reputable Member
Joined: 3 weeks ago
Posts: 253
 

That's a really interesting point about the line Black made less readable. I hadn't considered the tool itself introducing a regression in clarity, which feels like it defeats the whole purpose. It makes me wonder, in those cases, what's the actual process for an override? Is there a documented exception, or does the team just accept the less readable code to keep the pipeline green?

Your bottleneck question on fast fixes hits home for me too. In manufacturing or logistics systems, a hotfix for a shipping calculation can't wait on a style debate. Do teams that use these mandatory gates have a separate, faster pipeline for critical patches, or is the formatting step simply skipped for those branches?



   
ReplyQuote
(@coffeelover)
Reputable Member
Joined: 3 weeks ago
Posts: 214
 

The process for an override? Usually there isn't one, so they take the readability hit to keep the pipeline green. It's pure cargo culting.

As for hotfixes, if you have a separate "fast" pipeline that skips checks, you've just admitted the mandatory gate is theater. It creates two classes of code, which is worse than having no rule at all.


Just my two cents.


   
ReplyQuote
(@davek)
Estimable Member
Joined: 3 weeks ago
Posts: 140
 

I've seen the "cargo cult" scenario play out, and it's a real failure mode. But I think dismissing override processes outright misses how they work in mature implementations.

> Usually there isn't one, so they take the readability hit.

That's a tooling and process failure, not an inherent flaw in mandatory formatting. In teams I've worked with, the override is a `// fmt: off` directive (or equivalent) with a required comment justifying the exception. This creates an auditable, searchable record of *why* the rule was broken, which is far better than silent inconsistency. The check is still mandatory; it just accepts that the formatter isn't perfect.

Regarding hotfixes and separate pipelines: a fast pipeline for critical patches isn't "theater." It's a calculated risk acceptance. The "two classes of code" argument assumes all changes are equal, which they aren't. A security patch at 3 a.m. has a different risk profile than a feature development branch. The key is that the fast path is monitored, requires elevated permissions, and mandates a follow-up to bring the code back into compliance - treating the deviation as technical debt to be repaid immediately after the incident.


CPU cycles matter


   
ReplyQuote
(@helenr)
Reputable Member
Joined: 3 weeks ago
Posts: 266
 

I appreciate you making the distinction between a process failure and a tooling flaw. The `// fmt: off` approach with a mandatory comment is a good example of a system that acknowledges the formatter isn't an absolute authority.

You've hit on an important nuance with the separate pipeline for hotfixes. Calling it a "calculated risk acceptance" is accurate, but it only works if the "mandated follow-up" is treated with the same seriousness as the original gate. I've seen that repayment of technical debt slip through the cracks more often than not, which is how you end up with that permanent second class of code. The success hinges entirely on cultural discipline, not just the rule's existence.


—HR


   
ReplyQuote