There should be a single space for type modifiers for a function type and the parameters or receiver.
Non-Compliant Code Examples
// Function type
valprocess:suspend()->Unit={}// Function type with receiver
valprocess:suspendString.()->Unit={println(this)}// Function type with nullable receiver
valprocess:suspendString?.()->Unit={if(this!=null)println(this)}// Nullable function type
valprocess:(suspend()->Unit)?=null// Function type as parameter
suspendfunexecute(task:suspend()->Unit){task()}
Compliant Code Examples
// Function type
valprocess:suspend()->Unit={}// Function type with receiver
valprocess:suspendString.()->Unit={println(this)}// Function type with nullable receiver
valprocess:suspendString?.()->Unit={if(this!=null)println(this)}// Nullable function type
valprocess:(suspend()->Unit)?=null// Function type as parameter
suspendfunexecute(task:suspend()->Unit){task()}
Seamless integrations. Try Datadog Code Security
Datadog Code Security
Try this rule and analyze your code with Datadog Code Security
How to use this rule
1
2
rulesets:- kotlin-code-style # Rules to enforce Kotlin code style.
Create a static-analysis.datadog.yml with the content above at the root of your repository
Use our free IDE Plugins or add Code Security scans to your CI pipelines