Closed MareoRaft closed 5 years ago
I just tried it out and it works. Maybe you put your configuration in the wrong place. Note that is has to be at the root of your repo and be called .gitlint.yaml
.
This issue still stands. I have verified that my .gitlint.yaml
file is running, namely by commenting out the yamllint key and subcontents entirely. Then git-lint skips linting yaml files entirely. Is there more information I can provide that will give you more insight into the issue?
Please provide the gitlint
version you are running, the path of your configuration file as well as the contents of it. (Feel free to redact some parts)
git-lint 0.1.2 yamllint 1.15.0
I used a yaml validator to verify that both of the following files are valid yaml.
Contents of /Users/Matthew/programming/AR/.gitlint.yaml
:
# This file originally began as a template written by Sebastion Kreft, and has been modified...
# Copyright 2013-2014 Sebastian Kreft
#...
# Javascript
eslint:
extensions:
- .js
command: sh
arguments:
- ./client/scripts/eslint.sh
- ./src
filter: "(?P<line>{lines}):(?P<column>\\d+)\\s+error\\s+(?P<message>.+)"
installation: "cd client && npm install --no-package-lock eslint"
# YAML
yaml:
extensions:
- .yaml
- .yml
command: yamllint
arguments:
- -c
- .yamllint.yaml
- -f
- parsable
# Matches either:
# - syntax error, on any lineee
# - other error, on a modified line only
filter: >-
^{filename}:(?P<line>{lines}|\d+(?=:\d+:
\[error\] syntax error:)):(?P<column>\d+):
\[(?P<severity>\S+)\] (?P<message>.+)$
installation: Run pip install yamllint.
Contents of /Users/Matthew/programming/AR/.yamllint.yaml
:
# Config file for yamllint.
# Github: https://github.com/adrienverge/yamllint
# default rules: https://yamllint.readthedocs.io/en/stable/configuration.html#default-configuration
extends: default
rules:
document-start: enable
line-length: disable
Thank you kindly for taking another look.
There are two different issues being reported here.
The one I tested out, is that you are indeed able to pass inline config data to yamllint with --config-data
.
The second one you are reporting is when specifying the configuration of a specific yamllint config file. I think the problem there is that you need to specify a full path to the config file as commands are not run relative to any directory.
To test out that theory, you could run git-lint both from /Users/Matthew/programming/AR/
and from a subdirectory.
You could also get the full output of yamllint, from the cache directory. In your case it will be something like /Users/Matthew/.git-lint/cache/yamllint/Users/Matthew/programming/AR/path/to/yaml.yaml
Ahhh, that clears everything up
Only certain errors are captured by git lint because the regex only catches "syntax error"s. By changing \[error\] syntax error:
to \[(?:error|warning)\] \w+(?: \w+)*:?
, for example, you can capture more errors and warnings.
Using absolute path for yaml config file worked. Without absolute path, it works for some files and fails for others. Of course this solution breaks when you try to lint the repo on another computer.
The original example of putting the yaml config data inline was fine.
So in the end the arguments were fine. It was the regex that wasn't. Working snippet:
yaml:
extensions:
- .yaml
- .yml
command: yamllint
arguments:
- -f
- parsable
- --config-data
- "{{extends: default, rules: {{document-start: disable, line-length: disable}}}}"
filter: >-
^{filename}:(?P<line>{lines}|\d+(?=:\d+:
\[(?:error|warning)\] .*:?)):(?P<column>\d+):
\[(?P<severity>\S+)\] (?P<message>.+)$
installation: Run pip install yamllint.
Do you want me to look into it further and open a PR for this? The original source code said the regex matched an other error, on a modified line only
, but the regex did not match that AFAIK.
When running
git lint
, I get output that includeseven though I have under "yaml" in my .gitlint.yaml:
To confirm that the arguments are in fact being ignored, I have successfully run
yamllint -c .yamllint.yaml -f parsable myfile.yaml
on my machine, producing an output that ignores line-length. Then by changing my gitlint config toand running
git lint
again, I yet again produce output that shows line-length errors.