-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
quoted-strings false positive on strings containing brackets #516
Comments
Hello @sxlijin, thanks for reporting this. A simpler reproduction is: $ yamllint -d 'rules: {quoted-strings: {required: only-when-needed}}' - <<<'field: [string[bracket]]'
1:15 error syntax error: expected ',' or ']', but got '[' (syntax)
$ yamllint -d 'rules: {quoted-strings: {required: only-when-needed}}' - <<<'field: ["string[bracket]"]'
1:9 error string value is redundantly quoted with any quotes (quoted-strings) @ruipinge you contributed In the meantine, a YAML block sequence can be used to workaround the problem: field:
- string[bracket] |
There's also a related case with commas in bracketed sequences:
|
Flow maps and sequences need quotes if the values contain any of the flow tokens ({}, [], ','). However, yamllint generates false positives in these cases: $ yamllint -d 'rules: {quoted-strings: {required: only-when-needed}}' - <<<'field: ["string[bracket]"]' 1:9 error string value is redundantly quoted with any quotes (quoted-strings) To fix this, track when inside a flow map/sequence and skip the quoting checks except for the quoting type. Resolves Issue adrienverge#516 Signed-off-by: Rob Herring <robh@kernel.org>
Flow maps and sequences need quotes if the values contain any of the flow tokens ({}, [], ','). However, yamllint generates false positives in these cases: $ yamllint -d 'rules: {quoted-strings: {required: only-when-needed}}' - <<<'field: ["string[bracket]"]' 1:9 error string value is redundantly quoted with any quotes (quoted-strings) To fix this, track when inside a flow map/sequence and skip the quoting checks except for the quoting type. Closes adrienverge#516
Flow maps and sequences need quotes if the values contain any of the flow tokens ({}, [], ','). However, yamllint generates false positives in these cases: $ yamllint -d 'rules: {quoted-strings: {required: only-when-needed}}' - <<<'field: ["string[bracket]"]' 1:9 error string value is redundantly quoted with any quotes (quoted-strings) To fix this, track when inside a flow map/sequence and skip the quoting checks except for the quoting type. Closes adrienverge#516
Flow maps and sequences need quotes if the values contain any of the flow tokens ({}, [], ','). However, yamllint generates false positives in these cases: $ yamllint -d 'rules: {quoted-strings: {required: only-when-needed}}' - <<<'field: ["string[bracket]"]' 1:9 error string value is redundantly quoted with any quotes (quoted-strings) To fix this, track when inside a flow map/sequence and skip the quoting checks except for the quoting type. Closes adrienverge#516
Flow maps and sequences need quotes if the values contain any of the flow tokens ({}, [], ','). However, yamllint generates false positives in these cases: $ yamllint -d 'rules: {quoted-strings: {required: only-when-needed}}' - <<<'field: ["string[bracket]"]' 1:9 error string value is redundantly quoted with any quotes (quoted-strings) To fix this, track when inside a flow map/sequence and skip the quoting checks except for the quoting type. Closes adrienverge#516
Flow maps and sequences need quotes if the values contain any of the flow tokens ({}, [], ','). However, yamllint generates false positives in these cases: $ yamllint -d 'rules: {quoted-strings: {required: only-when-needed}}' - <<<'field: ["string[bracket]"]' 1:9 error string value is redundantly quoted with any quotes (quoted-strings) To fix this, track when inside a flow map/sequence and skip the quoting checks except for the quoting type. Closes #516
When using brackets to define lists, string literals in that list can't contain brackets;
but when you include brackets:
yamllint complains about the string being quoted:
The text was updated successfully, but these errors were encountered: