Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scalafmt lint #86

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

scalafmt lint #86

wants to merge 2 commits into from

Conversation

carlosms
Copy link
Contributor

@carlosms carlosms commented Apr 6, 2018

Partially replaces #74, see #74 (comment).

Adds a new make lint-scala command that uses scalafmt. Travis uses this new command to replace Scalastyle.

Adds make lint-scala command, used by travis

Signed-off-by: Carlos Martín <carlos.martin.sanchez@gmail.com>
@carlosms carlosms requested a review from bzz April 6, 2018 16:43
This was referenced Apr 6, 2018
@bzz
Copy link
Contributor

bzz commented Apr 9, 2018

Thank you @carlosms for breaking the changes down to smaller PRs!

As expected, CI now fails on lint.

[error] /home/travis/build/src-d/gemini/src/main/scala/tech/sourced/gemini/ReportApp.scala has changes after scalafmt
[error] /home/travis/build/src-d/gemini/src/main/scala/tech/sourced/gemini/QueryApp.scala has changes after scalafmt
[error] /home/travis/build/src-d/gemini/src/main/scala/tech/sourced/gemini/ConnectedComponents.scala has changes after scalafmt
[error] /home/travis/build/src-d/gemini/src/main/scala/tech/sourced/gemini/HashSparkApp.scala has changes after scalafmt
[error] /home/travis/build/src-d/gemini/src/main/scala/tech/sourced/gemini/Gemini.scala has changes after scalafmt
com.lucidchart.sbt.scalafmt.ScalafmtCheckFailure: 5 Scala sources not formatted in gemini:compile

👍 for consistent autoformatting, but as for linting - I never used scalfmt for it before and am not sure yet if it would be a good idea to replace a scalastyle, which produces the meaningful violation descriptions, with something that can only report 5 Scala sources not formatted in gemini:compile.

Let me investigate a bit more and get back to you soon.

@carlosms
Copy link
Contributor Author

@bzz if we add to build.sbt the following:
scalafmtShowDiff in (ThisBuild, scalafmt) := true

It will show the diffs, like this:

[error] /home/cmartin/code/src-d/gemini/src/main/scala/tech/sourced/gemini/QueryApp.scala has changes after scalafmt:
[error] 60c60
[error] <       val cluster = Cluster.builder()
[error] ___
[error] >       val cluster = Cluster
[error] >         .builder()
[error] 69c70
[error] <       val channel = ManagedChannelBuilder.forAddress(config.feHost, config.fePort).usePlaintext(true).build()
[error] ___
[error] >       val channel =
[error] >         ManagedChannelBuilder.forAddress(config.feHost, config.fePort).usePlaintext(true).build()
[error] /home/cmartin/code/src-d/gemini/src/main/scala/tech/sourced/gemini/Gemini.scala has changes after scalafmt:
[error] 17c17
[error] < import tech.sourced.featurext.generated.service.{Feature, IdentifiersRequest, LiteralsRequest, Uast2seqRequest}
[error] ___
[error] > import tech.sourced.featurext.generated.service.{
[error] >   Feature,
[error] >   IdentifiersRequest,
[error] >   LiteralsRequest,
[error] >   Uast2seqRequest
[error] > }

Let me know if that's a good enough solution and I'll push the change.

@bzz
Copy link
Contributor

bzz commented Apr 10, 2018

Ok, there is a relevant discussion about applying http://docs.scala-lang.org/style/ with scalafmt and seems like people manage to adjust it quite well - please, give me some more time to experiment with it.

Meanwhile +1 for adding a flag to linter that reports violations better.

Signed-off-by: Carlos Martín <carlos.martin.sanchez@gmail.com>
@carlosms
Copy link
Contributor Author

Change pushed. You can see the new output here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants