Coder Social home page Coder Social logo

scala-clippy's Introduction

Scala clippy

Join the chat at https://gitter.im/softwaremill/scala-clippy Build Status Dependencies Maven Central

Did you ever see a Scala compiler error such as:

[error] TheNextFacebook.scala:16: type mismatch;
[error]  found   : akka.http.scaladsl.server.StandardRoute
[error]  required: akka.stream.scaladsl.Flow[akka.http.scaladsl.model.HttpRequest,akka.http.scaladsl.model.HttpResponse,Any]
[error]   Http().bindAndHandle(r, "localhost", 8080)

and had no idea what to do next? Well in this case, you need to provide an implicit instance of an ActorMaterializer, but the compiler isn't smart enough to be able to tell you that. Luckily, ScalaClippy is here to help!

Just add the compiler plugin, and you'll see this additional helpful message:

[error]  Clippy advises: did you forget to define an implicit akka.stream.ActorMaterializer?
[error]  It allows routes to be converted into a flow.
[error]  You can read more at http://doc.akka.io/docs/akka-stream-and-http-experimental/2.0/scala/http/routing-dsl/index.html

Adding the plugin

The easiest to use Clippy is via an SBT plugin. If you'd like Clippy to be enabled for all projects, without the need to modify their build, add the following to ~/.sbt/0.13/plugins/build.sbt:

addSbtPlugin("com.softwaremill.clippy" % "plugin-sbt" % "0.1")

Upon first use, the plugin will download the advice dataset from https://scala-clippy.org and store it in the $HOME/.clippy directory. The dataset will be updated at most once a day, in the background. You can customize the dataset URL and local store by using the -P:clippy:url= and -P:clippy:store= compiler options.

Contributing advice

Scala Clippy is only as good as its advice database. Help other users by submitting a fix for a compilation error that you have encountered!

It will only take you a couple of minutes, no registration required. Just head over to https://scala-clippy.org! Thanks!

Alternative ways to use Clippy

You can also use Clippy directly as a compiler plugin. If you use SBT, add the following setting to your project's .sbt file:

addCompilerPlugin("com.softwaremill.clippy" %% "plugin" % "0.1")

If you are using scalac directly, add the following option:

-Xplugin:clippy-plugin_2.11-0.1.jar

Contributing to the project

You can also help developing the plugin and/or the UI for submitting new advices! The module structure is:

  • model - code shared between the UI and the plugin. Contains basic model case classes, such as CompilationError + parser
  • plugin - the compiler plugin which actually displays the advices and matches errors agains the database of known errors
  • tests - tests for the compiler plugin. Must be a separate project, as it requires the plugin jar to be ready
  • ui - the ui server project in Play
  • ui-client - the Scala.JS client-side code
  • ui-shared - code shared between the UI server and UI client (but not needed for the plugin)

Heroku deployment

Locally:

  • Install the Heroku Toolbelt
  • link the local git repository with the Heroku application: heroku git:remote -a scala-clippy
  • run sbt deployHeroku to deploy the current code as a fat-jar

Currently deployed on https://www.scala-clippy.org

scala-clippy's People

Contributors

adamw avatar dragisak avatar gitter-badger avatar kciesielski avatar szimano avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.