Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Analyze your changeset in a branch before git push using SonarLint + Git hooks; Round #2

Janos Gyerik
December 08, 2016

Analyze your changeset in a branch before git push using SonarLint + Git hooks; Round #2

Janos Gyerik

December 08, 2016
Tweet

More Decks by Janos Gyerik

Other Decks in Technology

Transcript

  1. ANALYZE YOUR CHANGESET
    BEFORE GIT PUSH
    WITH SONARLINT + GIT HOOKS
    ROUND #2
    https://speakerdeck.com/janosgyerik/sonarlint-before-git-push-2

    View full-size slide

  2. Motivation
    * Changeset = branch = many commits
    * Automatic (+bypass)

    View full-size slide

  3. git clone https://github.com/janosgyerik/sonarlint-git-hooks
    cd sonarlint-git-hooks
    ./get-and-setup-sonarlint.sh
    hooks=$PWD
    cd /path/to/your/project
    $hooks/install.sh
    Setup

    View full-size slide

  4. Difference from sonar-github
    * Runs locally
    * Fast feedback
    * No-brainer setup

    View full-size slide

  5. Difference from pre-commit checks
    in IntelliJ
    * Many commits vs one
    * Less frequent
    * IntelliJ not needed

    View full-size slide

  6. “custom” sonarlint?
    custom == future

    View full-size slide

  7. Tip #1 : bypass the analysis
    SKIPSONARLINT=1 git push -u origin HEAD

    View full-size slide

  8. Tip #2 : git alias to bypass the
    analysis
    somename = "!f() { SKIPSONARLINT=1 git
    push -u origin HEAD \"$@\"; }; f"

    View full-size slide

  9. Tip #3 : enable pre-commit hook
    mv .git/hooks/pre-commit.optional .git/hooks/pre-commit

    View full-size slide

  10. https://github.com/janosgyerik/sonarlint-git-hooks/issues
    Problems? Ideas? Feature requests?

    View full-size slide