scalastyle / scalastyle-sbt-plugin

scalastyle-sbt-plugin
Apache License 2.0
139 stars 52 forks source link

How do I exclude files/folders? #35

Closed mthurlin closed 7 years ago

mthurlin commented 9 years ago

I would like to exclude some folders/files from being checked, how do I do that?

The command-line version of scalastyle takes the source directory to use, but I can't figure out how to do that with scalastyle-sbt.

matthewfarwell commented 9 years ago

By default the sbt plugin uses the normal scalaSource setting. There isn't a way to exclude a particular set of directories at the minute.

jeffsteinmetz commented 8 years ago

+1

Does this commit improve this?

https://github.com/scalastyle/scalastyle-sbt-plugin/commit/313833043d734b974869c6d3f7f13d6a56a0b050

samarthgupta437 commented 8 years ago

+1 would like to see this feature.
[edit] look like its implemented in oct 2015 https://github.com/scalastyle/scalastyle/blob/e19b54eacb6502b47b1f84d7b2a6b5d33f3993bc/src/main/scala/org/scalastyle/Main.scala#L51 , but i am not able to figure out how to use in maven plugin.

matthewfarwell commented 7 years ago

This should be fixed. You can now supply a list of files to scalastyleSources. This should be available to test in 0.9.0-SNAPSHOT. Closing issue.

anancds commented 5 years ago

if use play framework,you can try this:

lazy val root = (project in file(".")).enablePlugins(PlayScala).
  settings(
    (scalastyleSources in Compile) := {
      val scalaSourceFiles = ((scalaSource in Compile).value ** "*.scala").get
      scalaSourceFiles.filterNot(_.getAbsolutePath.contains("example.scala")).filterNot(_.getAbsolutePath.contains("somefolder"))
    }
  )
arthurarty commented 9 months ago

if use play framework,you can try this:

lazy val root = (project in file(".")).enablePlugins(PlayScala).
  settings(
    (scalastyleSources in Compile) := {
      val scalaSourceFiles = ((scalaSource in Compile).value ** "*.scala").get
      scalaSourceFiles.filterNot(_.getAbsolutePath.contains("example.scala")).filterNot(_.getAbsolutePath.contains("somefolder"))
    }
  )

When using the above you code in your build.sbt might run into the error.

warning: method in in trait ScopingSetting is deprecated (since 1.5.0): `in` is deprecated; migrate to slash

Updated way to do it is.

  (Compile / scalastyleSources) := {
    val scalaSourceFiles = ((Compile / scalaSource).value ** "*.scala").get
    scalaSourceFiles.filterNot(_.getAbsolutePath.contains("example.scala")).filterNot(_.getAbsolutePath.contains("somefolder"))
  },

Reference

Note:

This worked with the sbt plugin.