Wednesday, 2 January 2019

How to add Scalastyle plugin in eclipse


Scalastyle is a style checker for Scala. It checks your Scala code against a number of configurable rules, and marks the code which violates these rules with warning or error markers in your source code.


Lets add scalastyle plugin in 4 steps.

  1. Install Scalastyle plugin
  2. Add Scalastyle Nature to your project
  3. Set up a configuration for Scalastyle
  4. Enable Scalastyle for that project


  1. Install Scalastyle plugin
    1. From Eclipse Marketplace install Scala Style 0.9.0



    1. Accept the terms and conditions. Scalastyle is installed in your eclipse.

  1. Add Scalastyle Nature to your project
               Right click project → ScalaStyle → Add Scalastyle nature

  1. Set up a configuration for Scalastyle
    1. Now we need to download the configuration rules from scalastyle.org 

    1. Place this file in your project, where the eclipse can access the file                                 eg: project/src/main/resource/scalastyle_config.xml

    1. Add configuration file to list of available configuration
                     In eclipse windows preference → select scalastyle 
                     configuration page → you can then add the file path of configuration file .


  1. Enable Scalastyle for that project
    1. Finally we need to select the configuration for our project
                      In project properties → select the configuration in 
               drop down list → enable check box




    1. Do a project clean and build, and you should see Scalastyle errors appear in your problems view or in the source code.