dense-analysis / dense-analysis/ale
Hadolint Linting fails if executable does not support --no-color flag
- Dominant language
- Vim Script
- Stars
- 14k
- Forks
- 1.5k
- Avg merge
- 17h 49m
- Merged PRs (30d)
- 1
Description
## Information
**VIM version**
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jul 18 2021 11:42:29)
macOS version - x86_64
**Operating System**
macOS Monterey
Version 12.4
**hadolint version**
Haskell Dockerfile Linter 1.19.0-no-git
Note that this version does not container a flag `--no-color`
**ALE version**
commit 5ad4fdd583116ec253aaf43e2d457cd3e3aa5587
## What went wrong
When linting a file named `Dockerfile` containing errors, ALE does not flag these errors.
Reviewing `:ALEInfo`, the `hadolint` executable failed with exit code 1.
In the shell, hadolint succeeds when run manually:
» hadolint Dockerfile
Dockerfile:4 DL4006 Set the SHELL option -o pipefail before RUN with a pipe in it. If you are using /bin/sh in an alpine image or if your shell is symlinked to busybox then consider explicitly setting your SHELL to /bin/ash, or disable this check
But the command fails when using the command generated by ALE:
```
» zsh -c 'hadolint --no-color - < Dockerfile'
Invalid option `--no-color'
Usage: hadolint [-v|--version] [-c|--config FILENAME] [-f|--format ARG]
[DOCKERFILE...] [--ignore RULECODE]
[--trusted-registry REGISTRY (e.g. docker.io)]
Lint Dockerfile for errors and best practices
```
The [`l:opts` variable in hadolint.vim](https://github.com/dense-analysis/ale/blob/master/ale_linters/dockerfile/hadolint.vim#L105) is hardcoded to `'--no-color -'`. The linter's config in ALE does not support changing this value.
## Reproducing the bug
1. Write a Dockerfile with an error.
2. Save the file to initiate ALE's linting.
3. No errors are reported, so it appears the file is fine.
4. Commit and push the file to trigger build pipeline
5. Pipeline fails during linting stage
### :ALEInfo
```
Current Filetype: dockerfile
Available Linters: ['dockerfile_lint', 'hadolint']
Enabled Linters: ['hadolint']
Ignored Linters: []
Suggested Fixers:
'remove_trailing_lines' - Remove all blank lines at the end of a file.
'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
Linter Variables:
let g:ale_dockerfile_dockerfile_lint_executable = 'dockerfile_lint'
let g:ale_dockerfile_dockerfile_lint_options = ''
let g:ale_dockerfile_hadolint_docker_image = 'hadolint/hadolint'
let g:ale_dockerfile_hadolint_use_docker = 'never'
Global Variables:
let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = ''
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_disable_lsp = 0
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '[%linter%] %severity% [%code%] %s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 1
let g:ale_fixers = {'go': ['gofmt', 'goimports'], 'terraform': ['terraform'], 'json': ['jq'], 'python': ['isort']}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 0
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'never'
let g:ale_linter_aliases = {}
let g:ale_linters = {'vim': ['vint'], 'php': ['php', 'phpcs'], 'go': ['gofmt', 'go build', 'golint', 'go vet', 'gopls'], 'terraform': ['terraform_lsp'], 'dockerfile': ['hadolint'], 'bash': ['shellcheck'], 'javascript': ['eslint'], 'python': ['pylint', 'pyls', 'mypy']}
let g:ale_linters_explicit = 0
let g:ale_linters_ignore = {}
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '[%linter%] %severity% [%code%] %s'
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_root = {}
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
let g:ale_sign_error = '>>'
let g:ale_sign_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
let g:ale_sign_highlight_linenrs = 0
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
Command History:
(executable check - success) hadolint
(finished - exit code 1) ['zsh', '-c', 'hadolint --no-color - < ''/var/folders/7v/dk7rkgbn0x30cyr_5y5tjxy80000gp/T/vwRgaem/0/Dockerfile''']
<<>>
```
Contributor guide
Assessment
This issue has not been assessed yet.