Commit Graph

483 Commits (master)
 

Author SHA1 Message Date
Adrien Vergé 2d8639c3a1 quoted-strings: Fix broken rule for list items
The rule worked for values like:

    flow-map: {a: foo, b: "bar"}
    block-map:
      a: foo
      b: "bar"

But not for:

    flow-seq: [foo, "bar"]
    block-seq:
      - foo
      - "bar"

Also add tests to make sure there will be no regression.

Fixes: #208.
5 years ago
Adrien Vergé e284d74be1 quoted-strings: Rename tests names for clarity
And move only-when-needed tests at the end for readability.
5 years ago
Adrien Vergé 1a13837e84 docs: Sunset Python 2
Keep supporting Python 2.7 for one extra year after upstream dropped it:
https://www.python.org/doc/sunset-python-2/
5 years ago
Adrien Vergé 46ed0c02be truthy: Add missing test removed from PR
See https://github.com/adrienverge/yamllint/pull/247#discussion_r405421376.
5 years ago
ilyam8 6ce11dedb4 truthy: add `check-keys` option 5 years ago
Adrien Vergé 542ae758f5 yamllint version 1.21.0 5 years ago
Rui Pinge 3a6a09b7b6 Add support for redundant quotes in quoted-strings rule
Co-Authored-By: Adrien Vergé
5 years ago
Rui Pinge 15aea73fbe
Fix quoted-strings rules not working for string values matching scalars 5 years ago
Martin Packman 91763f5476 Fix new-lines rule on Python 3
Use io.open() when reading files in cli which has the same behaviour
in Python 2 and Python 3, and supply the newline='' parameter which
handles but does not translate line endings.

Add dos.yml test file with windows newlines.

Also add to file finding test expected output.

Add test for new-lines rule through the cli.

Validates files are read with the correct universal newlines setting.

Fixes adrienverge/yamllint#228
5 years ago
Martin Packman 5b049e4229 Add RunContext helper for cli tests
Single context manager that includes exit code and output streams.

Use new RunContext throughout test_cli.

Largely non-functional change, saving some repetition of setup.

Also improve some failures by bundling multiple assertions into one.
5 years ago
Adrien Vergé 044c7f0248 cli: Test unicode chars in paths too 5 years ago
Adrien Vergé 734d5d5f73 CI: Run tests on Python 3.8
Python 3.8 was released in October 2019.
5 years ago
dhutty fd86455076 CI: Disable building on Python 3.4
As can be seen in https://travis-ci.org/adrienverge/yamllint/builds/631325436?utm_source=github_status&utm_medium=notification
The dependency, pathspec, requires Python '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*' but the running Python is 3.4.8

This commit stops Travis building yamllint against 3.4 so that CI can pass again.
5 years ago
Adrien Vergé 13a0f11e7c yamllint version 1.20.0 5 years ago
Sylvestre Ledru 43b95e99d1 Use 'syntax' as rule name upon syntax errors 5 years ago
ffapitalle 8fa9eb3ced Add --no-warnings option to suppress warning messages
Use `--no-warnings` option to hide warning messages. It only shows
problems marked as errors.
5 years ago
Adrien Vergé da3788e95a yamllint version 1.19.0 5 years ago
Joel Baranick fb400dc64b Allow disabling all checks for a file
Allow disabling of a file, even if it is invalid YAML (syntax error) by
including `# yamllint disable-file` in the first line.
5 years ago
Adrien Vergé 92324ae730 yamllint version 1.18.0 5 years ago
Imran Iqbal 7359785ea0 fix(default.yaml): disable `empty-values` & `octal-values` by default
* Close #204
5 years ago
Hossein Zolfi 579a975b70 docs: Fix pre-commit config file
* pre-commit show warning for unsupported key (sha)
* Demonstrate how to use custom yamllint
5 years ago
Imran Iqbal f3d9196aa0 docs(configuration): improve `yaml-files` code example
* A straight copy/paste of the existing example into the `.yamllint` file results in a `yamllint` error!
5 years ago
Ibrahim AshShohail 881d301883 feat: Support reading config from .yamllint.yml and .yamllint.yaml
Signed-off-by: Ibrahim AshShohail <me@ibrasho.com>
5 years ago
Adrien Vergé b62b424dd4 feat: Lint .yamllint by default 5 years ago
Adrien Vergé ce0336e430 yamllint version 1.17.0 6 years ago
grzesuav 063c854658 feat: Make YAML file extensions configurable 6 years ago
xatier 673bdbd324 fix(truthy): Fix extra whitespace 6 years ago
Remi Pointel cb5fe2c050 add OpenBSD installation instructions. 6 years ago
Adrien Vergé 930c8eea94 docs: Simplify installation instruction in the README 6 years ago
Adrien Vergé f6a24552d9 yamllint version 1.16.0 6 years ago
Adrien Vergé 0ba193331b truthy: Validate options passed to 'allowed-values'
Make sure values passed in allowed values are correct ones. This is
possible thanks to previous commit, and should prevent users from
writing incorrect configurations.
6 years ago
Adrien Vergé f65553c4f7 config: Validate config options with list of enums
Allow rules to declare a list of valid values for an option.

For example, a rule like:

    CONF = {'allowed-values': list}

... allowed any value to be passed in the list (including bad ones).

It is now possible to declare:

    CONF = {'allowed-values': ['value1', 'value2', 'value3']}

... so that the list passed to the options must contain only values in
`['value1', 'value2', 'value3']`.
6 years ago
Adrien Vergé 0fef4c14e7 truthy: Try to make docs on allowed-values more explicit
Edit documentation for the `truthy` rule, in order to:
- add quotes to examples (`'yes'` instead of `yes`) to avoid
  misconfigurations,
- group truthy values in the `allowed-values` option paragraph, for
  easier reading.
6 years ago
Ondrej Vaško 4ef7e05f3a truthy: Add allowed-values configuration option
Allows using key `allowed-values` for `truthy` section in configuration file (#150).

This allows to use configuration `truthy: allowed-values: ["yes", "no",
"..."]`, to set custom allowed truthy values.

This is especially useful for people using ansible, where values like
`yes` or `no` are valid and officially supported, but yamllint reports
them as illegal.

Implemented by difference of set of TRUTHY constants and configured
allowed values.

Signed-off-by: Ondrej Vasko <ondrej.vaskoo@gmail.com>
6 years ago
xatier 43c50379e0 Sort import orders 6 years ago
Adrien Vergé fec2c2fba7 fix(parser): Correctly handle DOS new lines in 'line' rules
Do not consider the trailing `\r` of a line a part of it.
6 years ago
Mateusz Piotrowski 2a66ec2e5e Add FreeBSD installation instructions 6 years ago
Adrien Vergé 37700ab3e6 yamllint version 1.15.0 6 years ago
Adrien Vergé f66661e36d docs(cli): Add a paragraph about standard input
See commit 05dfcbc "cli: Add command line option - to read from standard
input", cc @miguelbarao.
6 years ago
Adrien Vergé d6b89e94e4 chore(docs): Fix conf.py styling 6 years ago
Miguel Barao 05dfcbc109 cli: Add command line option - to read from standard input
If YAML files are given as arguments, parses these files.
If yamllint is run with - option, stdin.
If no arguments are given, just fail.
6 years ago
Adrien Vergé 16b939958d yamllint version 1.14.0 6 years ago
Adrien Vergé b4740dc1fb comments: Fix ignore-shebangs option on corner cases 6 years ago
Mattias Bengtsson b77f78f677 Support ignoring shebangs
Some usages of YAML (like Ansible) supports running the file as a script.

Support (by default) an ignore-shebangs setting for the comments module.

Fixes #116 - comments rule with require-starting-space: true should special case shebang
6 years ago
Adrien Vergé 0f073f7a09 config: Do not require all rule options to be set
Before, it was required to specify all the options when customizing a
rule. For instance, one could use `empty-lines: enable` or `empty-lines:
{max: 1, max-start: 2, max-end: 2}`, but not just `empty-lines: {max:
1}` (it would fail with *invalid config: missing option "max-start" for
rule "empty-lines"*).

This was a minor problem for users, but it prevented the addition of new
options to existing rules, see [1] for an example. If a new option was
added, updating yamllint for all users that customize the rule would
produce a crash (*invalid config: missing option ...*).

To avoid that, let's embed default values inside the rules themselves,
instead of keeping them in `conf/default.yaml`.

This refactor should not have any impact on existing projects. I've
manually checked that it did not change the output of tests, on
different projects:
- ansible/ansible: `test/runner/ansible-test sanity --python 3.7 --test yamllint`
- ansible/molecule: `yamllint -s test/ molecule/`
- Neo23x0/sigma: `make test-yaml`
- markstory/lint-review: `yamllint .`

[1]: https://github.com/adrienverge/yamllint/pull/151
6 years ago
cclauss bc7ac81707 Travis CI: Add Python 3.7 and 3.8a
* Adds Python 3.7.1 and a current nightly build of Python 3.8 alpha.
* Python 3.3 reached its end of life in 2017 https://devguide.python.org/#branchstatus
6 years ago
Adrien Vergé a56a1015f0 style(docs): Fix RST lint errors reported by doc8 6 years ago
Adrien Vergé 6cf5eecdac chore(CI): Lint RST (reStructuredText) files 6 years ago
Hugo f4c56b8216 Upgrade Python syntax with pyupgrade
https://github.com/asottile/pyupgrade
6 years ago
Hugo 5852566ff0 Upgrade unit tests to use more useful asserts 6 years ago