From a8cce32580ecf3c6b6076f54f423e85e2b171398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 6 Apr 2018 18:33:57 +0200 Subject: [PATCH 1/2] Repace Scalastyle with scalafmt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds make lint-scala command, used by travis Signed-off-by: Carlos Martín --- .scalafmt.conf | 8 ++++ .travis.yml | 2 +- Makefile | 5 +++ README.md | 7 ++++ build.sbt | 12 ------ project/plugins.sbt | 2 +- scalastyle-config.xml | 98 ------------------------------------------- 7 files changed, 22 insertions(+), 112 deletions(-) create mode 100644 .scalafmt.conf delete mode 100644 scalastyle-config.xml diff --git a/.scalafmt.conf b/.scalafmt.conf new file mode 100644 index 00000000..bc4b624a --- /dev/null +++ b/.scalafmt.conf @@ -0,0 +1,8 @@ +style = IntelliJ +maxColumn = 100 + +project.excludeFilters = [ + ".*com/google/.*" + ".*tech/sourced/featurext/generated/.*" + ".*gopkg/in/.*" +] diff --git a/.travis.yml b/.travis.yml index b11e3ac0..11de4b89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -69,7 +69,7 @@ matrix: - scala: 2.11.2 env: STYLE_CHECK=true - script: ./sbt scalastyle + script: make lint-scala - scala: 2.11.2 env: FE_PYTHON_TEST=true diff --git a/Makefile b/Makefile index 3b7b74bb..cde101c6 100644 --- a/Makefile +++ b/Makefile @@ -27,3 +27,8 @@ format-python: lint-python: $(YAPF_CMD) --diff + +lint-scala: + $(SBT) scalafmt::test + $(SBT) test:scalafmt::test + $(SBT) sbt:scalafmt::test diff --git a/README.md b/README.md index 87685e31..b55d800a 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,13 @@ To generate protobuf messages fixtures you may use [bblfsh-sdk-tools](https://gi bblfsh-sdk-tools fixtures -p .proto -l ``` +This project uses [scalafmt](http://scalameta.org/scalafmt) formatting. + +To check if the code follows the project style, use the linters +``` +make lint-scala +``` + ## License Copyright (C) 2017 source{d}. diff --git a/build.sbt b/build.sbt index 8ee0c075..8dc6ccbf 100644 --- a/build.sbt +++ b/build.sbt @@ -102,15 +102,3 @@ publishTo := { Some("releases" at nexus + "service/local/staging/deploy/maven2") } } - -scalastyleSources in Compile := { - // all .scala files in "src/main/scala" - val scalaSourceFiles = ((scalaSource in Compile).value ** "*.scala").get - val fSep = java.io.File.separator - val dirsNameToExclude = List( - "com" + fSep + "google", - "tech" + fSep + "sourced" + fSep + "featurext" + fSep + "generated", - "gopkg" + fSep + "in" - ) - scalaSourceFiles.filterNot(f => dirsNameToExclude.exists(dir => f.getAbsolutePath.contains(dir))) -} diff --git a/project/plugins.sbt b/project/plugins.sbt index 98efea74..b02b3573 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,7 +1,7 @@ addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5") addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.2") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1") -addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0") addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.2") addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0") addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1") +addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.15") diff --git a/scalastyle-config.xml b/scalastyle-config.xml deleted file mode 100644 index 15c6ce16..00000000 --- a/scalastyle-config.xml +++ /dev/null @@ -1,98 +0,0 @@ - - Scalastyle standard configuration - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From bd3954583687da59acb32a864442ac794413ee51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 6 Apr 2018 18:39:38 +0200 Subject: [PATCH 2/2] Add make format-scala command, using scalafmt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Martín --- Makefile | 5 +++++ README.md | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cde101c6..17b3f213 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,11 @@ format-python: lint-python: $(YAPF_CMD) --diff +format-scala: + $(SBT) scalafmt + $(SBT) test:scalafmt + $(SBT) sbt:scalafmt + lint-scala: $(SBT) scalafmt::test $(SBT) test:scalafmt::test diff --git a/README.md b/README.md index b55d800a..fa18b155 100644 --- a/README.md +++ b/README.md @@ -117,13 +117,18 @@ To generate protobuf messages fixtures you may use [bblfsh-sdk-tools](https://gi bblfsh-sdk-tools fixtures -p .proto -l ``` -This project uses [scalafmt](http://scalameta.org/scalafmt) formatting. +This project uses [scalafmt](http://scalameta.org/scalafmt) formatting. You can configure IntelliJ IDEA to use the same formatting configuration. To do so, follow the [scalafmt instructions](http://scalameta.org/scalafmt/#IntelliJ). To check if the code follows the project style, use the linters ``` make lint-scala ``` +To fix formatting issues, use the formatters +``` +make format-scala +``` + ## License Copyright (C) 2017 source{d}.