@@ -28,12 +28,13 @@ class ClippyPlugin(val global: Global) extends Plugin {
2828
2929 override val description : String = " gives good advice"
3030
31- var url : String = " "
32- var colorsConfig : ColorsConfig = ColorsConfig .Disabled
33- var testMode = false
34- val DefaultStoreDir = new File (System .getProperty(" user.home" ), " .clippy" )
35- var localStoreDir = DefaultStoreDir
36- var projectRoot : Option [File ] = None
31+ var url : String = " "
32+ var colorsConfig : ColorsConfig = ColorsConfig .Disabled
33+ var testMode = false
34+ val DefaultStoreDir = new File (System .getProperty(" user.home" ), " .clippy" )
35+ var localStoreDir = DefaultStoreDir
36+ var projectRoot : Option [File ] = None
37+ var initialFatalWarnings : List [Warning ] = Nil
3738
3839 lazy val localAdviceFiles = {
3940 val classPathURLs = new PathResolver (global.settings).result.asURLs
@@ -72,7 +73,7 @@ class ClippyPlugin(val global: Global) extends Plugin {
7273 testMode = testModeFromOptions(options)
7374 localStoreDir = localStoreDirFromOptions(options)
7475 projectRoot = projectRootFromOptions(options)
75-
76+ initialFatalWarnings = initialFatalWarningsFromOptions(options)
7677 if (testMode) {
7778 val r = global.reporter
7879 global.reporter = new FailOnWarningsReporter (
@@ -177,6 +178,15 @@ class ClippyPlugin(val global: Global) extends Plugin {
177178 .map(new File (_, " .clippy.json" ))
178179 .filter(_.exists())
179180
181+ private def initialFatalWarningsFromOptions (options : List [String ]): List [Warning ] =
182+ options
183+ .find(_.startsWith(" fatalWarnings=" ))
184+ .map(_.substring(14 ))
185+ .map { str =>
186+ str.split('|' ).toList.map(str => Warning (RegexT (str), text = None ))
187+ }
188+ .getOrElse(Nil )
189+
180190 private def localStoreDirFromOptions (options : List [String ]): File =
181191 options.find(_.startsWith(" store=" )).map(_.substring(6 )).map(new File (_)).getOrElse(DefaultStoreDir )
182192
@@ -194,7 +204,7 @@ class ClippyPlugin(val global: Global) extends Plugin {
194204 new AdviceLoader (global, url, localStoreDir, projectAdviceFile, localAdviceFiles).load(),
195205 10 .seconds
196206 )
197- AdvicesAndWarnings (clippyData.advices, clippyData.fatalWarnings)
207+ AdvicesAndWarnings (clippyData.advices, clippyData.fatalWarnings ++ initialFatalWarnings )
198208 } catch {
199209 case e : TimeoutException =>
200210 global.warning(s " Unable to read advices from $url and store to $localStoreDir within 10 seconds. " )
0 commit comments