Skip to content

Add CLI argument to quiet PHPCS output #969

Closed
@catrope

Description

@catrope

When I run phpcs --report=json and it finds errors, it simply outputs {JSON here} and nothing else. However, if it finds no errors, it outputs {JSON here}Time: 97ms; Memory: 6Mb which is not valid JSON. Other tools that consume phpcs output (the linter-phpcs plugin in Atom in my case) choke on this.

I think this may have been broken by d4abee4; #335 indicates this information previously wasn't printed when no errors were found.

$ cat blah-bad.php  | phpcs --warning-severity=1 --standard=phpcs.xml --report=json


{"totals":{"errors":1,"warnings":0,"fixable":1},"files":{"STDIN":{"errors":1,"warnings":0,"messages":[{"message":"Each PHP statement must be on a line by itself","source":"Generic.Formatting.DisallowMultipleStatements.SameLine","severity":5,"type":"ERROR","line":30,"column":25,"fixable":true}]}}}

$ cat blah-good.php  | phpcs --warning-severity=1 --standard=phpcs.xml --report=json


{"totals":{"errors":0,"warnings":0,"fixable":0},"files":{"STDIN":{"errors":0,"warnings":0,"messages":[]}}}Time: 113ms; Memory: 6Mb

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions