Giter Club home page Giter Club logo

vscode-phpcs's People

Contributors

admad avatar bravo-kernel avatar ikappas avatar mvdriel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

vscode-phpcs's Issues

Lint multiple folders on a directory

It would be nice if it had a setting so I can set the folders of my code.

phpcs example:

phpcs --standard=WordPress wp-content/themes/deugame/src wp-content/plugins/deugame-manager/src

phpcs: Unexpected end of JSON input

Windows 10 Home
VS Code v. 1.11.2

Plugin not working on opened file. After saving showing notification with error:
"phpcs: Unexpected end of JSON input"

It worked perfectly yesterday.

Windows 10 warning for all php files: File appears to be minified and cannot be processed

I am having an issue where all php files opened in my Windows 10 Visual Studio Code IDE produce the following warning:

afbeelding

Full error message:

file: 'file:///c%3A/Users/bravo/VScodeProjects/test-app/src/Controller/AppController.php'
severity: 'Warning'
message: 'File appears to be minified and cannot be processed'
at: '1,1'
source: 'phpcs'

Even this basic file is enough to trigger the warning:

<?php
   print "the line above causes the trigger"

I am running:

  • Windows 10
  • Visual Studio Code 1.10.2
  • PHP 7.1.2 (cli) (built: Feb 14 2017 21:24:49) ( ZTS MSVC14 (Visual C++ 2015) x64 )
  • PHP_CodeSniffer version 2.8.1 (stable) by Squiz (http://www.squiz.net)

I am creating this ticket because the warning only seems to occur in the IDE, the warning does not show when running phpcs against the exact same php files on both:

  • my Windows machine (same phpcs as used by VSC and your extension)
  • my Linux machine

All pointers highly appreciated.

Linting never completes

When running on Windows 7. VS Code version 0.10.6.

phpcs is installed globally and in my path but even on a small file the status bar just sits saying 'phpcs is linting 1 document' with a spinner.

Is there any way I can get diagnostic output?

Does not shows errors onType

This extension does not shows errors onType although "php.validate.run": "onType" is exists in user settings.

This extension shows errors after saving file.

Visual Studio Code information. Version 1.0.0 Commit fa6d0f03813dfb9df4589c30121e9fcffa8a8ec8 Date 2016-04-13T14:21:33.326Z Shell 0.35.6 Renderer 45.0.2454.85 Node 4.1.1 On Ubuntu 14.4

Fails to process if path contains a space

If either the directory or filename contain a space phpcs will fail to process the file. It will return an error like:

phpcs: The file "XXX" does not exist.

where XXX = the path before the space

Unable to locate phpcs

I am receiving the following error with phpcs installed locally and globally.

MacOS Sierra 10.12.4
VSCode 1.11.2

phpcs: Unable to locate phpcs. Please add phpcs to your global path or use composer dependency manager to install it in your project locally.

Terminal output:

$ phpcs --version
PHP_CodeSniffer version 2.8.1 (stable) by Squiz (http://www.squiz.net)

EDIT:
The above error occurs on a project hosted on a mounted drive accessible through a VPN.

I tried it on a local project and receive the following error

The PHP CodeSniffer Linter server crashed 5 times in the last 3 minutes. The server will not be restarted.

Console output:

linting started on: file:///path/to/file.php

spaces or indentation not detected

Using php standard PSR2:
when indented 2 spaces, it will complain and lint correctly;
when indented 6 or more spaces or multiple tabs, it will not complain and ignore

High CPU on multiple file changes

The extension works great! So, I guess this is an improvement to work fine with big projects.

When you change multiple files in a project, for example 100 files, vscode-phpcs fires simultaneous 100 processes.... and CPU is overloaded.

There is also a second (weird) case when CPU is overloaded. When VSCode tries to write a file with no write permissions, it fires a change event to all files in a project! In my case, it can be easily 200-300 simultaneous processes running phpcs.

I'm currently disabling the extension with "phpcs.enable": false.

It would be better to have a feature to disable it per project .... or a CPU processes limit to 1 (the file that's being edited.... and not all changes files).

Ignoring files

Has a way to configure to ignore paths and files for avoid linting?

Unable to locate phpcs on macOS Sierra

Hello,

I am trying to resolve this error:

phpcs: Unable to locate phpcs. Please add phpcs to your global path or use composer depency manager to install it in your project locally.

I have phpcs installed in these locations:

screenshot

Output of echo $PATH:

~/wpcs/vendor/bin:/Users/sridharkatakam/.nvm/versions/node/v5.6.0/bin:./node_modules/.bin:/usr/local/git/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

I went through some of the previous issues on this topic and ran this in terminal:

ln -s ~/wpcs/vendor/bin/phpcs /usr/local/bin/phpcs

and restarted VS Code. But that didn't make a difference.

Any idea?

Can't locate phpcs on macOS

So I installed VSCode, the phpcs extension and then phpcs using PEAR:

sudo pear install phpcs (does not work without sudo: No releases available for package "pear.php.net/phpcs")

After restarting VSCode I get the message:

phpcs: Unable to locate phpcs. Please add phpcs to your global path or use composer depency manager to install it in your project locally.

which phpcs returns /usr/local/bin/phpcs

Anyone?

Not showing N further errors or warnings

I have files in the project I'm working on that contain a lot of coding standard violations

screen shot 2017-05-31 at 11 15 16

Is it possible to see all the warnings and errors no matter how many there are?

What's the point ?

I've struggled for hours to install phpcs and it just says "you have an error". It would be much more convinient if it tried to fix it. But it doesn't. I can't manage to indent correctly my code that I modify with ftp-simple as I guess does 90% of php coders in the world. So this extension is pointless.

Unable to locate phpcs

Hello,
I tried to install the phpcs plugin for Visual Studio Code but I keep getting phpcs: Unable to locate phpcs. Please add phpcs to your global path or use composer depency manager to install it in your project locally. message. I can access phpcs from the Command Line, it is available globally in the PATH.
The PATH on my device is following:

PATH=C:\Program Files (x86)\iis express\PHP\v5.6;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Git\cmd;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Program Files\nodejs\;C:\Users\hajek\.dnx\bin;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\hajek\AppData\Roaming\npm

I also tried adding phpcs.bat to the PATH directly, but it didn't change anything (not even after restart). The resulting PATH was like this:

PATH=C:\Program Files (x86)\iis express\PHP\v5.6;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Git\cmd;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Program Files\nodejs\;C:\Users\hajek\.dnx\bin;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\hajek\AppData\Roaming\npm;C:\Program Files (x86)\IIS Express\PHP\v5.6\phpcs.bat

I have tried restarting my PC as well, but nothing has changed.

The call to phpcs from Command Line is following:

C:\Users\hajek>phpcs --version
PHP_CodeSniffer version 2.6.0 (stable) by Squiz (http://www.squiz.net)

Running on Windows 10 Pro 1511.

Any idea what I could be doing wrong?

Linting very slow

First of all, thanks for this extension! It is very helpful :)

Unfortunately, I encounter very slow linting performance in my project. It is a very straightforward project with just a bunch of classes, some Composer dependencies, and that's it.

Linting a single file in Visual Studio Code takes about a whole minute ("phpcs is linting 1 document ... /"), whereas if I run the sniffer from the command line, it takes around 25-50ms for every file.

Any idea how this is possible?

System: OSX 10.11.4 / 8GB RAM / 4GHz i7

Implement lint-as-you-type

vscode-phpcs lints files on save (and load). It's possible to lint unsaved files by feeding file contents to PHPCS on its STDIN. This might provide for more interactive user experience: seeing if you introduced a problem or fixed one without saving the file.

You may borrow some implementation bits from AtomLinter/linter-phpcs that implemented this feature.

Autoformat

Is there a way i can autoformat the code on save for PSR2 standards?

Switch and case indenting

Hi,

PHPCS is working great for me, very handy to update code as I work on it or making sure new code is formatted correctly.

It appears that the indenting check for the case may be off. If I have a switch statement inside a function, it is indented and then the case statement has an additional indent. However, the PHPCS shows the indentation is wrong, that it was expecting 4 spaces, but found 8. I think the check may not be taking into account the indent for being inside a function.

I double checked the standard.
http://www.php-fig.org/psr/psr-2/#5-2-switch-case

Here's my truncated sample code. There is an error message for each case line and the default line.

function createWebsiteImage($orig_name, $new_name, $path, $w, $h, $img) { switch($img) { **case 1:** $nw = 150; $nh = 205; break; **case 2:** $nw = 205; $nh = 150; break; **default:** $nw = 220; $nh = 220; break; } }

Unable to locate phpcs

I am trying to use VS Code and phpcs on a local system running xampplite. As a result, php and phpcs are not installed in c:\php but rather are in C:\xampplite\php. Is there a setting in the phpcs extension that would allow me to point it to the right spot?

I have added C:\xampplite\php to my PATH but when I do that I get the message: Report type "json" not known

Any guidance to get this working?

Thanks,
Ben

Add ability to select phpcs

I've a phpcs version installed globally. How about a config param, say "phpcs.path" that would allow me to insert the path for my global phpcs for the times I want to test a different version of phpcs with existing projects?

error: "phpcs: Unexpected token F in JSON at position 0"

I got this error "phpcs: Unexpected token F in JSON at position 0" every time I open or save a PHP file.

My phpcs is installed system-wide, and it is working properly in my terminal.

$  php --version
PHP 5.6.29 (cli) (built: Jan 14 2017 21:05:20)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans

$  which php
/usr/local/php5/bin/php

$  phpcs --version
PHP_CodeSniffer version 2.6.2 (stable) by Squiz (http://www.squiz.net)

My guess is that this extension is parsing the text report (not a JSON format report) by mistake. The error message Unexpected token F in JSON looks like the first character of this:

$ phpcs src

FILE: test.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
 8 | ERROR | [x] Whitespace found at end of line

Add config to allow specifying phpcs executable location.

The plugin currently checks whether package with name squizlabs/php_codesniffer is present under packages or packages-dev of composer.lock and if found uses the phpcs binary from vendor/bin. Now my project has a dev dependency which itself has php codesniffer as dependency causing squizlabs/php_codesniffer package to be present under packages-dev of composer.lock and hence the plugin uses the vendor/bin/phpcs binary. But I don't want that and instead want my globally installed phpcs to be used (available through environment path) which is configured as per my needs.

So it would be nice if there was an option to explicitly specify the phpcs executable location. That would also help resolve the issues like #48 where the plugin is unable to detect phpcs location.

Can't locate phpcs on macOS Sierra

Although this has been closed twice, the problem seems to persist. I have a fresh install of VSCode and I have installed phpcs to /opt/local/bin, which is in my path. Calling phpcs from the command line works fine.

Nevertheless I still get the message:

phpcs: Unable to locate phpcs. Please add phpcs to your global path or use composer depency manager to install it in your project locally.

Moving phpcs to /usr/local/bin (also in my path) does not help.

Where does the plugin look for phpcs?

And thanks for your work on this Ioannis, phpcs is awesome and having it as a VSCode plugin would be brilliant.

phpcs: Unable to locate phpcs (php installed, pear installed, phpcs intalled)

Edit: Restarting the system fixed the issue. Looks like I now have the same issue as described here.

Hey,

I'm getting the error "phpcs: Unable to locate phpcs. Please add phpcs to your global path or use composer depency manager to install it in your project locally." on VS Code.

PHP is installed in E:\php
PEAR is installed in E:\php
phpcs is installed in E:\php\pear\PHP\CodeSniffer (phpcs is also available in E:\php)

What am I supposed to add to the global path, assuming it's the Windows environment variable "Path"?
I've tried a lot of different paths and none seem to work.

Support -s flag output

The current error output doesn't tell you what rule definition originated the error. This makes debugging and optimizing your rulesets significantly more difficult.

It's be nice if this information was included on the tooltip, but if not there, at least in the debug panel output. My phpcs.xml file includes the -s flag argument, but it doesn't seem that's being respected with output.

phpcs: The "WordPress-Extra" coding standard set in your configuration is not installed...

Been getting this error notification lately. phpcs is installed through brew and available at /usr/local/bin/phpcs

There is no other version of phpcs installed on my machine as far as I know and therefore the one in /usr/local/bin should be used.

The WordPress coding standards are installed

→ phpcs -i
The installed coding standards are MySource, PEAR, PHPCS, PSR1, PSR2, Squiz, Zend, WordPress, WordPress-Core, WordPress-Docs, WordPress-Extra and WordPress-VIP

Specify standard to use

Is it possible to specify the standard that phpcs will use or does it just pick the default? It would also be good to be able to specify this per-project.

"phpcs.standard" with a .xml doesn't work

I have a ruleset.xml that I wanted to use to set the standard but I get an issue with DirectoryIterator (I believe)

I only see Unexpected token P or something along those lines as an error.

I had it set in settings as

"phpcs.standard": "/path/to/my/ruleset.xml",

Add phpcs.error_severity and phpcs.warning_severity

I'd like to be able to override the warning_severity (my CI tools doesn't care about warnings)
Eg: vendor/bin/phpcs . --standard=phpcs.ruleset.xml --warning-severity=0

There's no setting for this. Can you add those settings ?
/phpcs-server/src/linter.ts:43
/phpcs-server/src/linter.ts:281
/phpcs/package.json:33
/phpcs/README.md:56

(I would have posted a pull-request, but I don't know how to build and test a vscode extension)

Use multiple standards at the same time

My team uses multiple standards like this:
phpcs --standard=Drupal,DrupalSecure
which works fine when running in on the command line

So we configured it as

{
  "phpcs.standard": "Drupal,DrupalSecure"
}

When we do that, we get
phpcs: Unexpected token P in JSON at position 0

Is there a way to achieve that?

Specify encoding

By default, PHPCS assumes file encoding to be encoded in ISO-8859-1. Nowadays people generally use UTF-8, but some may use other multibyte charsets as well.

Not specifying encoding when running PHPCS on multibyte (including UTF-8, when using non-ascii characters) encoded files causes it to report wrong character offsets, and also causes character-width sensitive sniffs fail where they shouldn't. For example, this code trigger failures of line-length sniff (from PSR2 ruleset):

<?php
$q = "ЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖЖ";

even though it only contains 68 characters (and PSR2 requires line lengths to be under 120 chars).

See AtomLinter/linter-phpcs#228 and AtomLinter/linter-phpcs#233 for possible fix. Those PRs got eventually reverted, since Atom's linter feeds the text to PHPCS via stdin, but they are are relevant for your project because you pass file paths to PHPCS.

Add label to extension message

Request:
When you have more then one lint-type extension populating the Problems panel, having them label helps know where that message is coming from. This is helpful when you are first starting out and are still trying to determine what sort of rules you want them to be running. It also becomes annoying when more then one linter is unlabeled and you are looking to change the rules it runs.

linter.js: PhpcsPathResolver 3rd line up - message: ${message.message}
just need to concat a string in front, such as "CS: " || "PHPCS: " || "phpCS: "

1.3.x - phpcs: Unable to locate phpcs. Please add phpcs to your global path or use composer depency manager to install it in your project locally.

Works fine on version 1.2.x, but shortly after update to above version, vscode no longer detect/locate phpcs. Global path configure properly, on default setting, hardcode setting to absolute path, I try everything, nothing works.

Output from Developer Tools:

phpcs: Unable to locate phpcs. Please add phpcs to your global path or use composer depency manager to install it in your project locally.
    e.doShow                  @ messageService.ts:119
    e.show                    @ messageService.ts:103
    (anonymous function)      @ mainThreadMessageService.ts:53
    i.Class.derive._oncancel  @ winjs.base.raw.js:1641
    e.$showMessage            @ mainThreadMessageService.ts:23
    e.handle                  @ abstractThreadService.ts:34
    s                         @ ipcRemoteCom.ts:269
    f                         @ ipcRemoteCom.ts:226
    _combinedTickCallback     @ internal/process/next_tick.js:67
    _tickCallback             @ internal/process/next_tick.js:98

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.