mchades opened a new issue, #9834: URL: https://github.com/apache/gravitino/issues/9834
### Problem Currently, the Spotless configuration uses Google Java Format for code formatting, but it does **not enforce the 100-character line length limit** specified in the Google Java Style Guide. This was discovered during PR review ([#9824](https://github.com/apache/gravitino/pull/9824#discussion_r2747481313)) where a line exceeded 100 characters but passed `spotlessCheck`. ### Root Cause Google Java Format (used by Spotless) handles code formatting like indentation and whitespace, but it **does not automatically split long string literals** or enforce line length limits. This means: - `./gradlew build` passes even when lines exceed 100 characters - Line length violations can only be caught during manual code review ### Proposed Solution Add a custom Spotless step to enforce the 100-character line length limit: ```kotlin custom("Enforce line length limit (100 chars)") { fileContent -> val maxLineLength = 100 val lines = fileContent.split("\n") val violations = mutableListOf<String>() lines.forEachIndexed { index, line -> val trimmedLine = line.trimEnd('\r') if (trimmedLine.length > maxLineLength) { violations.add("Line ${index + 1}: ${trimmedLine.length} chars (max $maxLineLength)") } } if (violations.isNotEmpty()) { throw AssertionError( "Lines exceed $maxLineLength characters:\n ${violations.joinToString("\n ")}" ) } fileContent } ``` ### Impact Adding this rule will require fixing existing violations in the codebase. We should: 1. First run the check to identify all current violations 2. Fix existing violations (can be done incrementally using Spotless's `ratchetFrom` feature) 3. Enable the check for all new code ### Additional Context - Google Java Style Guide: https://google.github.io/styleguide/javaguide.html#s4.4-column-limit - Spotless custom steps documentation: https://github.com/diffplug/spotless/tree/main/plugin-gradle#custom-steps -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
