Static Code Analyzer to enforce Type Annotation in Scala

182 Views Asked by At

Is there any static code analyzer that can be used to enforce Type Annotation in Scala. For example, when a developer writes a statement without type annotation as show in the example below, he should get a compile time error

val name="sometime" //This should throw compile time error

This is what I expect the developer to write,

val name: String = "somename" // Type annotation 'String' explicitly specified

I am able to enforce few good practices using Scalastyle plugin in sbt(which throws compile time error when any of the rules specified for ScalastylePlugin is not followed). But I could find any rule that enforce type annotation

PS : Scalastyle does provide provision to create CustomRules(by extending the class ScalariformChecker). But I am just looking for a way to avoid developing custom code

0

There are 0 best solutions below