Jonathan Sokolowski
03e0f5aa6b
Add strict mode argument to CLI
2016-10-24 14:08:46 +11:00
Adrien Vergé
6dae8f5b6e
feat(truthy): Allow explicit types
...
With this change, we don't require quotes for truthy values that are
explicitly typed. For instance, the following examples are all
considered valid:
string1: !!str True
string2: !!str yes
string3: !!str off
encoded: !!binary |
True
OFF
pad== # this decodes as 'N\xbb\x9e8Qii'
boolean1: !!bool true
boolean2: !!bool "false"
boolean3: !!bool FALSE
boolean4: !!bool True
boolean5: !!bool off
boolean6: !!bool NO
2016-10-02 08:15:53 +02:00
Peter Ericson
5294ff5552
truthy: Add tests for explicit booleans
...
From @adrienverge
2016-10-01 09:04:37 +02:00
Peter Ericson
1f472bc144
Add rule: truthy, to forbid truthy values that are not quoted
2016-10-01 09:03:59 +02:00
Adrien Vergé
f656cf42d2
fix(line-length): Wrap token scanning securely
...
With `allow-non-breakable-inline-mappings` enabled, every long line is
passed through `loader.peek_token()`. Even lines that are not valid
YAML. For this reason, this code must be wrapped in a `try`/`except`
block.
Closes : #21
2016-09-27 09:27:43 +02:00
Adrien Vergé
d3cd8ba332
line-length: Generalize ...-inline-mappings for corner cases
...
This commit refactors the `allow-non-breakable-inline-mappings` logic to
use YAML tokens and avoid crashes or erroneous reports on cases like:
```yaml
- {a: "http://localhost/very/very/very/very/very/very/long/url "
}
```
```yaml
dict:
{a: long long long long long long long, b: nospace}
```
```yaml
- long_line: http://localhost/very/very/long/url
```
```yaml
long_line: and+some+space+at+the+end <-- extra spaces
```
For reference see:
https://github.com/adrienverge/yamllint/pull/17#issuecomment-247805799
2016-09-19 12:39:52 +01:00
Allan Lewis
e56a7c788c
line_length: Extract inline logic to new config option
...
This commit extracts the inline mappings logic defined in the previous
commit to a separate config option, as suggested by @adrienverge. I'll
squash this into the previous commit if the change is accepted. (I named
the option slightly differently to what was suggested as I think my
proposal reads better without consulting the docs: I'd be happy to
reconsider this.)
2016-09-19 12:39:52 +01:00
Allan Lewis
d017631aff
line_length: Allow mapping values with long unbreakable lines
2016-09-12 16:31:58 +01:00
Adrien Vergé
5b98cd2053
feat(comments): Allow comments with multiple hash chars
...
This change make the `comments` rule accept comments that start with
multiple pound signs, e.g.:
##############################
## This is some documentation
Closes : #12
2016-08-12 11:58:57 +02:00
Adrien Vergé
a2c68fdf9b
feat(cli): Colour output only on TTY
...
When piping yamllint output to a file, "coloured" characters aren't
interpreted and pollute text formatting with glyphs like:
�[4m./global.yaml�[0m
�[2m1439:52�[0m �[31merror�[0m no new line character...
With this commit, stdout is checked: if it's a TTY then output is
coloured, otherwise output is simple text.
Closes : #14
2016-08-12 11:03:41 +02:00
Adrien Vergé
92ff315fb4
Tests: Set proper LC_ALL when decoding UTF-8 is needed
...
Make sure the default localization conditions on the "test system"
support UTF-8 encoding.
2016-06-28 12:06:55 +02:00
Adrien Vergé
f4cebdc054
Tests: Run with LC_ALL=C for uniform tests
...
Use default (C) locale in all tests to make sure the localization
conditions are the same wherever tests are run.
2016-06-28 11:04:50 +02:00
Adrien Vergé
c8ba8f7e99
linter: Fix UnicodeError when parsing comments
...
And add tests when reading non-ASCII strings and comments (both from
Python strings and from files).
Fixes : #10
2016-06-28 09:58:23 +02:00
Adrien Vergé
0eb310e102
Allow disabling yamllint checks using comments
...
Implement problem report disabling with comments in YAML source, for
instance:
# The following mapping contains the same key twice,
# but I know what I'm doing:
key: value 1
key: value 2 # yamllint disable-line rule:key-duplicates
or:
# yamllint disable rule:colons
- Lorem : ipsum
dolor : sit amet,
consectetur : adipiscing elit
# yamllint enable rule:colons
Closes : #8
2016-06-27 17:53:23 +02:00
Adrien Vergé
cdd094220c
parser: Add tests for Comment.is_inline()
2016-06-27 17:47:13 +02:00
Adrien Vergé
7a7d98c96a
parser: Iterate over lines + tokens + comments
...
Instead of iterating over lines and tokens (and find comments between
tokens in the comment rules), add a new `Comment` type and set rules
with `type = 'comment'`.
2016-06-27 17:47:13 +02:00
Michele Bariani
867970258e
Patch allow-non-breakable-words on '-'
2016-06-15 18:07:42 +02:00
Adrien Vergé
eabd349902
Config: Allow a user-global configuration file
...
Instead of just looking for `.yamllint` in the current working
directory, also look for `~/.config/yamllint/config` (using
`$XDG_CONFIG_HOME` or `$HOME`, see [1] and [2] for information).
[1]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-0.6.html
[2]: https://wiki.archlinux.org/index.php/XDG_Base_Directory_support
Closes : #6
2016-04-21 22:24:24 +02:00
Adrien Vergé
59d5bffbec
Tests: cli: Detect and handle the -d '' case
2016-03-25 13:46:19 +01:00
Adrien Vergé
53da21934d
Tests: Add many cli.run test cases
2016-03-25 13:46:19 +01:00
Adrien Vergé
88ebcbbb93
Tests: Test cli.find_files_recursively
2016-03-25 13:46:19 +01:00
Adrien Vergé
08615ec4f8
Tests: config: Check the non-valid-yaml-config case
2016-03-25 13:46:19 +01:00
Adrien Vergé
29aceb430a
Tests: indentation: Increase coverage
2016-03-25 13:46:19 +01:00
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
2016-03-22 14:34:07 +01:00
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.
2016-03-06 15:42:16 +01:00
Adrien Vergé
9a7eec34b1
Rules: indentation: Fix spaces: consitent with broken flows
2016-03-06 08:26:09 +01:00
Adrien Vergé
5b62548ece
Tests: indentation: Use 'spaces: consistent' by default
2016-03-06 08:26:09 +01:00
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.
2016-03-06 08:00:25 +01:00
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.
2016-03-04 16:03:53 +01:00
Adrien Vergé
fa420499c7
Config: Allow types in multiple choices
...
For instance, allow rules with:
CONF = {'choice': (int, 'hardcoded-string'),
'string-or-bool': (str, bool)}
2016-03-04 16:03:46 +01:00
Adrien Vergé
29c1c60143
Tests: Use absolute path to spec examples
2016-03-04 12:15:26 +01:00
Adrien Vergé
10ad302e2f
Tests: Explicit encoding for spec examples
...
YAML specification examples contain unusual characters, let's explicit
`encoding='utf-8'` to prevent bugs.
2016-02-25 10:44:05 +01:00
Adrien Vergé
73d9322813
linter: Test run on str, unicode, bytes and stream
...
Previously it was not tested, and broke on Python 2 `unicode` inputs.
2016-02-25 10:41:17 +01:00
Adrien Vergé
6c8af97a40
Tests: unblacklist remaining spec examples
...
Since !!tags are now supported.
2016-02-05 11:14:37 +01:00
Adrien Vergé
647d84ff94
Rules: indentation: Handle tags
2016-02-05 11:13:44 +01:00
Adrien Vergé
8eb0d0ad74
Tests: unblacklist spec example 7.16
...
As is it supported -- it just lacks some indentation.
2016-02-05 09:52:09 +01:00
Adrien Vergé
4bc3d5a01c
Rules: indentation: Handle anchors
2016-02-04 22:10:40 +01:00
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).
2016-02-04 22:10:40 +01:00
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.
2016-02-04 22:10:40 +01:00
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
],
},
]
2016-02-03 12:05:22 +01:00
Adrien Vergé
ba140ad42c
Tests: Remove ghost character from YAML spec example
2016-02-01 23:27:49 +01:00
Adrien Vergé
f6bab05e8a
Rules: Add the 'key-duplicates' rule
2016-02-01 22:26:18 +01:00
Adrien Vergé
c16eec4681
Style: Fix indentation not multiple of four
2016-02-01 21:36:35 +01:00
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]
2016-02-01 17:52:46 +01:00
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.
2016-02-01 17:05:22 +01:00
Adrien Vergé
6b5948c06b
Tests: Reorganize common and global tests
2016-02-01 16:56:32 +01:00
Adrien Vergé
dd163ed551
Rules: indentation: Fix flow sequences with multi-line scalars
...
Typically sequences like this:
["multi
line 1", "multi
line 2"]
2016-02-01 16:56:32 +01:00
Adrien Vergé
14c99da2bb
Tests: Add test cases for empty flows
2016-02-01 16:56:32 +01:00
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
2016-02-01 14:59:52 +01:00
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.
2016-02-01 12:13:10 +01:00