Skip to content
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

Sniffing from STDIN shows Generic.Files.LowercasedFilename.NotFound error #711

Closed
skyrpex opened this issue Sep 22, 2015 · 3 comments
Closed

Comments

@skyrpex
Copy link

skyrpex commented Sep 22, 2015

Atom's PHPCS linter plugin uses now STDIN to lint on the fly. Someone that uses the Wordpress-VIP ruleset is getting this error Generic.Files.LowercasedFilename.NotFound.

The output of this command cat "path/myfile.php" | phpcs --report=json --standard=WordPress-VIP is:

{
    "totals": {
        "errors": 1,
        "warnings": 0,
        "fixable": 0
    },
    "files": {
        "STDIN": {
            "errors": 1,
            "warnings": 0,
            "messages": [
                {
                    "message": "Filename \"STDIN\" doesn't match the expected filename \"stdin\"",
                    "source": "Generic.Files.LowercasedFilename.NotFound",
                    "severity": 5,
                    "type": "ERROR",
                    "line": 1,
                    "column": 1,
                    "fixable": false
                }
            ]
        }
    }
}

You'll notice that STDIN is treated the filename... See AtomLinter/linter-phpcs#60

@gsherwood
Copy link
Member

The proper way to resolve this is for the plugin to tell PHPCS the filename so that sniffs that check the filename still work correctly. To do that, the first line of the input should be phpcs_input_file: [file path], for example:

phpcs_input_file: /path/to/test.php
<?php
echo 'test';

@gsherwood
Copy link
Member

I've posted the same comment on the linked issue for the plugin. This feature was added in version 2.0 specifically to allow for plugin (Sublime plugins, at the time) to support filename checking.

@gsherwood
Copy link
Member

Now that I've said that, the quick and easy way to fix this is for the sniff to ignore files with the name STDIN, which I'll also do. But that's something that will need to wait for the next release while the Atom plugin could be updated to work correctly today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants