Skip to content

feature: global ignore pragma#871

Merged
lorenzo merged 1 commit intohadolint:masterfrom
m-ildefons:global-ignore
Nov 7, 2022
Merged

feature: global ignore pragma#871
lorenzo merged 1 commit intohadolint:masterfrom
m-ildefons:global-ignore

Conversation

@m-ildefons
Copy link
Copy Markdown
Member

Add global variant of the ignore pragma. This allows users to disable rules for the whole dockerfile by using a pragma like:

# hadolint global ignore=DL3003,SC2035

What I did

  • add file-global variant of the ignore pragma
  • clean up the pragma parsing code

How I did it

The file global ignore pragma works almost like the inline ignore pragma. The difference is that it parses into just a set of rules to ignore instead of a map from line-numbers to sets of rules to ignore. Consequently there is no check for line numbers when deciding if a check-failure should be ignored or propagated, all that matters is if that failures code is in that global set of rule codes to ignore.

How to verify it

The following Dockerfile should not trigger any of the globally ignored rules, but will still trigger all other rules just normal:

# hadolint global ignore=DL3002
FROM alpine
USER root

Add global variant of the ignore pragma. This allows users to disable
rules for the whole dockerfile by using a pragma like:

```dockerfile
```
@lorenzo
Copy link
Copy Markdown
Member

lorenzo commented Nov 7, 2022

Thanks!

@lorenzo lorenzo merged commit e1d9fc3 into hadolint:master Nov 7, 2022
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.

2 participants