Git Product home page Git Product logo

fix-whitespace's Introduction

fix-whitespace: Fixes whitespace issues

Hackage version fix-whitespace on Stackage Nightly Stackage LTS version Build status Haskell-CI

This tool can keep your project and repository clean of trailing whitespace and missing terminal newline.

Usage: fix-whitespace [-h|--help] [-v|--verbose] [-V|--version] [--check] [--config CONFIG] [FILES]

The program does the following to files specified in FILES or in the configuration file fix-whitespace.yaml under the current directory (and its subdirectories):

  • Remove trailing whitespace.
  • Remove trailing lines containing nothing but whitespace.
  • Ensure that the file ends in a newline character.
  • Expand tabs to spaces (optionally).

Available options:

  • -h --help

    Show this help information.

  • -v --verbose

    Show files as they are being checked. Since 0.1: Display location of detected whitespace violations.

  • -V --version

    Show program's version.

  • --config=CONFIG

    Override the project configuration fix-whitespace.yaml.

  • --tab=TABSIZE

    Expand tab characters to TABSIZE (default: 8) many spaces. Keep tabs if 0 is given as TABSIZE. (Option available since 0.0.9.)

  • --check

    With --check the program does not change any files, it just checks if any files would have been changed. In the latter case, it returns with a non-zero exit code.

For an example configuration file see the one of Agda.

Continuous integration

fix-whitespace comfortably integrates into your GitHub CI via the fix-whitespace-action.

fix-whitespace's People

Contributors

aitorres avatar andreasabel avatar asr avatar dependabot[bot] avatar ednutting avatar l-tchen avatar rwe avatar ulysses4ever avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fix-whitespace's Issues

unknown package: filepattern

Even after running cabal update, I keep getting an error telling me that
filepattern is an unknown package.

[__1] unknown package: filepattern (dependency of fix-whitespace)

Add testsuite

Add a golden value testsuite.
Since there is now printing of error locations, we should test for correct outputs:

Release a github action that does `fix-whitespace --check`

Turn existing instances of fix-whitespace CI workflows into a github action.

Consider making binary releases for the github action platforms to speed up the action (no need to install GHC, Cabal, build fix-whitespace...).

Make tab expansion optional (new option `--tab`).

Some files have tabs as part of the syntax, like Makefile.
I propose to put the tab-expansion under a flag --tab, which could have a number argument TABSIZE that defaults to 8.

This is a breaking change, so, new major version: 0.1.

stack warning: Failed to decode module interface

I'm getting the following warning:

$ stack install --stack-yaml=stack-8.10.1.yaml --system-ghc
...
Warning: Failed to decode module interface:
         /home/asr/src/fix-whitespace/.stack-work/dist/x86_64-linux/Cabal-3.2.0.0/build/fix-whitespace/fix-whitespace-tmp/ParseConfig.hi Decoding
         failure: Invalid magic: e49ceb0f

You can see also the warning in Travis.

It seems the warning is related to commercialhaskell/stack#5134.

Symlink treated as directory

With these additional files in test/interaction,

/test/interaction$ tree issue-4828-NEve/
issue-4828-NEve/
├── src
│   └── Issue4828.agda
└── sym
    └── Issue4828.agda -> issue-4828-NEve/src/Issue4828.agda

I get this error:

$ fix-whitespace --check
fix-whitespace: .../test/interaction/issue-4828-NEve/sym/Issue4828.agda/: getDirectoryContents:openDirStream: does not exist (No such file or directory)

Seems like a symlink is treated as a directory somehow.

UPDATE: Blocked upstream:

Performance problem with error message feature

After PR #44, performance has degraded for large files with lots of violations.

Reproducer:

runhaskell test/GenerateViolations.hs 200000
FW=$(cabal list-bin fix-whitespace)
time $FW --check 200000-violations.txt 2> /dev/null

Takes 30sec on my machine. The released (0.0.11) finishes in a fraction of a second.

Proposed procedure:

  1. Try to fix the performance problem
  2. Guard error reporting under --verbose flag.

Use `fix-whitespace.yaml` as filter when file arguments are given

Use case:

git ls-tree -r master --name-only | xargs fix-whitespace --config fix-whitespace.yaml 

or simply

git ls-tree -r master --name-only | xargs fix-whitespace

This should filter the FILES given to fix-whitespace through the configuration given in fix-whitespace.yaml.

A new flag, like --config - could be used if really all of the given FILES should be processed.

Enhancement: more verbose error reporting

It would be nice if fix-whitespace would tell (a) what kind of error it discover, and more importantly, (b) where in the file it is. That would be particularly helpful for large non-trivial files.

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.