Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Add dockerfile-lint checker #1606

Merged
merged 1 commit into from
Nov 27, 2015
Merged

Add dockerfile-lint checker #1606

merged 1 commit into from
Nov 27, 2015

Conversation

pixelastic
Copy link
Contributor

This adds a syntaxchecker for Dockerfile. This uses dockerfile-lint and expect the dockerfile-lint binary to be available (usually through a npm -g install).

By default, it will simply check for basic syntax correctness of the Dockerfile. One can pass a custom yml rule file through the syntastic_dockerfile_dockerfile_lint_post_args, for example:

let b:syntastic_dockerfile_dockerfile_lint_post_args = '-r /path/to/rule/file.yml'

I've used preprocess for the json parsing part.

This adds the first syntaxchecker for `Dockerfile`. This uses
[dockerfile-lint](https://github.com/projectatomic/dockerfile_lint)
and expect the `dockerfile-lint` binary to be available (usually
through the `npm` install).

By default, it will simply check for basic syntax correctness of the
`Dockerfile`. One can pass a custom `yml` rule file through the `syntastic_dockerfile_dockerfile_lint_post_args`, for example:

```vim
let b:syntastic_dockerfile_dockerfile_lint_post_args = '-r /path/to/rule/file.yml'
```

I've used `preprocess` to convert the json output.
@lcd047 lcd047 merged commit 13456d5 into vim-syntastic:master Nov 27, 2015
@lcd047
Copy link
Collaborator

lcd047 commented Nov 27, 2015

Thank you. Merged, with this patch on top: 73dd785.

@pixelastic pixelastic deleted the dockerfile-lint branch November 28, 2015 00:19
@pixelastic
Copy link
Contributor Author

Thanks!

Could you tell me more about the Style/%n/e['nr'] dance?

@lcd047
Copy link
Collaborator

lcd047 commented Nov 30, 2015

There isn't much to tell. Normal languages have named regexps for parsing error messages, Vim has errorformat. Besides being an obfuscated pain in the rear, errorformat is quite limited, there is very little information you can pass from an error message to the corresponding item in the resulting quickfix list. Normally all you get is a filename, line and column numbers, an error type, and an error description. If you need, say, a second column number, you're out of luck. To get the job done, your options are to either (1) include the extra information in the error description, then parse it out from there after the quickfix has been built, or (2) abuse some unused %-format to pass the information. Syntastic uses both techniques, and my patch above is an example of the latter one.

Normally %n in errorformat is used to parse error numbers. It gives you something like 143 col 37 warning 302 in the quickfix window, and you can look up "warning 302" to find out more details about the warning. In the quickfix list itself %n gives you a field named nr. If the checker doesn't provide meaningful error numbers however, you can abuse %n to parse some other number (typically a second column number). But if you use %n it like this you also need to delete nr from the quickfix items (after saving it elsewhere, of course), so that Vim doesn't show it to you as an error number.

In the patch above I use nr to signal that the corresponding items are information messages, and are to be marked as style warnings. Setting e['subtype'] to Style does the marking, and that's all there is to it. It's an unbelievably gross hack, but it gets the job done. shrug

@pixelastic
Copy link
Contributor Author

Haha, thanks for the details. I learn new vim quirks at every PR :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants