ikappas / vscode-phpcs

PHP CodeSniffer for Visual Studio Code
MIT License
128 stars 56 forks source link

Lint only opened PHP files? #117

Open sofyansitorus opened 6 years ago

sofyansitorus commented 6 years ago

CMIIW, for now I see this extension will lint all PHP files under the folder project. It will be useful saving resources if this plugin can lint only opened files.

tfirdaus commented 6 years ago

@sofyansitorus strange that does not happen to me.

Below is an example where there are 4 files. 2 of them have errors.

example-1

...the error report seems following the file when it's closed or opened.

example-2
sofyansitorus commented 6 years ago

@tfirdaus Yeah it seems mine also work as yours. It seems I was confused by another linter report that printed in the PROBLEMS tab 🤦‍♂️ . Thanks for clarifying! 👍

sofyansitorus commented 6 years ago

@tfirdaus Today I got the same issue happen again. The PHP files has been closed but the linting still run as we can see it at the status bar at the bottom, and the report tabs is still has list of PHP files that never opened before. Have you ever face this issue before?

IMG

joeworkman commented 6 years ago

phpcs definitely processes all files in the project folder. Not just open files. I have a very large repository that has a lot of legacy PHP code that I need in my repo but dont need to worry about phpcs on them at this time. I would love to disable this. I have 920 phpcs errors at this time in my status bar. :-(

sofyansitorus commented 6 years ago

+1 Adding options to only enable linting while the files is opened

jaredatch commented 6 years ago

Oh man, I can't +1 this enough. I'd donate some dough for this feature.

I use PHPCS on VSC daily. For the most part it works well. But one of the projects I work on regularly is really large and the PHPCS package is more or less unusable. It takes forever to lint the project and basically ends up just linting itself into oblivion due to the size of things.

An option to only lint OPEN files and only lint on save (not on type) would completely solve all my issues.

cyann commented 6 years ago

PHPCS is also linting files in the Source Control tab, and I can't remove them from the Problems view.

I've added this to my config, but that doesn't work:

"phpcs.ignorePatterns": ["git:/*"],
jaredatch commented 6 years ago

@cyann

In your user or workspace settings, you should have something like:

    "files.exclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true
      },

That should seems to prevent the issue for me (at least, that I can tell).

cyann commented 6 years ago

@jaredatch

Yes, this is the default. I've also copied that my workspace and user settings, no changes.

arvilmena commented 5 years ago

+1 for this feature, I believe this feature solves the bug that causes multiple PHP process spawning that floods CPU to 100% usage.