Skip to content

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Jun 5, 2024

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 InvalidArgumentException instead.

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 InvalidArgumentException instead.

Includes test.

Common::getSniffCode(): throw exception on invalid input [2b]

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.

Common::getSniffCode(): minor simplification

  • 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.

Suggested changelog entry

The Common::getSniffCode() method will now throw an InvalidArgumentException exception if an invalid $sniffClass is passed.

Copy link
Contributor

@rodrigoprimo rodrigoprimo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jrfnl jrfnl modified the milestones: 3.10.x Next, 3.11.0 Jun 28, 2024
@jrfnl jrfnl force-pushed the feature/common-add-tests-and-simplify branch from 86982b0 to 659becb Compare September 18, 2024 12:18
@jrfnl
Copy link
Member Author

jrfnl commented Sep 18, 2024

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)).
@jrfnl jrfnl force-pushed the feature/common-add-tests-and-simplify branch from 659becb to 7449b29 Compare September 29, 2024 23:31
@jrfnl jrfnl merged commit 78ecda4 into master Sep 29, 2024
48 checks passed
@jrfnl jrfnl deleted the feature/common-add-tests-and-simplify branch September 29, 2024 23:59
@williamdes
Copy link

williamdes commented Nov 12, 2024

Forwarded to #675

@jrfnl
Copy link
Member Author

jrfnl commented Nov 12, 2024

@williamdes I'd need to see the code of the JsonSniff to figure out what's going on. Is it accessible somewhere ? Also, could you please open an issue about this with information on how I can reproduce the issue ?

@williamdes
Copy link

@williamdes I'd need to see the code of the JsonSniff to figure out what's going on. Is it accessible somewhere ? Also, could you please open an issue about this with information on how I can reproduce the issue ?

Sure, thank you for responding so quickly.
I posted a trim down sample on #675

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