scalaintellij-ideascalastyle

Is there a better way to setup ScalaStyle under IntelliJ?


There's some scalastyle support in the Scala plugin for IntelliJ. This question is about the best way to set it up to pick up a scalastyle configuration file which is customarily at the root of the directory under the name scalastyle-config.xml (example for the Spark project).

Currently, to get the scalastyle plugin in IntelliJ to pickup our scalastyle config, you need to put a copy of it into your .idea folder (supposedly .project would also work, but I haven’t tested this). Also, the file needs to be named scalastyle_config.xml (with an underscore instead of the hyphen). In short, you need to call the following in the root of your project:

cp scalastyle-config.xml .idea/scalastyle_config.xml

While I think this is an ugly hack, it at least allows me to see the scalastyle violations before building the whole project. Please let me know if you have a better solution for this.


Solution

  • I have found that this now works if you are using IntelliJ 15 and update the Scala plugin.

    The plugin was updated on October 12 to support the configuration file located in either the project root or .idea directory. The configuration file now can be named with an underscore or a hyphen.