Back to all reviewers

Format for readability

tensorflow/swift
Based on 3 comments
Other

Code should be formatted to optimize readability. Apply these key practices: 1. **Maintain reasonable line length** (typically 100 columns) by breaking long lines of code. For function declarations with multiple parameters or long statements, wrap them across lines with proper indentation:

Code Style Other

Reviewer Prompt

Code should be formatted to optimize readability. Apply these key practices:

  1. Maintain reasonable line length (typically 100 columns) by breaking long lines of code. For function declarations with multiple parameters or long statements, wrap them across lines with proper indentation:
// Instead of:
func getMedianExecutionTime(iterationCount: UInt = 10, _ verbose:Bool = false, _ function: () -> ()) -> Double {

// Use:
func getMedianExecutionTime(
  iterationCount: UInt = 10, _ verbose:Bool = false, _ function: () -> ()
) -> Double {
  1. Leverage language syntax conventions for cleaner code. In Swift, when a closure is the last argument, you can omit the parentheses:
// Instead of:
array.sorted(by: { s1, s2 in return s1 > s2 })

// You can write:
array.sorted { s1, s2 in return s1 > s2 }
  1. Use appropriate formatting for multiline strings. In Swift, the indentation of multiline strings is aligned with the closing triple quotes, not the indentation in the source code:
let quotation = """
    This text will have leading whitespace aligned
    with the closing triple quotes.
    """

These formatting practices improve code readability, reduce cognitive load, and make the codebase more maintainable.

3
Comments Analyzed
Other
Primary Language
Code Style
Category

Source Discussions