Coder Social home page Coder Social logo

sbt-sammy's Introduction

sbt-sammy

NOTE This project is no longer under development.

Build Status

Download

A friendly policeman to help reduce your compiler warnings.

Tomorrow the sun will come up again, and I'm pretty sure that whatever happens we won't have found Freedom, and there won't be a whole lot of Justice, and I'm damn sure we won't have found Truth. But it's just possible that I might get a hard-boiled egg. -- Sam Vimes, Night Watch by Terry Pratchett

In a perfect world, all projects would start off life with @tpolecat's scala compiler options and we would never encounter compiler warnings. In reality, we have to delve into mature, imperfect codebases where the lofty heights of Xfatal-warnings are difficult to achieve. We have to take a pragmatic approach to cleaning these up.

sbt-sammy prevents you from making your codebase worse by enforcing a warning threshold. This threshold decreases whenever you make improvements, nudging you to take small steps to -Xfatal-warnings.

To use

This plugin requires sbt 1.0+.

Add this to your project/plugins.sbt or as a global plugin in ~/.sbt/1.0/plugins/plugins.sbt:

addSbtPlugin("com.github.zainab-ali" % "sbt-sammy" % version)

Where version is set to the latest version of sbt-sammy

Setup

With a floating threshold (recommended)

sbt-sammy can reduce its warning threshold to the maximum number of warnings in your codebase. This means that each time you make a positive change, you can reduce your warning threshold.

If you want to do this, simply run sbt policeWarnings. The warning threshold should decrease to the maximum number of warnings in your project.

With a fixed threshold

If you would like to enforce a fixed threshold that sbt-sammy won't reduce then add the following to your build.sbt:

sammyWarningThresholdFile := None
sammyWarningThreshold := yourFixedThreshold

With suggestions

sbt-sammy is geared towards incremental fixes, and can suggest files to be fixed. It does this by diffing the files with warnings with those in a changeset. You need to supply it with a sammyDiffCommand that generates a list of changed files.

For example, if you would like to look for changes between the current branch and the master:

sammyDiffCommand := Some("git diff --name-only master...HEAD")

Run

Run sbt policeWarnings. This task will fail if the number of warnings exceeds the threshold.

sbt-sammy's People

Contributors

zainab-ali avatar scala-steward avatar mrvisser avatar

Stargazers

Mihai Soloi avatar  avatar  avatar ebigram avatar Ionuț G. Stan avatar moritz bust avatar Brandon Blaylock avatar johannes karoff avatar Higyed Arnold avatar Alexandru Nedelcu avatar Fernando Racca avatar BenWhitehead avatar Alexey Alekhin avatar Alexandru Stana avatar >>= avatar Yilin Wei avatar Devon Stewart avatar Zhihao Zhang avatar Jesús Martínez avatar Peter Schmitz avatar Christopher Davenport avatar Seth Tisue avatar Alan Devlin avatar Haemin Yoo avatar David Gregory avatar  avatar Dan Di Spaltro avatar

Watchers

James Cloos avatar  avatar  avatar

sbt-sammy's Issues

Reducing warnings does not reduce assessed count

Following the error message:

[error] The number of warnings has increased from 5 to 7. Please reduce warnings in your project.

If I reduce the number of warnings by 2, I still get the message:

[error] The number of warnings has increased from 5 to 7. Please reduce warnings in your project.

This implies that the plugin is counting stale warnings.

Typo ;)

In README there should be
addSbtPlugin("com.github.zainab-ali" % "sbt-sammy" % version), instead of
addSbtPlugin("com.github.zainab-ali" % "sbt-sammmy" % version).

Reload from `sammy.sbt` on each run?

One thing that might be helpful for those running a live sbt console would be to continue to reload the updated sammy.sbt on each run.

I think I have caught wind of other projects that do live reload, but one doesn't come to mind right now.

Thoughts?

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.