nastra commented on code in PR #12641: URL: https://github.com/apache/iceberg/pull/12641#discussion_r2012585502
########## site/docs/contribute.md: ########## @@ -422,6 +422,50 @@ Use `this` when assigning values to instance variables, making it clear when the 2. Use `.` to create a hierarchy of config groups * For example, `s3` in `s3.access-key-id`, `s3.secret-access-key` +#### Block Spacing + +To improve readability and maintain consistency, always place a newline after control blocks (if, for, while, switch, etc.). +This helps separate logical sections of the code, making it easier to read and debug. + +```java + // BAD: No newline separator after `if` block + public static WriteBuilder write(OutputFile file) { + if (file instanceof EncryptedOutputFile) { + return write((EncryptedOutputFile) file); + } + return new WriteBuilder(file); + } + + // GOOD: newline separator after `if` block + public static WriteBuilder write(OutputFile file) { + if (file instanceof EncryptedOutputFile) { + return write((EncryptedOutputFile) file); + } + + return new WriteBuilder(file); + } + + // BAD: No newline separator after `for` block + public static Schema convert(final org.apache.iceberg.Schema schema) { Review Comment: since we really only care about the newline, I would just change this example so that we don't deal with different Schema objects here, which could add confusion when reading it. ``` // BAD: ... public static Schema convert(Schema schema) { ImmutableList.Builder<Field> fields = ImmutableList.builder(); for (NestedField f : schema.columns()) { fields.add(convert(f)); } return new Schema(fields.build()); } ``` ``` // GOOD: ... public static Schema convert(Schema schema) { ImmutableList.Builder<Field> fields = ImmutableList.builder(); for (NestedField f : schema.columns()) { fields.add(convert(f)); } return new Schema(fields.build()); } ``` -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org