Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (33 sloc) 2.63 KB

commons-analyzer

This module contains a simple static analyzer for Scala, implemented as a compiler plugin.

Here's how to configure it in build.sbt:

val avsCommonsVersion: String = ???
addCompilerPlugin("com.avsystem.commons" %% "commons-analyzer" % avsCommonsVersion)

Analyzer runs after typechecker inside the Scala compiler and applies its rules on every file. Every rule can be disabled or enabled to yield a compilation error, warning or info. It is recommended to use warnings with -Xfatal-warning option for the Scala compiler enabled and silencer plugin for warning suppression.

Here's a list of currently supported rules:

Name Default level Description
importJavaUtil warning Rejects direct imports of java.util package.
valueEnumExhaustiveMatch warning Enables (limited) exhaustive pattern match checking for ValueEnums.
any2stringadd off Disables any2stringadd (concatenating arbitrary values with strings using +).
bincompat warning Enables @bincompat checking
showAst error Handles @showAst.
findUsages warning Issues a message for every occurrence of any of the symbols listed in the argument of this rule
varargsAtLeast warning Enables @atLeast checking
macroPrivate warning Enables @macroPrivate checking
explicitGenerics warning Enables @explicitGenerics checking

Rules may be enabled and disabled in build.sbt with Scala compiler options:

scalacOptions += "-P:AVSystemAnalyzer:<level><ruleName>,<level><ruleName>,..."

<name> must be one of the rule names listed above or _ to apply to all rules.

<level> may be one of:

  • - to disable rule
  • * for "info" level
  • empty for "warning" level
  • + for "error" level
You can’t perform that action at this time.