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

Is it possible for tests to check which lines contained the error? #48

Open
bmitch opened this issue Dec 20, 2016 · 5 comments
Open

Is it possible for tests to check which lines contained the error? #48

bmitch opened this issue Dec 20, 2016 · 5 comments

Comments

@bmitch
Copy link
Owner

bmitch commented Dec 20, 2016

No description provided.

@winkbrace
Copy link

Yeah, the line number is the key of the _errors array in PHP_CodeSniffer_File.

If you replace the foreach loop in the \Codor\Tests\Wrappers\Results::getAllErrorMessages() method like this:

foreach ($errors as $line => $error) {
    $allErrorMessages[] = "Error at line $line: " . reset($error)[0]['message'];
}

The output becomes this:

[
  0 => "Error at line 5: Return null value found."
  1 => "Error at line 21: Return null value found."
]

@winkbrace
Copy link

Hmm, I just realised that you're logging the error with the $stackPtr of the scope start, not the index of the actual token that has an error. Currently error messages point to the start of functions instead of the actual line that contains the error.

I've updated my last PR to report return null errors with the correct stack pointer.

@bmitch
Copy link
Owner Author

bmitch commented Dec 30, 2016

Thanks, I'll take a look at this in the next few days when I have time. But if you feel like tackling it please go ahead.

@winkbrace
Copy link

I think you should have a look at it first. The error messages would change with that implementation.
And maybe you want to do something different with the lines.

Anyway, I'm on vacation starting now, so won't be programming (much) the coming week.
Have a good new year! ;)

@bmitch
Copy link
Owner Author

bmitch commented Dec 30, 2016

OK thanks. You too!

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

No branches or pull requests

2 participants