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
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.
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.
Fixes#325
The linter allows a directive to contain trailing whitespace characters like
\r, but does not trim them before iterating on the rules. As a result, the last
rule in the list contains the trailing whitespace characters and never matches
any existing rule.
I added the necessary trimming, as well as a test with 2 checks to go along
with it.
Add 'forbid' configuration parameters to the braces and brackets rules
to allow users to forbid the use of flow style collections, flow
mappings and flow sequences.
Pound-signs followed by a lone CRLF should not
raise if require-starting-space is specified.
If require-starting-space is true, *and* either:
- new-lines: disbale, or
- newlines: type: dos
is specified, a line with `#\r` or `#\r\n` should
not raise a false positive.
This commit also uses a Set for O(1) membership testing
and uses the correct escape sequence for the nul byte.
If we find a CRLF when looking for Unix newlines, yamllint
should always raise, regardless of logic with
require-starting-space.
Closes: Issue #171.
Add ability to:
- require strings to be quoted if they match a pattern (PCRE regex)
- allow quoted strings if they match a pattern, while `require:
only-when-needed` is enforced.
Co-Authored-By: Leo Feyer (https://github.com/adrienverge/yamllint/pull/246)
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.
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.
Fixesadrienverge/yamllint#228
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.
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.
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']`.
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>