Commit Graph

443 Commits

Author SHA1 Message Date
Dimitri Papadopoulos
19d00809d1 quoted-strings: Merge comparisons with in
To check if a variable is equal to one of many values, combine the
values into a tuple and check if the variable is contained in it
instead of checking for equality against each of the values. This
is faster, less verbose, and more readable.
2022-10-07 17:01:51 +02:00
Adrien Vergé
008db4aa09 float-values: Fix bug on strings containing fordidden values
The rule correctly reports number values like `.1`, `1e2`, `.NaN` and
`.Inf`, but it also reported false positives on strings like `.1two3`,
`1e2a`, `.NaNa` and `.Infinit∞`.

The regexps need to end with an end delimiter (`$`) otherwise longer
strings can be matched too.

Fixes https://github.com/adrienverge/yamllint/issues/495
2022-10-04 08:59:51 +02:00
Dimitri Papadopoulos Orfanos
e8391de711
Drop support for Python 3.6
Python 3.6 reached end-of-life on 2021-12-23.
https://peps.python.org/pep-0494/
2022-09-13 07:59:17 +02:00
Dimitri Papadopoulos
a5adec1570 ci: Update GitHub Actions
https://github.com/actions/checkout
https://github.com/actions/setup-python
2022-09-13 07:58:03 +02:00
Adrien Vergé
9cce294041 yamllint version 1.28.0 2022-09-12 14:37:48 +02:00
andrewnaguib
2f8ad7003a config: Implement for ignore-from-file option
Closes https://github.com/adrienverge/yamllint/issues/360
Co-authored-by: Adrien Vergé <@adrienverge>
2022-08-10 08:35:40 +02:00
Roman Geraskin
fb0c0a5247 quoted-strings: fix docs example 2022-08-07 20:13:48 +02:00
Roman Geraskin
352e1a975e
quoted-strings: Add allow-quoted-quotes option
Allows strings like `'foo"bar'` on `quote-type: double` and vice versa.
2022-08-07 13:47:35 +02:00
Dimitri Papadopoulos
e319a17344 octal values: simpler test for match objects
From the Python 3 documentation:
	Match objects always have a boolean value of True.
	Since match() and search() return None when there is no match,
	you can test whether there was a match with a simple if statement:
		match = re.search(pattern, string)
		if match:
		    process(match)
2022-08-06 15:23:23 +02:00
Dimitri Papadopoulos
6b6fdba3bf linter: pre-compile disable/enable rules regexes
Not only this should improve performance, but I find the code more
readable.
2022-08-06 15:23:23 +02:00
Dimitri Papadopoulos Orfanos
868350681a
License: Update to latest version of GPLv3
http:// → https://
2022-08-06 15:14:57 +02:00
Andrew Imeson
94c1c2bcf2 docs: Update ALE vim plugin link 2022-08-05 18:57:21 +02:00
Andrew Imeson
0130e15c8c docs: Simplify GitHub Actions example 2022-08-05 18:57:21 +02:00
Dimitri Papadopoulos
ae3158cd1f No need to inherit from object in Python 3 2022-08-05 08:49:56 +02:00
Dimitri Papadopoulos
4c7b47daf3 Most __future__ imports are specific to Python 2 2022-08-05 08:49:56 +02:00
Dimitri Papadopoulos Orfanos
3346843edc
docs: Better compress PNG image 2022-08-05 08:43:55 +02:00
Dimitri Papadopoulos Orfanos
ea70520216
Changelog: Fix typo found by codespell 2022-08-05 08:42:10 +02:00
Adrien Vergé
a09ad89268 yamllint version 1.27.1 2022-07-08 18:06:54 +02:00
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
2022-07-08 18:05:21 +02:00
Adrien Vergé
8a364e2fde yamllint version 1.27.0 2022-07-08 17:32:19 +02:00
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.
2022-07-08 17:21:22 +02:00
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"
2022-07-08 17:21:22 +02:00
Derek Brown
8ac7d58693 float-values: Add a new rule to check floating-point numbers 2022-07-08 17:21:22 +02:00
Andrew Imeson
40cab7f999 docs: Bump application copyright year 2022-06-24 17:15:21 +02:00
Andrew Imeson
34a4f76e8b docs: Remove repeated word 'copyright'
Fixes #476 - credit to @chrillep and @adrienverge
2022-06-24 17:15:21 +02:00
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.
2022-06-23 08:19:30 +02:00
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
2022-06-23 08:19:30 +02:00
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
2022-06-23 08:19:30 +02:00
Christian Widlund
695fc5f1f1 docs: Add plugin section for Visual Studio Code 2022-06-22 18:12:56 +02:00
Christian Widlund
632665c3e6 docs: Add plugin section for IntelliJ 2022-06-20 14:47:43 +02:00
Derek Brown
5658cf7f42 octal-values: Pre-compile regex for performance 2022-06-11 12:03:44 +02:00
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.
2022-06-10 11:19:59 +02:00
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.
2022-06-10 08:39:50 +02:00
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.
2022-06-09 10:03:08 +02:00
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.
2022-06-09 09:40:06 +02:00
Andrew Imeson
e49a101160 Add rstcheck to CI to lint docs 2022-06-08 09:21:44 +02:00
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} }
2022-04-20 11:00:08 +02:00
Andrew Imeson
2f423117c1
docs: Attempt to clarify configuration file location
Closes #96, Closes #212
2022-03-24 10:23:39 +01:00
Andrew Imeson
f58448cb21 Fix spelling of "across" in test output 2022-03-21 13:48:34 +01:00
Andrew Imeson
7974d518cd Fix grammar in key_ordering docs to make Lintian happy
Fixes part of #76
2022-03-21 13:48:34 +01:00
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
2022-03-21 13:48:34 +01:00
Andrew Imeson
c34c962691 Remove the repeated word "automatically" in GHA doc 2022-03-21 13:48:34 +01:00
Madison Swain-Bowden
4f1bbc33dc
docs: Fix link syntax on integration.rst 2021-12-24 09:34:15 +01:00
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
2021-12-19 22:02:56 +01:00
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.
2021-12-01 08:52:59 +01:00
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.
2021-11-24 14:38:26 +01:00
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
2021-11-17 16:43:46 +01:00
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
2021-11-17 16:43:46 +01:00
Adrien Vergé
f2e2e0c366 docs: Update CONTRIBUTING.rst
Be more precise in contributing instructions.
2021-10-20 09:40:59 +02:00
Adrien Vergé
058fef7559 yamllint version 1.26.3 2021-08-21 19:26:15 +02:00