Coder Social home page Coder Social logo

riff's Introduction

Riff

PyPI version Ruff Black MIT License

Ruff + diff = Riff

Run Ruffโšก, and filter out violations not caused by your branch. Riff uses git diff to detect code lines modified in the current branch, and filters Ruff's output accordingly. Riff only fails when violations are detected in modified lines.

Rationale

Ruff doesn't have a baseline feature, so Riff can come handy for enforcing Ruff rules in larger repositories quickly, without having to fix every single existing violation.

Usage

As a CLI tool

  • Make sure Ruff (>=0.0.291) is installed
  • Run riff, followed by (optional) Riff arguments, and (optional) Ruff arguments.
  • Running riff without arguments will run it in the current directory.
  • Riff expects to be run in a repository folder.

As a pre-commit hook

Copy this to your .pre-commit-config file

- repo: https://github.com/dorschw/riff
  hooks:
  - id: riff
    rev: v0.1.9.0
    additional_dependencies: ["ruff>=0.0.291"] # minimal is 0.0.291

To pass other arguments to Riff (and Ruff), add the args key, e.g.

    args: ["--base-branch=origin/master"]

Riff Arguments

  • always_fail_on: comma-separated list of Ruff error codes. When detected by Ruff, Riff will consider them as failures, even if they're not in lines modified in the current branch.
  • print_github_annotation: boolean (default false). When set to true, will add GitHub Annotations, making the violations more visible when reviewing code in GitHub's Modified Files tab.
  • base_branch: string (default origin/main). Change to origin/master or whatever your base branch is named.

Limitations

  • When using Ruff's --fix feature, Ruff will fix everything it is configured to, regardless of the modified lines. Riff cannot control this behavior.
  • Riff cannot currently run Ruff with a --output-format configuration. (see here)

riff's People

Contributors

dorschw avatar renovate[bot] avatar ricky-sb avatar shmuel44 avatar

Stargazers

Brian Bolton 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.