Scalastyle¶
Scalastyle examines your Scala code and indicates potential problems with it. It is used as part of the grading framework for the course Functional Programming Principles in Scala by Martin Odersky on Coursera.
http://www.scalastyle.org/
Enabling Scalastyle¶
Scalastyle provides several ways of usint it. We recommend the way of SBT plugin. To set up Scalastyle as a SBT plugin, follow the setup instructions . And you need a configuration file in your repository, then you can configure Scalastyle by adding the following lines to your configuration:
build:
nodes:
analysis:
tests:
override:
- scalastyle-run
scalastyle-run
is a built-in wrapper for Scalastyle which takes care of results and output format.
If your project is in a sub-directory of your repository, add command line as follows:
build:
nodes:
analysis:
tests:
override:
- '(cd path/to/project && scalastyle-run)'
Scalastyle Configuration¶
You can just use the default Scalastyle configuration scalastyle-config.xml . Alternatively you can also customize your own configuration file by following the format:
<scalastyle commentFilter="enabled">
<name>Scalastyle standard configuration</name>
<check level="warning" class="org.scalastyle.file.FileTabChecker" enabled="true" />
<check level="warning" class="org.scalastyle.file.FileLengthChecker" enabled="true">
<parameters>
<parameter name="maxFileLength">800</parameter>
</parameters>
</check>
</scalastyle>
Important:
to run scalastyle, a configuration file is required.