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

Errors outputting to sublime console, but no styles being applied to editor / empty diagnostics panel #28

Open
MarketHubb opened this issue Apr 8, 2024 · 7 comments

Comments

@MarketHubb
Copy link

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

// SublimeLinter Settings - User
{
    // "gutter_theme": "ProjectIcons",
    "debug": true,
    "lint_mode": "background",
    "linters": {
        "phpmd": {
            "disable": false,
            "executable": "/Users/chris/.composer/vendor/bin/phpmd",
            "selector": "source.php, embedding.php, text.html.php, meta.embedded.php, source.php.embedded.html",
            "real_file_mode": true,
        },
        "phpcs": {
            "disable": false,
            "args": [],
            "executable": "/Users/chris/.composer/vendor/bin/phpcs",
            "env": {},
            "excludes": [],
            "filter_errors": [],
            "lint_mode": "background",
            "selector": "",
            "styles": [
                {
                    "codes": [
                        ""
                    ]
                }
            ],
            "working_dir": "",
            "disable_if_not_dependency": false
        }
    },
    "paths": {
        "linux": [],
        "osx": [
            "/Users/chris/.composer/vendor/bin"
        ],
        "windows": []
    },
}
@kaste
Copy link
Contributor

kaste commented Apr 8, 2024

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.

@MarketHubb
Copy link
Author

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.'

@kaste
Copy link
Contributor

kaste commented Apr 8, 2024

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.

@MarketHubb
Copy link
Author

@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?

@kaste
Copy link
Contributor

kaste commented Apr 9, 2024

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.

@MarketHubb
Copy link
Author

MarketHubb commented Apr 9, 2024

@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.

@kaste
Copy link
Contributor

kaste commented Apr 10, 2024

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.)

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

No branches or pull requests

2 participants