Adrien Vergé
59d5bffbec
Tests: cli: Detect and handle the `-d ''` case
9 years ago
Adrien Vergé
53da21934d
Tests: Add many `cli.run` test cases
9 years ago
Adrien Vergé
88ebcbbb93
Tests: Test cli.find_files_recursively
9 years ago
Adrien Vergé
08615ec4f8
Tests: config: Check the non-valid-yaml-config case
9 years ago
Adrien Vergé
29aceb430a
Tests: indentation: Increase coverage
9 years ago
Adrien Vergé
76f47e91ca
Rules: indentation: Handle imbricated flows correctly
...
The following source -- although not loadable by pyyaml -- is valid
YAML:
{{key}}: value
This was processed badly by yamllint. The same for `[[value]]`,
`{{{{{moustaches}}}}}` or:
{[val,
{{key: val,
key2}}]}
This patch corrects it and add corresponding test cases.
Related-to: #3
9 years ago
Adrien Vergé
46e9108419
Rules: indentation: Add 'consistent' option for 'indent-sequences'
...
Using `indent-sequences: consistent` allows block sequences to be
indented or not to be, as long as it remains the same within the file.
9 years ago
Adrien Vergé
9a7eec34b1
Rules: indentation: Fix `spaces: consitent` with broken flows
9 years ago
Adrien Vergé
5b62548ece
Tests: indentation: Use 'spaces: consistent' by default
9 years ago
Adrien Vergé
8fca8a7a33
Config: Allow 'enable' keyword for rules
...
In the same manner as 'disable', 'enable' allows setting a rule on
without worrying about its options.
9 years ago
Adrien Vergé
5693b1dddf
Rules: indentation: Add 'consistent' option for 'spaces'
...
Using `spaces: consistent` allows any number of spaces, as long as it
remains the same within the file.
9 years ago
Adrien Vergé
fa420499c7
Config: Allow types in multiple choices
...
For instance, allow rules with:
CONF = {'choice': (int, 'hardcoded-string'),
'string-or-bool': (str, bool)}
9 years ago
Adrien Vergé
29c1c60143
Tests: Use absolute path to spec examples
9 years ago
Adrien Vergé
10ad302e2f
Tests: Explicit encoding for spec examples
...
YAML specification examples contain unusual characters, let's explicit
`encoding='utf-8'` to prevent bugs.
9 years ago
Adrien Vergé
73d9322813
linter: Test run on str, unicode, bytes and stream
...
Previously it was not tested, and broke on Python 2 `unicode` inputs.
9 years ago
Adrien Vergé
6c8af97a40
Tests: unblacklist remaining spec examples
...
Since !!tags are now supported.
9 years ago
Adrien Vergé
647d84ff94
Rules: indentation: Handle tags
9 years ago
Adrien Vergé
8eb0d0ad74
Tests: unblacklist spec example 7.16
...
As is it supported -- it just lacks some indentation.
9 years ago
Adrien Vergé
4bc3d5a01c
Rules: indentation: Handle anchors
9 years ago
Adrien Vergé
48c7d65c54
parser: Provide nextnext for token rules
...
Because the indentation rule sometimes needs to look two tokens forward
(in case of anchors for instance).
9 years ago
Adrien Vergé
62fa4cbe39
Tests: indentation: Test the indent stack
...
The "indentation stack" is iteratively built by the `check()` function
of the indentation rule. It is important, since everything in the rule
relies on it.
This patch adds tests to make sure the stack is correctly built for some
known structures.
9 years ago
Adrien Vergé
9a82b99d4b
Rules: indentation: Fix multi-line flows
...
To detect this as correct indentations:
top:
rules: [
{
foo: 1
},
{
foo: 2
bar: [
a, b, c
],
},
]
9 years ago
Adrien Vergé
ba140ad42c
Tests: Remove ghost character from YAML spec example
9 years ago
Adrien Vergé
f6bab05e8a
Rules: Add the 'key-duplicates' rule
9 years ago
Adrien Vergé
c16eec4681
Style: Fix indentation not multiple of four
9 years ago
Adrien Vergé
68618be4cc
Rules: indentation: Handle sets
...
Sets are like mappings, that do not contain values. Example:
set:
? key one
? key two
? [non, scalar, key]
9 years ago
Adrien Vergé
431a379c81
Tests: Add tests from YAML 1.2 specification
...
Write all examples from http://www.yaml.org/spec/1.2/spec.html in
independent files in tests/yaml-1.2-spec-examples; and test them with
yamllint.
9 years ago
Adrien Vergé
6b5948c06b
Tests: Reorganize common and global tests
9 years ago
Adrien Vergé
dd163ed551
Rules: indentation: Fix flow sequences with multi-line scalars
...
Typically sequences like this:
["multi
line 1", "multi
line 2"]
9 years ago
Adrien Vergé
14c99da2bb
Tests: Add test cases for empty flows
9 years ago
Adrien Vergé
cae100071a
Rules: indentation: Add support for cleared sequence entries
...
The following construction is valid YAML, and its indentation should be
correctly handled:
- this is
-
a
-
sequence:
with cleared entries
9 years ago
Adrien Vergé
7cb7b4f669
Rules: commas: Add 'min-spaces-after'
...
Since such constructions are allowed and valid YAML:
- [one,two, three,four]
this commit adds a `min-spaces-after` option that defaults to 1.
9 years ago
Adrien Vergé
4410bc3e23
Rules: indentation: Fix check-multi-line-strings
...
For strings that continue on next line at a lower indentation level:
Blaise Pascal: Je vous écris une longue lettre parce que
je n'ai pas le temps d'en écrire une courte.
9 years ago
Adrien Vergé
97c446907c
Rules: line-length: Add option `allow-non-breakable-words`
9 years ago
Adrien Vergé
5ed496f471
Distribution: Remove unneeded `setup_requires`
...
With the new project layout, `pyyaml` is not needed anymore for parsing
setup.py.
9 years ago
Adrien Vergé
7b147cb411
Tests: Remove Python 2.6 from CI tests
...
Because:
1. It is old. VERY old.
2. Some useful methods (`assertRaisesRegexp`, `assertIsInstance`) are
only available from Python 2.7.
9 years ago
Adrien Vergé
fc108e7cee
Config: Refactor to use YamlLintConfig objects
9 years ago
Adrien Vergé
1bfd18097a
Rules: indentation: Add 'check-multi-line-strings' option
...
This options allows the user to control whether to lint indentation
inside multi-line scalars or not.
When enabled, such YAML source will be detected as a problem:
- C code: void main() {
printf("foo");
}
whereas this one would not:
- C code: void main() {
printf("foo");
}
9 years ago
Adrien Vergé
67d13d60ae
Rules: indentation: Check multi-line scalars
9 years ago
Adrien Vergé
96465008ab
Rules: Fix `spaces_before` when prev is multi-line scalar
...
YAML content like the following one produced an error, because the
multi-line ScalarToken ends at the beginning of the 4th line (the one
with the value):
? >
multi-line
key
: value
9 years ago
Adrien Vergé
847f7e3fff
Rules: comments: Fix bug when multi-line scalar
...
YAML content like the following one produced an error, because the
ScalarToken associated whose value is "this is plain text" ends at the
beginning of the 5th line (the one with the comment):
---
string: >
this is plain text
# comment
9 years ago
Adrien Vergé
6a24781f96
Tests: indentation: Add explicit keys test cases
9 years ago
Adrien Vergé
0b0251bacc
Rules: indentation: Add the 'indent-sequences' option
...
Using either 'yes', 'no' or 'whatever', the user will be able to choose
whether to force block sequence items to be indented, to force them not
to be indented, or don't care, respectively.
9 years ago
Adrien Vergé
ad5cec9c6c
Config: Allow overriding only one option when extending
9 years ago
Adrien Vergé
8288a6f331
Rules: colons: Apply to '?' also
9 years ago
Adrien Vergé
9d8b0d4d2c
Rules: commas: Don't allow a comma on a new line
...
Forbid such constructions:
[ a, b, c
, d, e ]
9 years ago
Adrien Vergé
39c878c819
Rules: indentation: Rewrite the algorithm (again)
...
Use a new, better thought algorithm that keeps an history stack with all
the parents indentations.
9 years ago
Adrien Vergé
222f7a27c1
Make syntax errors prevail over all yamllint problems
9 years ago
Adrien Vergé
effb4db3b4
Tests: Rules: Remove unused `line` and `column` args
...
Now that every test case use the `problem=(x, y)` syntax.
9 years ago
Adrien Vergé
f09aef4f89
Rules: comments-indentation: Allow two levels
...
Previously only comments that were indented like the following content
line were allowed, e.g.:
prev: line:
# commented line
current: line
With this change, such new cases are also allowed:
prev: line
# commented line 1
# commented line 2
current: line
9 years ago