From 54ea921b2553345fb2d978c2384927f50fd464df Mon Sep 17 00:00:00 2001 From: Patrick Honkonen <1883101+SaintPatrck@users.noreply.github.com> Date: Thu, 11 Dec 2025 11:18:23 -0500 Subject: [PATCH] Update STYLE_AND_BEST_PRACTICES.md to clarify KDoc requirements and fix whitespace (#6256) --- docs/STYLE_AND_BEST_PRACTICES.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/STYLE_AND_BEST_PRACTICES.md b/docs/STYLE_AND_BEST_PRACTICES.md index da7b5cfd9b..963a7edfda 100644 --- a/docs/STYLE_AND_BEST_PRACTICES.md +++ b/docs/STYLE_AND_BEST_PRACTICES.md @@ -270,7 +270,7 @@ Whenever questions about code formatting arise in which multiple options are val #### Documentation -All public classes, functions, and properties should include documentation in the [KDoc style](https://kotlinlang.org/docs/kotlin-doc.html). Private classes, functions, and properties may optionally be documented as needed. +All public classes, functions, and properties should include documentation in the [KDoc style](https://kotlinlang.org/docs/kotlin-doc.html). Private classes, companion objects, functions, and properties may optionally be documented as needed. ##### Class Documentation @@ -602,7 +602,7 @@ The following contains general tips and best practices that apply for Kotlin cod } } ``` - + ```kotlin // Good: This class requires a Data object for someMethod to function properly, so we inject // an instance of DataProvider. @@ -615,7 +615,7 @@ The following contains general tips and best practices that apply for Kotlin cod } } ``` - + - Functions should not intentionally throw exceptions! Any function that needs to represent the possibility of both a success and an error should either: - Return the [Result](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/) type. - Return a custom sealed class to model the possibilities. @@ -645,7 +645,7 @@ The following contains general tips and best practices that apply for Kotlin cod - Never catch a `RuntimeException` that _can't happen_: ```kotlin - // Bad: A NumberFormatException is not possible here based on what we know about the value + // Bad: A NumberFormatException is not possible here based on what we know about the value // we're using, so we're adding code that isn't necessary. val definitelyANumber = "1234" val value = try { @@ -671,7 +671,7 @@ The following contains general tips and best practices that apply for Kotlin cod e.printStackTrace() } ``` - + ```kotlin // Good try { @@ -693,7 +693,7 @@ The following contains general tips and best practices that apply for Kotlin cod return } ``` - + ```kotlin // Good val locationId = methodReturningNullableString()