Skip to content

processing: apply onbuild rule wrapper per rule#799

Merged
lorenzo merged 1 commit intohadolint:masterfrom
m-ildefons:per-role-onbuild-check
Mar 20, 2022
Merged

processing: apply onbuild rule wrapper per rule#799
lorenzo merged 1 commit intohadolint:masterfrom
m-ildefons:per-role-onbuild-check

Conversation

@m-ildefons
Copy link
Copy Markdown
Member

  • Apply onbuild wrapper per-rule rather than on all rules combined
  • Apply onbuild wrapper only for rules needing it
  • Inline rules and their onbuild wrapped counterparts
  • Test for DL3047 also when inside an ONBUILD statement

The onbuild wrapper makes sure a rule is also applied to the AST
branch inside an ONBUILD instruction. But this is not necessary for
all rules, for example rules dealing exclusively with FROM
instructions need not be applied because that would be invalid syntax
anyways.
Moving the onbuild wrapper to apply to each rule individually instead
of the fold of all rules permits granular control over which rules are
applied inside of an ONBUILD instruction and crucially also enables
the ability to not apply rules on the AST branch inside of an ONBUILD
instruction, if so desired.
In addition to that the inlining for the rules has been adjusted such
that all rules and their onbuild wrapped counterparts are inlined into
the fold, before that the fold between the unwrapped and wrapped rules
were both not inlined themselves.

fixes: #798

- Apply `onbuild` wrapper per-rule rather than on all rules combined
- Apply `onbuild` wrapper only for rules needing it
- Inline rules _and_ their `onbuild` wrapped counterparts
- Test for DL3047 also when inside an `ONBUILD` statement

The `onbuild` wrapper makes sure a rule is also applied to the AST
branch inside an `ONBUILD` instruction. But this is not necessary for
all rules, for example rules dealing exclusively with `FROM`
instructions need not be applied because that would be invalid syntax
anyways.
Moving the `onbuild` wrapper to apply to each rule individually instead
of the fold of all rules permits granular control over which rules are
applied inside of an `ONBUILD` instruction and crucially also enables
the ability to not apply rules on the AST branch inside of an `ONBUILD`
instruction, if so desired.
In addition to that the inlining for the rules has been adjusted such
that all rules and their `onbuild` wrapped counterparts are inlined into
the fold, before that the fold between the unwrapped and wrapped rules
were both not inlined themselves.

fixes: hadolint#798
@lorenzo
Copy link
Copy Markdown
Member

lorenzo commented Mar 19, 2022

thanks, I really like this solution!

Would you mind solving or silencing the hlint warnings?

@lorenzo lorenzo merged commit 6c46323 into hadolint:master Mar 20, 2022
@lorenzo
Copy link
Copy Markdown
Member

lorenzo commented Mar 20, 2022

I'll take care of the warnings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3061: False positive for ONBUILD commands

2 participants