mrtazz / checkmake

experimental linter/analyzer for Makefiles
MIT License
1.04k stars 45 forks source link

Feature request: add option to ignore rules on a line basis #31

Open fdegier opened 4 years ago

fdegier commented 4 years ago

Most linters have an option to ignore rules in line as in some cases the rules are too strict. E.g. in the Makefile from this repo there is a rule, which IMHO is fine for reading purposes, but it does not follow the rules.

Adding the comment would seem logical to prevent checkmake to complain about rule violation:

# checkmake ignore: maxbodylength
coverage:
    @echo "mode: set" > cover.out
    @for package in $(PACKAGES); do \
        if ls $${package}/*.go &> /dev/null; then  \
        go test -coverprofile=$${package}/profile.out $${package}; fi; \
        if test -f $${package}/profile.out; then \
        cat $${package}/profile.out | grep -v "mode: set" >> cover.out; fi; \
    done
    @-go tool cover -html=cover.out -o cover.html

To prevent this output, which contains a bug as described in #29 :

$ docker run -v $(pwd)/Makefile:/Makefile checker

      RULE                 DESCRIPTION             LINE NUMBER  

  maxbodylength   Target body for "coverage"       70           
ssokolow commented 4 years ago

Whether it's on a line-by-line basis or just documenting how to use checkmake.ini to disable rules, this would allow me to use checkmake on justfiles which are syntactically close enough to Makefiles that the main problem is the minphony and phonydeclared checks.

  1. Just doesn't have PHONY construct because, being developed for adding build automation to a language which tracks rebuilds already (Rust), all tasks are have PHONY behaviour and there's no other option.
  2. I get spurious minphony failures because test +args="": and clean +args="": don't match test: and clean:. (And a legitimate but unwanted complaint about a missing all because, if just is already breaking from make to fix warts, I might as well fix something I don't like... that name.)