-
-
Notifications
You must be signed in to change notification settings - Fork 89
Common::getSniffCode(): add tests, more defensive coding and minor simplification #524
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
Conversation
rodrigoprimo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
86982b0 to
659becb
Compare
|
Rebased without changes. |
Add initial set of tests for the `Common::getSniffCode()` method. Related to 146 Related to [review comment in PR 446](#446 (comment)).
Previously, if an empty string was passed, the `Common::getSniffCode()` method would return `..`, which is just confusing (and incorrect). This commit changes the behaviour to throw an `InvalidArgumentException` instead. Includes making a potentially superfluous function call to the method conditionally (as it could hit the new exception). Includes test.
Previously, if an invalid (incomplete) class name was passed, the `Common::getSniffCode()` method would return a garbled name, like `.Qualified.C`, which is just confusing. This commit changes the behaviour to throw an `InvalidArgumentException` instead. Includes test.
Previously, if an invalid class name was passed, which didn't end on `Sniff` or `UnitTest`, the `Common::getSniffCode()` method would return a garbled name, like `Fully.Qualified.C`, which is just confusing. This commit changes the behaviour to throw an `InvalidArgumentException` instead. Includes test.
* Remove the use of `array_pop()` in favour of directly referencing the required "parts" by their index in the array. * Remove the unused `$sniffDir` variable. * Remove the unnecessary `$code` variable. Related to [review comment in PR 446](#446 (comment)).
659becb to
7449b29
Compare
|
Forwarded to #675 |
|
@williamdes I'd need to see the code of the |
Sure, thank you for responding so quickly. |
Description
Common::getSniffCode(): add tests
Add initial set of tests for the
Common::getSniffCode()method.Related to #146
Related to review comment in PR 446.
Common::getSniffCode(): throw exception on invalid input [1]
Previously, if an empty string was passed, the
Common::getSniffCode()method would return.., which is just confusing.This commit changes the behaviour to throw an
InvalidArgumentExceptioninstead.Includes making a potentially superfluous function call to the method conditionally (as it could hit the new exception).
Includes test.
Common::getSniffCode(): throw exception on invalid input [2a]
Previously, if an invalid (incomplete) class name was passed, the
Common::getSniffCode()method would return a garbled name, like.Qualified.C, which is just confusing.This commit changes the behaviour to throw an
InvalidArgumentExceptioninstead.Includes test.
Common::getSniffCode(): throw exception on invalid input [2b]
Previously, if an invalid class name was passed, which didn't end on
SnifforUnitTest, theCommon::getSniffCode()method would return a garbled name, likeFully.Qualified.C, which is just confusing.This commit changes the behaviour to throw an
InvalidArgumentExceptioninstead.Includes test.
Common::getSniffCode(): minor simplification
array_pop()in favour of directly referencing the required "parts" by their index in the array.$sniffDirvariable.$codevariable.Related to review comment in PR 446.
Suggested changelog entry
The
Common::getSniffCode()method will now throw anInvalidArgumentExceptionexception if an invalid$sniffClassis passed.