mrtazz / checkmake

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

'update' contains 'date' and so creates 'contains a timestamp' issue #64

Open bcm-at-zama opened 2 years ago

bcm-at-zama commented 2 years ago

Expected behaviour

Makefile

.PHONY: update_my_stuff
update_my_stuffv:

.PHONY: all
all:

.PHONY: clean
clean:

.PHONY: test
test:

fails with

  timestampexpanded   Variable "PHONY" possibly        2            
                      contains a timestamp and                      
                      should be simply expanded.                    

Actual behaviour

It should work.

The problem is that 'update' contains the word 'date', as in #38 and as fixed in #39. Notably, if you replace update_my_stuff by upda_te_my_stuff It works

Output of checkmake --version

checkmake 0.1.0-39-g1383019 built at 2020-10-27T22:53:40Z by <> with go version go1.15.3 linux/amd64

Output of checkmake --debug <your makefile>

2022/01/19 11:28:22 Unable to match line '' to a Rule or Variable 2022/01/19 11:28:22 Unable to match line 'update_my_stuffv:' to a Rule or Variable 2022/01/19 11:28:22 Unable to match line '' to a Rule or Variable 2022/01/19 11:28:22 Unable to match line '' to a Rule or Variable 2022/01/19 11:28:22 Unable to match line '' to a Rule or Variable 2022/01/19 11:28:22 Unable to match line '' to a Rule or Variable 2022/01/19 11:28:22 Unable to parse config file "checkmake.ini", running with defaults 2022/01/19 11:28:22 Running rule 'maxbodylength'... 2022/01/19 11:28:22 iniFile not initialized 2022/01/19 11:28:22 Running rule 'minphony'... 2022/01/19 11:28:22 iniFile not initialized 2022/01/19 11:28:22 Running rule 'phonydeclared'... 2022/01/19 11:28:22 iniFile not initialized 2022/01/19 11:28:22 Running rule 'timestampexpanded'... 2022/01/19 11:28:22 iniFile not initialized 2022/01/19 11:28:22 iniFile not initialized

    RULE                   DESCRIPTION             LINE NUMBER  

timestampexpanded Variable "PHONY" possibly 2
contains a timestamp and
should be simply expanded.

Output of make --version

I am in Docker so not sure it makes sense

Sample Makefile to reproduce issue

.PHONY: update_my_stuff
update_my_stuffv:

.PHONY: all
all:

.PHONY: clean
clean:

.PHONY: test
test:
mrtazz commented 2 years ago

ah I can see this happening. Thanks for reporting. I think in addition to making the matching a bit better we should probably also never treat .PHONY as a variable name anyways.

trinitronx commented 2 years ago

I think in addition to making the matching a bit better we should probably also never treat .PHONY as a variable name anyways.

@mrtazz It's funny you mention that because I just happened to refactor it on my fork. I noticed it was treated as a SpecialVariable instead of what GNU Make calls "Special Built-in Target Names".

I was implementing a new rule for matching trailing whitespace after variables, and found that PHONY was being treated as a variable which was messing with how I was trying to match trailing comment patterns. So, I ended up refactoring the parser a bit. I noticed there are still some bugs with LineNumber being set off by 1 in some instances... Not sure why that is, and it's getting late so my brain's too tired to figure it out now.