mrtazz / checkmake

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

Empty strings for blank makefile lines in debug logs #84

Open mcandre opened 1 year ago

mcandre commented 1 year ago

Expected behaviour

Blank makefile lines should be ignored before emitting warnings to logs.

Also, a specific line number would be helpful for identifying any actual problematic makefile lines.

Actual behaviour

$ checkmake --debug Makefile
2023/03/20 22:05:22 Unable to match line '' to a Rule or Variable
2023/03/20 22:05:22 Unable to match line '' to a Rule or Variable
2023/03/20 22:05:22 Unable to match line '' to a Rule or Variable
2023/03/20 22:05:22 Unable to match line '' to a Rule or Variable
2023/03/20 22:05:22 Unable to match line '' to a Rule or Variable
2023/03/20 22:05:22 Unable to match line '' to a Rule or Variable
2023/03/20 22:05:22 Unable to match line '' to a Rule or Variable
2023/03/20 22:05:22 Unable to match line '' to a Rule or Variable
2023/03/20 22:05:22 Unable to match line '' to a Rule or Variable
2023/03/20 22:05:22 Unable to match line '' to a Rule or Variable
2023/03/20 22:05:22 Running rule 'maxbodylength'...
2023/03/20 22:05:22 Running rule 'minphony'...
2023/03/20 22:05:22 Running rule 'phonydeclared'...
2023/03/20 22:05:22 Running rule 'timestampexpanded'...
    RULE              DESCRIPTION             LINE NUMBER  

  minphony   Missing required phony target    1            
             "test"

Output of checkmake --version

checkmake built at 2022-12-11T14:02:56Z by Homebrew homebrew@brew.sh with go version go1.19.4 darwin/arm64

Output of checkmake --debug <your makefile>

$ checkmake --debug Makefile
2023/03/20 22:05:22 Unable to match line '' to a Rule or Variable
2023/03/20 22:05:22 Unable to match line '' to a Rule or Variable
2023/03/20 22:05:22 Unable to match line '' to a Rule or Variable
2023/03/20 22:05:22 Unable to match line '' to a Rule or Variable
2023/03/20 22:05:22 Unable to match line '' to a Rule or Variable
2023/03/20 22:05:22 Unable to match line '' to a Rule or Variable
2023/03/20 22:05:22 Unable to match line '' to a Rule or Variable
2023/03/20 22:05:22 Unable to match line '' to a Rule or Variable
2023/03/20 22:05:22 Unable to match line '' to a Rule or Variable
2023/03/20 22:05:22 Unable to match line '' to a Rule or Variable
2023/03/20 22:05:22 Running rule 'maxbodylength'...
2023/03/20 22:05:22 Running rule 'minphony'...
2023/03/20 22:05:22 Running rule 'phonydeclared'...
2023/03/20 22:05:22 Running rule 'timestampexpanded'...
    RULE              DESCRIPTION             LINE NUMBER  

  minphony   Missing required phony target    1            
             "test"

Output of make --version

GNU Make 3.81 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0

Sample Makefile to reproduce issue

.PHONY: all lint clean

all: lint

safety:
    safety check

shfmt:
    stank . | grep -v node_modules | xargs shfmt -w -i 4

bashate:
    stank . | grep -v node_modules | xargs bashate

funk:
    @funk .

shellcheck:
    @stank -exInterp zsh . | grep -v node_modules | xargs shellcheck

yamllint:
    @yamllint -s .yamllint .

checkmake:
    checkmake Makefile

lint: safety shfmt funk shellcheck yamllint checkmake