People have been arguing about how to indent code for as long as there’s been code, and nobody has settled it. Java’s Checkstyle aligns continuations under the open paren, ESLint and Prettier each invent their own rules, Go’s gofmt uses tabs and shrugs, RuboCop hands you a menu, Python’s PEP 8 picks four spaces and leaves the rest to taste. Every tool has its own dialect, and teams waste hours fighting over the details. I suggest a simple rule of monotonic indentation for source code of any programming language: Between any two adjacent lines, indentation may increase by exactly one unit. This rule should resolve most disputes about code formatting style. It is easy to add as an extra check to any existing style checker, or to deploy on its own as a small standalone tool. Покровские ворота (1983) by Михаил Козаков According to the rule, this Java code is illegal: class Repository { void save(File file, String text, String summary, boolean overwrite) { if (file.exists() && !overwrite)…
No comments yet. Log in to reply on the Fediverse. Comments will appear here.