Open MarketHubb opened 7 months ago
Hm, I would expect some lines with "No match for line ..." in the console output. That would indicate that our regex can't parse the output format of phpmd. I guess "phpcs" is working so the setup/install of SublimeLinter itself is working as well.
You can of course have a post-filter applied (e.g. the plugin/addon SublimeLinter-addon-filter can do this).
Maybe post the console output.
Hey @kaste,
Thank you for the quick response. I should have included those logs in the initial report. It is actually is logging a ton of "No match for file..."
Here are some log examples I'm seeing:
(Linter command)
INFO:SublimeLinter.plugin.phpmd:Running ...
/Users/chris/Dropbox/valet/markethub (working dir)
$ /Users/chris/.composer/vendor/bin/phpmd /Users/chris/Dropbox/valet/markethub/wp-content/themes/markethubb-theme/footer.php text cleancode,codesize,controversial,design,naming,unusedcode
(STDOUT)
SublimeLinter: #5 linter.py:1241 phpmd: output:
- Unexpected token: problemFnc, line: 8, col: 10, file: /Users/chris/Dropbox/valet/markethub/wp-content/themes/markethubb-theme/footer.php.
(No match)
SublimeLinter: #5 linter.py:1293 phpmd: No match for line: ' - Unexpected token: problemFnc, line: 8, col: 10, file: /Users/chris/Dropbox/valet/markethub/wp-content/themes/markethubb-theme/footer.php.'
INFO:SublimeLinter.plugin.phpmd:phpmd: No match for line: ' - Unexpected token: problemFnc, line: 8, col: 10, file: /Users/chris/Dropbox/valet/markethub/wp-content/themes/markethubb-theme/footer.php.'
Yeah, that's not the formatting we expect here. We have a very simple regex (.+):(?P<line>\d+)\s*(?P<message>.+)$
which very obvious does not match for e.g.
- Unexpected token: problemFnc, line: 8, col: 10, file: /Users/chris/Dropbox/valet/markethub/wp-content/themes/markethubb-theme/footer.php.
- Unexpected token: problemFnc, line: 8, col: 10, file: /Users/chris/Dropbox/valet/markethub/wp-content/themes/markethubb-theme/footer.php.
You probably set that somewhere as usually the linters don't change defaults as it would break anyone. Or did they: we run 'phpmd', target, 'text'
so it should be the "text" format
That said your formatting is also better as it has column information in it.
@kaste,
I can write custom regex for the diagnostics panel, but shouldn't there still be some sort of output in the buffer / gutter where the errors are being found, or do I misunderstand how the package is set up to work?
It works like this: we run the linter, grab its output, parse it line-by-line to get a standardized form of each error. These are then stored in the store, and various "views" react to that: they draw squiggles or show them in the bottom panel when open, or in the status bar or in a tooltip on hover etc.
You can't write a custom regex though. The regex is the same for all users. The question is why you have such a format. The text
format should be very compact, e.g. file:18 The message
.
@kaste,
Would you be comfortable sharing your phpmd.xml
so I can mimic yours exactly and remove that variable?
Also, feel free to send it to me on the Sublime Discord if that's easier.
I actually don't have a phpmd.xml
file as I'm not using phpmd. Where is yours from? I don't recognize your formatting style. Could that be a custom renderer or a custom phpmd?
As we explicitly ask for the text format, see their tests of how that should look like: https://github.com/phpmd/phpmd/blob/e9c0e1f47a391c54e473ddde783ccbf22e2d457c/src/test/php/PHPMD/Renderer/TextRendererTest.php#L68-L72
(Now, we should probably also extract the rule names as separate entities and not as part of the message but that's a completely other point.)
Issue
With the debug enabled, I can see that the package is formatting the command correctly (i.e.,
index.php text cleancode,codesize,controversial,design,naming,unusedcode
), and the errors and warnings are outputting to the Sublime console exactly as they are if I run the command directly in my terminal.However, no "error" or "warning" styles are being applied to the buffer, nor is anything outputting to the diagnostics panel via SublimeLinter --> Open diagnostics panel
Setup Sublime 4169 SublimeLinter 4.23.5 SublimeLinter-phpmd 1.3.0
User config