Konsist
GitHubSlack (kotlinlang)Twitter
  • 🚀GETTING STARTED
    • What is Konsist?
    • Getting Started
      • Add Konsist Dependency
      • Create First Konsist Test - Declaration Check
      • Create Secound Konsist Test - Architectural Check
    • Articles & Videos
  • ✅WRITING TESTS
    • Create The Scope
    • Declaration Filtering
    • Declaration Assertion
    • Architecture Assertion
    • Suppress Konsist Test
  • ✏️VERYFYING CODEBASE
    • Verify Classes
    • Verify Interfaces
    • Verify Functions
    • Verify Properties
    • Verify Generics
    • Verify Source Declarations
  • 📗FEATURES
    • Add Konsist Existing To Project (Baseline)
    • Debug Konsist Test
    • Declaration
    • Declaration Vs Property
    • Compiler Type Inference
    • Package Wildcard
    • Declaration References
    • Indirect Parents
    • Kotest Support
  • 🔍INSPIRATION
    • Starter Projects
    • Snippets
      • General Snippets
      • Android Snippets
      • Spring Snippets
      • Test Snippets
      • JUnit Snippets
      • Kotest Snippets
      • Architecture Snippets
      • Clean Architecture Snippets
      • Kotlin Serialization Snippets
      • Library Snippets
      • Generic Types Snippets
  • 🎓ADVANCED
    • Isolate Konsist Tests
    • Enable Full Command Line Logging
    • Dynamic Konsist Tests
      • Explicit Test Names
    • When Konsist API Is Not Enough
    • Additional JUnit5 Setup
    • Why There Are No Pre-defined Rules?
    • Konsist Snapshots
  • ❓HELP
    • Getting Help
    • Known Issues
      • java.lang.OutOfMemoryError: Java heap space
    • Compatibility
  • ℹ️OTHER
    • Changelog
    • Project Status
    • Contributing
    • Contributors
    • Assets And Logos
    • Open Source Licenses
    • Sponsor Konsist
Powered by GitBook
On this page
  • 1. Every Api Declaration Has KDoc
  • 2. Every Function With Parameters Has A Param Tags
  • 3. Every Function With Return Value Has A Return Tag
  • 4. Every Extension Has A Receiver Tag
  • 5. Every Public Function In Api Package Must Have Explicit Return Type
  • 6. Every Public Property In Api Package Must Have Specify Type Explicitly
Edit on GitHub
Export as PDF
  1. INSPIRATION
  2. Snippets

Library Snippets

Snippets to library authors.

1. Every Api Declaration Has KDoc

@Test
fun `every api declaration has KDoc`() {
    Konsist
        .scopeFromPackage("..api..")
        .declarationsOf<KoKDocProvider>()
        .assertTrue { it.hasKDoc }
}

2. Every Function With Parameters Has A Param Tags

@Test
fun `every function with parameters has a param tags`() {
    Konsist.scopeFromPackage("..api..")
        .functions()
        .assertTrue { it.hasValidKDocParamTags() }
}

3. Every Function With Return Value Has A Return Tag

@Test
fun `every function with return value has a return tag`() {
    Konsist.scopeFromPackage("..api..")
        .functions()
        .assertTrue { it.hasValidKDocReturnTag() }
}

4. Every Extension Has A Receiver Tag

@Test
fun `every extension has a receiver tag`() {
    Konsist.scopeFromPackage("..api..")
        .declarationsOf<KoReceiverTypeProvider>()
        .assertTrue { it.hasValidKDocReceiverTag() }
}

5. Every Public Function In Api Package Must Have Explicit Return Type

@Test
fun `every public function in api package must have explicit return type`() {
    Konsist
        .scopeFromPackage("..api..")
        .functions()
        .assertTrue { it.hasReturnType() }
}

6. Every Public Property In Api Package Must Have Specify Type Explicitly

@Test
fun `every public property in api package must have specify type explicitly`() {
    Konsist
        .scopeFromPackage("..api..")
        .properties()
        .assertTrue { it.hasType() }
}
PreviousKotlin Serialization SnippetsNextGeneric Types Snippets

Last updated 1 year ago

🔍