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

Bug in lint method of the PhpcsLinter class #128

Open
Blake-C opened this issue Sep 2, 2018 · 1 comment
Open

Bug in lint method of the PhpcsLinter class #128

Blake-C opened this issue Sep 2, 2018 · 1 comment

Comments

@Blake-C
Copy link

Blake-C commented Sep 2, 2018

If a user has <arg name="basepath" value="./"/> in their phpcs.xml file the dictionary look up on line 216 will lookup the wrong file.

if (filePath !== undefined && semver.gte(this.executableVersion, '2.0.0')) {
	const fileRealPath = extfs.realpathSync(filePath);
	if (!data.files[fileRealPath]) {
		return [];
	}
	({ messages } = data.files[fileRealPath]);
}

File path given with <arg name="basepath" value="./"/>:
screen shot 2018-09-01 at 11 17 04 pm

File path being looked up:
screen shot 2018-09-01 at 11 17 40 pm

Meta:
VSCode: Version 1.26.1 (1.26.1)
macOS: 10.13.6 High Sierra
PHP CodeSniffer: 3.2.3
vscode-phpcs: 1.0.5

@shadyvb
Copy link

shadyvb commented Dec 28, 2019

For the lazy, and until the associated PR is fixed, this is a one-liner to fix this based on @Blake-C PR in #129 :

curl https://gist.githubusercontent.com/shadyvb/585ff8666f55f206c7fdbd11cee128d5/raw/f48e3fee4ce4f4d264f20e76a7e64429811ca9d2/vscode-phpcs-ext-basepath-fix.patch | patch ~/.vscode/extensions/ikappas.phpcs-1.0.5/server/src/linter.js

The patch being applied can be viewed at https://gist.githubusercontent.com/shadyvb/585ff8666f55f206c7fdbd11cee128d5/raw/f48e3fee4ce4f4d264f20e76a7e64429811ca9d2/vscode-phpcs-ext-basepath-fix.patch, given the extension is saved to ~/.vscode/extensions

Thanks @Blake-C !

yukihiko-shinoda added a commit to yukihiko-shinoda/staticpress-s3 that referenced this issue Jun 18, 2020
Comment out basepath temporary for developing with Visual Studio Code.
@see ikappas/vscode-phpcs#128
@see ikappas/vscode-phpcs#132
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants