1

How to use scct and Scala Style in Scala-Sbt project

 3 years ago
source link: https://blog.knoldus.com/how-to-use-scct-and-scala-style-in-scala-sbt-project/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to use scct and Scala Style in Scala-Sbt project

Reading Time: < 1 minute

In this blog, I’ll explain the use of scct and scalastyle in your Scala-Sbt project.

scct is Scala code coverage tool. It tests the code coverage using test cases. It measures that how much code is covered by test cases and then it creates test coverage report (index.html) which resides at following position :

xxxxxxxxxx
project/target/scala-2.10/coverage-report/index.html

For good programming, code coverage should be greater that 90 %.

Add this line in build.sbt file :

xxxxxxxxxx
seq(ScctPlugin.instrumentSettings : _*)

Add this line in target/plugins.sbt file :

xxxxxxxxxx
addSbtPlugin("com.github.scct" %% "sbt-scct" % "0.2.1")

To run scct, follow this command :

xxxxxxxxxx
sbt scct:test

Scalastyle is used to examine your Scala code. When we run scalastyle then it gives warnings for the code which does not follow scala style guidelines.

Add this line in build.sbt file :

xxxxxxxxxx
org.scalastyle.sbt.ScalastylePlugin.Settings

Add this line in target/plugins.sbt file:

xxxxxxxxxx
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.3.2")

To run scala style, follow this command :

xxxxxxxxxx
sbt scalastyle

For good Scala code, warning should be zero. Sometimes we get the condition, where we have to break scala style guideline, but that is in very rare case. In general, waring should be zero.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK