Commit Graph

426 Commits (v1.27.1)
 

Author SHA1 Message Date
Adrien Vergé a09ad89268 yamllint version 1.27.1 3 years ago
Adrien Vergé 8d543a4b9c key-duplicates: Fix failing test for missing space after colon
Commit c268a82 "key-duplicates: Don't crash on redundant closing
brackets or braces" fixed a problem but introduced another one: it
crashes on systems with (I guess) an old version of PyYAML. This is
probably linked to the "Allow colon in a plain scalar in a flow context"
issue on PyYAML [1].
For example, this problem happens on CentOS 8:

    FAIL: test_disabled (tests.rules.test_key_duplicates.KeyDuplicatesTestCase)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "…/tests/rules/test_key_duplicates.py", line 90, in test_disabled
        '{a:1, b:2}}\n', conf, problem=(2, 11, 'syntax'))
      File "…/tests/common.py", line 54, in check
        self.assertEqual(real_problems, expected_problems)
    AssertionError: Lists differ: …
    - [2:3: syntax error: found unexpected ':' (syntax)]
    + [2:11: <no description>]

I propose to simply fix the *space following a colon* problem, since
it's not related to what the original author @tamere-allo-peter tried to
fix.

[1]: https://github.com/yaml/pyyaml/pull/45
3 years ago
Adrien Vergé 8a364e2fde yamllint version 1.27.0 3 years ago
Adrien Vergé dc2d0991e0 float-values: Refactor tests to be less verbose
The goal is to be more concise thus more readable, as well as consistent
with most other tests.
3 years ago
Adrien Vergé e6af957131 float-values: Add missing quotes in problems messages
To be consistent with other existing messages, e.g.:
- forbidden not a number value ".NaN"
- found forbidden document start "---"
- missing document start "---"
- truthy value should be one of ["true"]
- forbidden implicit octal value "0777"
3 years ago
Derek Brown 8ac7d58693 float-values: Add a new rule to check floating-point numbers 3 years ago
Andrew Imeson 40cab7f999 docs: Bump application copyright year 3 years ago
Andrew Imeson 34a4f76e8b docs: Remove repeated word 'copyright'
Fixes #476 - credit to @chrillep and @adrienverge
3 years ago
Jan Wille 7d9c824b83 new-lines: add `type: platform` config option
The new option infers the correct newline character(s) from the
operating system running yamllint.
3 years ago
Jan Wille 157b06871d new-lines: refactor to reduce duplicate code
Both options where using identical code.  Now the newline character
is determined beforehand depending on the selected option and then
the same code can be used for all options
3 years ago
Jan Wille af843b675a new-lines: explicitly check \n for type: unix
To be more consistent with the other types, unix now also checks against
the expected newline character (`\n`) instead of checking if a wrong
character (`\r`) is present
3 years ago
Christian Widlund 695fc5f1f1 docs: Add plugin section for Visual Studio Code 3 years ago
Christian Widlund 632665c3e6 docs: Add plugin section for IntelliJ 3 years ago
Derek Brown 5658cf7f42 octal-values: Pre-compile regex for performance 3 years ago
Matt Clay bdbec7dc4d linter: Remove redundant conditional
Remove the redundant conditional used when reporting a syntax error
at the same location as a cosmetic problem. Also reword the comment
explaining the logic to more accurately describe the situation.

This eliminates an unreachable `syntax_error = None` assignment.
3 years ago
Matt Clay 9700525496 linter: Remove unreachable exception handler
Remove two `try/except UnicodeError` exception handlers which were
added in commit c8ba8f7e99 for
Python 2.x compatibility. Now that Python 2.x is no longer
supported, the `except` is unreachable and is no longer needed.
3 years ago
Matt Clay 327f92e472 tests: Increase test coverage
- Add a `temp_workspace` context manager to simplify writing new tests.
- Add `# pragma: no cover` to unit test code paths used for skipping tests.
  These code paths are only covered when tests are skipped.
  That makes it impractical to reach full code coverage on the unit test code.
  Having full coverage of unit tests is helpful for identifying unused tests.
- Test the `octal-values` rule with a custom tag.
- Test the cli `-d` option with the `default` config.
- Test support for the `XDG_CONFIG_HOME` env var.
- Test warning message output.
- Test support for `.yamllint.yml` config files.
- Test support for `.yamllint.yaml` config files.
- Test error handling of a rule with a non-enable|disable|dict value.
- Test error handling of `ignore` with a non-pattern value.
- Test error handling of a rule `ignore` with a non-pattern value.
- Test error handling of `locale` with a non-string value.
- Test error handling of `yaml-files` with a non-list value.
- Test extending config containing `ignore`.
- Test `LintProblem.__repr__` without a rule.
- Test `LintProblem.__repr__` with a rule.
3 years ago
Adrien Vergé 89b75b7c05 refactor: Remove UTF-8 headers in Python files
The `# -*- coding: utf-8 -*-` headers were useful for Python 2, and
aren't needed for Python 3 where UTF-8 is the default.

yamllint support of Python 2 was dropped in early 2021, see commit
a3fc64d "End support for Python 2".

Let's drop these headers.
3 years ago
Andrew Imeson e49a101160 Add rstcheck to CI to lint docs 3 years ago
Jérôme Alet c268a82c5a
key-duplicates: Don't crash on redundant closing brackets or braces
Don't break on empty `context` stack when invalid YAML:

    [ a, b, c ] ]
    {a: 1, b: 2} }
3 years ago
Andrew Imeson 2f423117c1
docs: Attempt to clarify configuration file location
Closes #96, Closes #212
3 years ago
Andrew Imeson f58448cb21 Fix spelling of "across" in test output 3 years ago
Andrew Imeson 7974d518cd Fix grammar in key_ordering docs to make Lintian happy
Fixes part of #76
3 years ago
Andrew Imeson 8a320aaf2c Make man page show up in apropos
Set the 'description' attribute so that Sphinx builds the manpage with
the 'NAME' section. This is necessary for `apropos` to be able to find
yamllint

Fixes part of #76
3 years ago
Andrew Imeson c34c962691 Remove the repeated word "automatically" in GHA doc 3 years ago
Madison Swain-Bowden 4f1bbc33dc
docs: Fix link syntax on integration.rst 3 years ago
Jérôme Alet bb567ba395
comments: Allow whitespace after the shebang marker
Basically, any character is now allowed after the shebang marker.

Closes #428.

Whitespace after the #! marker on shebang lines is authorized and
optional, as explained on Wikipedia's entry for shebang line as can be
seen from the extracts below :

> White space after #! is optional

and

> It has been claimed[20] that some old versions of Unix expect the
> normal shebang to be followed by a space and a slash (#! /), but this
> appears to be untrue;[21] rather, blanks after the shebang have
> traditionally been allowed, and sometimes documented with a space
3 years ago
Trevor Royer d0392b34ca
github format: Update output to utilize groups
Resolves #421

Update the github formatting to utilize groups in the output and provide
the line/column number for the error in the output log.
3 years ago
Trevor Royer 7246a0c800
cli: Separate --format=auto logic
Moved the auto arg_format selection out of the main if block into a
separate logic section to improve readability.

No logic changes.
3 years ago
Dmytro Bondar 9e6dfacceb Fix github actions workflow
- install correct python version
- set `fail-fast: false` to run all jobs
- remove hard-coded value for HOME directory
3 years ago
Dmytro Bondar 11e8d8ff37 Add support for Python 3.10, drop Python 3.5
- Add support for Python 3.10 released on 2021-10-04
- Drop support for Python 3.5 since it has reached end-of-life
3 years ago
Adrien Vergé f2e2e0c366 docs: Update CONTRIBUTING.rst
Be more precise in contributing instructions.
3 years ago
Adrien Vergé 058fef7559 yamllint version 1.26.3 3 years ago
Adrien Vergé f47d5318cf Restore setuptools requirement for Python < 3.8
This reverts commit 8f68248 "Remove runtime dep 'setuptools' for Python
< 3.8". It looks like removing setuptools induces problems on some
systems, see for example the linked discussion.

Fixes https://github.com/adrienverge/yamllint/issues/380.
3 years ago
Adrien Vergé 33ce0fa960 yamllint version 1.26.2 3 years ago
Kyle Finley 43744902e9
setup: update python_requires to comply with PEP 345/440
According to PEP 345 Requires-Python
(https://www.python.org/dev/peps/pep-0345/#requires-python), the value
of this field must be a valid Version Specifier
(https://www.python.org/dev/peps/pep-0345/#version-specifiers). Which
in turn expects this to comply with PEP 440
(https://www.python.org/dev/peps/pep-0440/).

While not an issue for those that directly use `pip`, this will cause
issues for `poetry` users in the next release (if their current stance
is maintained). Discussion of the issue and there stance can be found
here: https://github.com/python-poetry/poetry/issues/4095.
4 years ago
Adrien Vergé 85ccd625a3 yamllint version 1.26.1 4 years ago
Patryk Małek e53ea093e2
line_length: skip all hash signs starting comment 4 years ago
Adrien Vergé 5d8ef2ea23 CI: Simplify 'pip' commands 4 years ago
Adrien Vergé 4515269233 CI: Fix failing 'coverage' command because of $PATH
Very probably due to:
https://github.com/actions/virtual-environments/issues/2455#issuecomment-787511010
4 years ago
Adrien Vergé 66bf76a362 CI: Switch to GitHub Actions
Because Travis CI is dead.
4 years ago
Daniel M. Capella 8f682481c7
Remove runtime dep 'setuptools' for Python < 3.8
> In recent versions of setuptools and Python, console-script entry
points are using stdlib importlib by default, thus setuptools is no
longer needed as a runtime dependency.

https://github.com/pypa/setuptools/pull/2197
https://github.com/pypa/setuptools/blob/main/CHANGES.rst#v4730
https://docs.python.org/3/library/importlib.metadata.html
4 years ago
Adrien Vergé 0fff4e29e4 yamllint version 1.26.0 4 years ago
Adrien Vergé 1b378ed5b9 quoted-strings: Fix explicit octal recognition
PyYAML implements YAML spec version 1.1, not 1.2. Hence, values starting
with `0o` are not considered as numbers: they are just strings, so they
need quotes when `quoted-strings: {required: true}`.

>>> import yaml
>>> yaml.resolver.Resolver().resolve(yaml.nodes.ScalarNode, '100', (True, False))
'tag:yaml.org,2002:int'
>>> yaml.resolver.Resolver().resolve(yaml.nodes.ScalarNode, '0100', (True, False))
'tag:yaml.org,2002:int'
>>> yaml.resolver.Resolver().resolve(yaml.nodes.ScalarNode, '0o100', (True, False))
'tag:yaml.org,2002:str'

Let's try to prevent that.

Fixes https://github.com/adrienverge/yamllint/issues/351.
4 years ago
Adrien Vergé a3fc64d134 End support for Python 2
As planned and advertized, yamllint drops support for Python 2 on 2021.
4 years ago
Rusty Geldmacher ee4d163ff8
Allow only non-empty brackets/braces
We'd like to disallow brackets and braces in our YAML, but there's a
catch: the only way to describe an empty array or hash in YAML is to
supply an empty one (`[]` or `{}`). Otherwise, the value will be null.

This commit adds a `non-empty` option to `forbid` for brackets and
braces. When it is set, all flow and sequence mappings will cause errors
_except_ for empty ones.
4 years ago
Jason Mobarak 22335b294d Add support for Python 3.9, drop Python 3.4
Add support for Python 3.9 since it was officially released in October
and drop support for Python 3.4 since it is end-of-life (EOL).
4 years ago
Rex Ledesma 0f9dffde23
docs: Add configuration for integration with Arcanist 4 years ago
Mathieu Couette cef0b48993 tests: Add unittest aliases to Python 2.7 4 years ago
Mathieu Couette 11b1f1c14e tests: Fix indentation issues 4 years ago