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

Fix fileRealPath files lookup in data.files #1

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions phpcs-server/src/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,16 @@ export class PhpcsLinter {

let messages: Array<PhpcsMessage>;
if (filePath !== undefined && semver.gte(this.executableVersion, '2.0.0')) {
const fileRealPath = extfs.realpathSync(filePath);
if (!data.files[fileRealPath]) {
const { files, totals } = data;

if (!totals.errors && !totals.warnings) {
return [];
}
({ messages } = data.files[fileRealPath]);

let file: any;
for (file of Object.entries(files)) {
({ messages } = file[1]);
};
} else {
// PHPCS v1 can't associate a filename with STDIN input
if (!data.files.STDIN) {
Expand All @@ -232,7 +237,7 @@ export class PhpcsLinter {

private parseData(text: string) {
try {
return JSON.parse(text) as { files: any };
return JSON.parse(text) as { files: any, totals: any };
} catch (error) {
throw new Error(SR.InvalidJsonStringError);
}
Expand Down
6 changes: 4 additions & 2 deletions phpcs-server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"lib": [ "es2016" ],
"lib": [
"es2017"
],
"outDir": "../phpcs/server"
},
"exclude": [
"node_modules"
]
}
}