Giter VIP home page Giter VIP logo

cytopia / docker-file-lint Goto Github PK

View Code? Open in Web Editor NEW
13.0 4.0 4.0 90 KB

Alpine-based Docker image to perform generic file checks on your source code in order to improve consistency within your repository (e.g. for easy usage in CI).

License: MIT License

Makefile 13.39% Shell 84.51% HTML 0.52% CSS 0.14% JavaScript 0.10% Perl 0.47% PHP 0.25% Python 0.30% Ruby 0.18% SCSS 0.14%
alpine multistage multistage-docker docker dockerfile docker-image docker-container ci continuous-integration lint linting awesome-ci line-feed linefeed whitespace white-space utf8

docker-file-lint's Issues

Asterisk (*) added at end of ignore pattern, bug?

When defining an ignore pattern, e.g. FILE_TRAILING_NEWLINE_IGNORE=".git,*.svg,*.excalidraw", the resulting path will get an * added at the end. Example:

`find . -type f -not \( -path "./.git*" -o -path "./*.svg*" -o -path "./*.excalidraw*" \) ! -size 0 -print0 | xargs -0 -P 8 -n1 grep -Il '' | tr '\n' '\0' | xargs -0 -P 8 -n1 sh -c 'if [ -f "${1}" ]; then aci-trailing-newline -n "$1" || echo "$1: No trailing newline at EOF."; fi' --`

This seems like a bug, this makes it impossible to only match files with certain extensions without also matching files having that extension in the middle of the file name, e.g. somefile.excalidraw.custom_ending will also be ignored.

It seems like this is the code responsible:

#
# 'find' pattern for ignores/excludes
#
if [ "${MY_IGN}" != "" ]; then
EXCL_PATTERN="-not \( -path \"${MY_PATH}/${MY_IGN//,/*\" -o -path \"${MY_PATH}\/}*\" \)"
else
EXCL_PATTERN=""
fi

would it be possible to not add an asterisk at the end?

Tools - Support GNU Parallel

Hi, pretty neat set of scripts this project has.

One thing I've noticed is that on relatively large directories with a large number of files, these scripts can occasionally take a good amount of time.

It would be nice if the scripts could leverage GNU Parallel to be able to process multiple files at once.

Taking a script like:

[OK]  All files are UTF-8 encoded.
$ find . -type f    -print0 | xargs -0 -P 2 -n1 grep -Il '' | tr '\n' '\0' | xargs -0 -P 2 -n1  sh -c 'if [ -f "${1}" ]; then awk "/^\xEF\xBB\xBF/ {print FILENAME} {nextfile}" "$1" || true; fi' --

To:

[OK]  All files are UTF-8 encoded.
$ find . -type f    -print0 | parallel 'xargs -0 -P 2 -n1 grep -Il \'\' | tr \'\n\' \'\0\' | xargs -0 -P 2 -n1  sh -c \'if [ -f "${1}" ]; then awk "/^\xEF\xBB\xBF/ {print FILENAME} {nextfile}" "$1" || true; fi\' --'

I don't fully know if this has been something that has been considered, but just a nice thought.

Description of repository should be refined

Currently the description of the repository says this:

Alpine-based Docker image for the very basics of CI against your code files for reproducible usage in CI

This is very abstract and redundant (contains the word CI multiple times). At least for me it is misleading and non-descriptive, so by only reading this description I have no idea what this repository is about.

Therefore I think it should be re-phrased.

My suggest (feel free to change it, though) is the following:

Alpine-based Docker image to perform generic file checks on your source code in order to improve consistency within your repository (e.g. for easy usage in CI).

file-nullbyte messes up terminal (when run against binary files?)

The file-nullbyte check seems to mess up terminals. I've checked it on multiple *nix machines (Linux, macOS) and the terminals are only showing "weird" characters and/or behave strangely, after the following command is run:

docker run --rm -v $(pwd):/data cytopia/file-lint file-nullbyte --path .

$(pwd) is the checked out repository, and contains some binary files inside the .git/ directory

The result looks something like this:

W7Om,ҧ)ӘG2
R2        iG:U!%{|=7h>r$rCzيZWbnڒ0[~`ٻ@|?B屙QlW`/UA=~F};aL_ٚ1xmIo@Mܬ
m99φiXn t?0LӚbΤy`QV(oWiƯk0vUpC6`yn]s_I+}R*g\7r3A@B{<lkuH5nY?$ebxjbBxiX9MyCgm5؈c$1qP&uQUF        xYÙx</JNI?6,D"(A(r)N<
                                                                            r$R%T-@&^(~%Yk175,c1omiwziìĿXC7;zgY6co<
                                                                                                                   fwSXSdme^Z(NЉ*lw]Tl3
                                                                                                                                       g<k..NL(K)hv9&5տlX9=-k
W3~?lwKzBwEP?Wipx|4q.YF1~K93e36ef28bb545f9c4650c7f13ce2f59b442180.pack:|* #*-2Ds*2E%к<  d_xږGՕYSOb9'YIz9sU_~^ @wYdrҴ:x/U5ӧHtYaYbNla|0m쇷k7XYpi1;
                          *h#!o<Ov6thOQ]&r5Sk$wɄ_N>VSh"ldRD@nt?|hk]fi7Li9(i؄TP
                                                                             k,ć|9g4}w0
                                                                                       nrua,
;r͎¨rvz֍Ki+d瑿AAeOV\cp?Z,<*f{woYvMSTytVnZ*                                                   F9W_̲D037웨5yi{:0~PgBӌĥ-]w˷z         ەG3L:#;@X*
                                         :i6bp?%XF?R    ѮCSa8[fOga1xmKs@ڣ"Hb}dOSWW35UNTE
./.git/objects/pack/pack-693e36ef28bb545f9c4650c7f13ce2f59b442180.pack:BrR1Ρ$AEgͤyLi(UXIDDAD!%5S          CAMV   !PCrOC<34EU'
qsɽM)epKũ                                                                                                                   U@ ⶮa`XŰ)xlZκjzΊ!,벾2Lo -OE[O.\z#6tXz`/Ѥbk8j^׳'k^؍fgOv
./.git/objects/pack/pack-693e36ef28bb545f9c4650c7f13ce2f59b442180.pack:c2ljxvPAMyFX
vIDu]E\S'v SAHSەB,%;3mSUU䡝<5s
                              f#G9duyu4}|JdS6-Ox_oT_6g
                                                      tcUN#M)oHڸUq
                                                                  %I~XDxSˮFQk#6e

                                                                                |}dUzUV]dƀ)b
./.git/objects/pack/pack-693e36ef28bb545f9c4650c7f13ce2f59b442180.pack:3
LkftbFPpHx54H}/pack/pack-693e36ef28bb545f9c4650c7f13ce2f59b442180.pack:-+z\gָ| y(Bdr\[k8'c9(yt;Umc

The terminal needs to be reset afterwards.

The example snippet for this check looks like this:

# file-crlf
FILE_NULLBYTE_EXTENSION=""
FILE_NULLBYTE_IGNORE=".git,*.svn,*.pyc"
FILE_NULLBYTE_TEXT=0
FILE_NULLBYTE_SIZE=1

This results in binary files being scanned.

Now I'm wondering:

  • Is it a good idea to run this check against binary files in the first place?
  • Why is it messing up the terminal? This should not happen, regardless of whether binary files are involved or not.

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.