Rule
Keep lines at a readable length.
Lines that are too long are difficult to read
and navigate, especially on smaller screens.
Supported languages: 45+Introduction
Long lines of code force horizontal scrolling, making it hard to follow logic and spot bugs. They also complicate code reviews and reduce readability across different screen sizes. Maintaining a consistent line length ensures code is easier to navigate, read, and maintain. This rule applies to all languages and environments.
Why it matters
Security implications: Long, dense lines can hide vulnerabilities or make unsafe operations harder to spot during code review.
Performance impact: No direct performance impact, but long lines can increase cognitive load for developers, indirectly affecting productivity.
Code maintainability: Short, well-structured lines are easier to read, review, and modify. They reduce mistakes and simplify debugging.
Code examples
❌ Non-compliant:
function calculateTotal(items) { return items.reduce((sum, item) => sum + item.price * item.quantity, 0); }Why this matters: Breaking the line into multiple segments improves readability and makes it easier to follow the reduce logic.
✅ Compliant:
function calculateTotal(items) {
return items.reduce(
(sum, item) => sum + item.price * item.quantity,
0
);
}Why this matters: Breaking the line into multiple segments improves readability and makes it easier to follow the reduce logic.
❌ Non-compliant (complex object):
const user = { id: 1, name: 'Alice', email: 'alice@example.com', roles: ['admin', 'editor'], active: true };Why it’s wrong: The single line is long and hard to scan, especially when reviewing multiple properties or debugging.
✅ Compliant:
const user = {
id: 1,
name: 'Alice',
email: 'alice@example.com',
roles: ['admin', 'editor'],
active: true
};Why this matters: Multi-line formatting improves readability and maintainability, making it easier to extend or modify properties later.
Conclusion
Keep lines at a manageable length to improve readability, maintainability, and error detection. Break long statements, objects, and function calls into multiple lines for clarity. Consistent formatting makes code reviews faster and reduces cognitive load for developers.
.avif)
