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

Generic/OpeningFunctionBraceKernighanRitchie: improve error message #736

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Nov 27, 2024

Description

Follow up on #707

When there are multiple tabs between the end of the function signature and the open brace, the "found: $length" part of the error message would refer to the number of tabs found.

This is inconsistent with other sniffs and confusing.

This commit fixes this, while still maintaining the previous behaviour - as introduced via squizlabs/PHP_CodeSniffer@c4b9807 - of special casing the messaging for a single tab - independently of whether or not tab replacement is in effect.

Example for line 10 of test case file 2:

// Before:
Expected 1 space before opening brace; found 3

// After:
Expected 1 space before opening brace; found 11

Covered via pre-existing tests in both test case files + some additional new tests.

Suggested changelog entry

Generic.Functions.OpeningFunctionBraceKernighanRitchie: minor improvement to the error message wording

Follow up on 707

When there are multiple tabs between the end of the function signature and the open brace, the "found: $length" part of the error message would refer to the number of tabs found.

This is inconsistent with other sniffs and confusing.

This commit fixes this, while still maintaining the previous behaviour - as introduced via squizlabs/PHP_CodeSniffer@c4b9807 - of special casing the messaging for a single tab - independently of whether or not tab replacement is in effect.

Example for line 10 of test case file 2:
```
// Before:
Expected 1 space before opening brace; found 3

// After:
Expected 1 space before opening brace; found 11
```

Covered via pre-existing tests in both test case files + some additional new tests.
@jrfnl jrfnl merged commit 778f533 into master Nov 27, 2024
59 checks passed
@jrfnl jrfnl deleted the feature/generic-openingfunctionbracekernighanritchie-improve-tab-handling branch November 27, 2024 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants