我想将 PHP CodeSniffer 添加到 VScode。
在 VScode 中,我收到错误“phpcs:phpcs 报告包含无效的 json”
但是,当我在终端中运行以下命令时:
phpcs --standard="WordPress-Core" -q --report=json --encoding=UTF-8 dropdowns.php
PHP Codesniffer 使用以下终端输出按预期工作:
{"totals":{"errors":34,"warnings":17,"fixable":50},"files":{"\/Users\/michelle\/Local Sites\/hdpiano2\/app\/public\/wp-content\/themes\/hdpiano\/inc\/dropdowns.php":{"errors":34,"warnings":17,"messages":[{"message":"Array double arrow not aligned correctly; expected 10 space(s) between \"'id'\" and double arrow, but found 1.","source":"WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned","severity":5,"fixable":true,"type":"WARNING","line":15,"column":14},{"message":"Array double arrow not aligned correctly; expected 4 space(s) between \"'taxonomy'\" and double arrow, but found 1.","source":"WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned","severity":5,"fixable":true,"type":"WARNING","line":17,"column":20},{"message":"Array double arrow not aligned correctly; expected 5 space(s) between \"'orderby'\" and double arrow, but found 1.","source":"WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned","severity":5,"fixable":true,"type":"WARNING","line":18,"column":19},{"message":"Equals sign not aligned with surrounding assignments; expected 10 spaces but found 1 space","source":"Generic.Formatting.MultipleStatementAlignment.NotSameWarning","severity":5,"fixable":true,"type":"WARNING","line":34,"column":15},{"message":"Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space","source":"Generic.Formatting.MultipleStatementAlignment.NotSameWarning","severity":5,"fixable":true,"type":"WARNING","line":35,"column":18},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":36,"column":26},{"message":"Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space","source":"Generic.Formatting.MultipleStatementAlignment.NotSameWarning","severity":5,"fixable":true,"type":"WARNING","line":44,"column":19},{"message":"Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space","source":"Generic.Formatting.MultipleStatementAlignment.NotSameWarning","severity":5,"fixable":true,"type":"WARNING","line":84,"column":14},{"message":"Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space","source":"Generic.Formatting.MultipleStatementAlignment.NotSameWarning","severity":5,"fixable":true,"type":"WARNING","line":111,"column":13},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":130,"column":16},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":131,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":135,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":139,"column":9},{"message":"Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space","source":"Generic.Formatting.MultipleStatementAlignment.NotSameWarning","severity":5,"fixable":true,"type":"WARNING","line":144,"column":13},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":165,"column":16},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":166,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":170,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":174,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":178,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":182,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":186,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":190,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":194,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":198,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":202,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":211,"column":22},{"message":"Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space","source":"Generic.Formatting.MultipleStatementAlignment.NotSameWarning","severity":5,"fixable":true,"type":"WARNING","line":217,"column":13},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":236,"column":16},{"message":"Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space","source":"Generic.Formatting.MultipleStatementAlignment.NotSameWarning","severity":5,"fixable":true,"type":"WARNING","line":260,"column":13},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":279,"column":16},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":280,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":284,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":288,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":292,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":296,"column":9},{"message":"Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space","source":"Generic.Formatting.MultipleStatementAlignment.NotSameWarning","severity":5,"fixable":true,"type":"WARNING","line":301,"column":13},{"message":"Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space","source":"Generic.Formatting.MultipleStatementAlignment.NotSameWarning","severity":5,"fixable":true,"type":"WARNING","line":303,"column":11},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":316,"column":16},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":317,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":321,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":325,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":329,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":333,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":337,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":341,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":345,"column":9},{"message":"Short array syntax is not allowed","source":"Generic.Arrays.DisallowShortArraySyntax.Found","severity":5,"fixable":true,"type":"ERROR","line":349,"column":9},{"message":"Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space","source":"Generic.Formatting.MultipleStatementAlignment.NotSameWarning","severity":5,"fixable":true,"type":"WARNING","line":354,"column":13},{"message":"Found precision alignment of 1 spaces.","source":"WordPress.WhiteSpace.PrecisionAlignment.Found","severity":5,"fixable":false,"type":"WARNING","line":396,"column":1},{"message":"Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space","source":"Generic.Formatting.MultipleStatementAlignment.NotSameWarning","severity":5,"fixable":true,"type":"WARNING","line":460,"column":14},{"message":"Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space","source":"Generic.Formatting.MultipleStatementAlignment.NotSameWarning","severity":5,"fixable":true,"type":"WARNING","line":461,"column":14}]}}}
输出中没有无效的 JSON,我不确定如何继续使其正常工作。