CodeSniffer Inspect Code only shows 1 warning
Answered
I'm new to PHPStorm but very impressed so far; I've managed to get PHP CodeSniffer up and running (see below screenshot) and highlighting sniffs in the editor is working well and shows all issues (at least up to the 100 allowed!).
But when I perform "Inspect Code" on the source (shown in the screenshot running on a single simple file) there is only ever a single CodeSniffer warning (always the first issue). Other inspections seem to be working fine and returning hundreds of warnings across large code bases.
I've spent a while trying to plough through the settings but can't find a reason for this. Can anyone enlighten me?
Lee

Please sign in to leave a comment.
Sorry, just realised that in the above screenshot the inspection was run before removing a comment. This is how it should look!
Apologies, what the issue is? Should there be more PHPCS warnings for given file?
Could you please illustrate this (e.g. a screenshot of phpcs run against that file in terminal)?
Sure, each of the yellow highlighted lines in the previous screenshot should trigger at least one CS warning. As requested, I've run phpcs in the terminal against the same file:
Is the coding standard at Preferences | Editor | Inspections > PHP | PHP Code Sniffer validation set correctly?
Yes, as you can see from the screenshot below, I have the coding standard set to PEAR as per the example above. Looking at a larger file in my project I get the "phpcs: Too many messages per file..." warning at the top of the editor but running Code | Inspect Code... on that same file again just gives me a warning for the first CodeSniffer violation.
I cannot say for sure, but I think before I experimented I was getting a full list of violations in the Inspect Code results. But as you see from the above screenshot, I have returned the standard Warning severity and returned to the PEAR coding standard.
I have also tried with the "show warnings as..." checkbox turned on and the "show sniff name" box on and off.
Whatever I try, I am still only getting the first violation listed in Inspect Code... despite many lines in the code being highlighted with violations (and many colour stripes in the scrollbar). Are there any other settings I should be looking at?
(Quite possibly I will be completely wrong her as I do not run CodeSniffer so cannot verify it myself .. but still)
How many Inspection Profiles do you have?
When you run "Code | Inspect Code" --- can you please double check what "Profile" is selected there? Maybe you are running using wrong/different profile that is configured differently...
Anything related in the idea.log (Help | Show Log in...)?
Thank you for your theory. The Inspection Profiles list Project Default (selected) and IDE Default. Switching to IDE default doesn't include the CodeSniffer checks at all. There are no other inspection profiles.
I looked at idea.log and running Inspect Code just added these two lines:
That's rather strange behavior.
Could you please try to configure the same PHPCS inspection for any other project and check if it would report more errors there? Just want to make sure this isn't a project-related glitch.
It does seem to be related to the project. I created a very simple new project with just one PHP file and a single class and ran Inspect Code with (as far as I know) the same CodeSniffer settings. This time all highlighted violations were reported in the Inspection Results pane.
Could you run File > Invalidate Caches > Invalidate and Restart and check if this will help the initial project?
I suspect that probably would have worked, but I'm afraid there's no way to know now. The old project sources included a symlink which I removed when I set up the reconfigured project (so as to avoid a circular reference). The old project was then reindexed before and after I recreated the symlink which I imagine also invalidated much of the previous cache.
Anyway, I am now happy as both old and new projects both return the correct number of CodeSniffer results when I use Inspect Code.
Many thanks to everyone who gave suggestions.