-
-
Notifications
You must be signed in to change notification settings - Fork 57
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/AssignmentInCondition: improve sniff code coverage #163
Generic/AssignmentInCondition: improve sniff code coverage #163
Conversation
8ac9a3e
to
225c9cf
Compare
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 with only one small remark. Will merge it once that's been fixed up. (Feel free to just amend the existing commit) Thanks @rodrigoprimo !
src/Standards/Generic/Tests/CodeAnalysis/AssignmentInConditionUnitTest.php
Outdated
Show resolved
Hide resolved
Doing this to be able to add more test case files to cover defensive code in the AssignmentInCondition sniff that protects it when checking code with parse errors.
This commit improves the test coverage for the AssignmentInCondition sniff by adding a few more test case files to exercise the parts of the sniff code that checks for invalid syntax.
225c9cf
to
1fad6ab
Compare
Thanks for reviewing this PR, @jrfnl. I implemented the change you requested and I believe it is now ready to be merged. |
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! Thanks @rodrigoprimo.
Replacing the default value with an empty string. Per Juliette's comment (PHPCSStandards#163 (comment)) there are three reasons why we want to do that: - The default value has no value in practice. It is an optional argument which is not enforced via the abstract functions, but is passed in all cases, so the default is never used in practice. - Setting the default value as file 1 also has an assumption implied, while IMO assumptions have no place in a test suite. - Maintainability - one less thing to have to keep in sync and to guard against typos
Replacing the default value with an empty string. Per Juliette's comment (PHPCSStandards#163 (comment)) there are three reasons why we want to do that: - The default value has no value in practice. It is an optional argument which is not enforced via the abstract functions, but is passed in all cases, so the default is never used in practice. - Setting the default value as file 1 also has an assumption implied, while IMO assumptions have no place in a test suite. - Maintainability - one less thing to have to keep in sync and to guard against typos
Replacing the default value with an empty string. Per Juliette's comment (#163 (comment)) there are three reasons why we want to do that: - The default value has no value in practice. It is an optional argument which is not enforced via the abstract functions, but is passed in all cases, so the default is never used in practice. - Setting the default value as file 1 also has an assumption implied, while IMO assumptions have no place in a test suite. - Maintainability - one less thing to have to keep in sync and to guard against typos
Replacing the default value with an empty string. Per Juliette's comment (#163 (comment)) there are three reasons why we want to do that: - The default value has no value in practice. It is an optional argument which is not enforced via the abstract functions, but is passed in all cases, so the default is never used in practice. - Setting the default value as file 1 also has an assumption implied, while IMO assumptions have no place in a test suite. - Maintainability - one less thing to have to keep in sync and to guard against typos
Replacing the default value with an empty string. Per Juliette's comment (PHPCSStandards#163 (comment)) there are three reasons why we want to do that: - The default value has no value in practice. It is an optional argument which is not enforced via the abstract functions, but is passed in all cases, so the default is never used in practice. - Setting the default value as file 1 also has an assumption implied, while IMO assumptions have no place in a test suite. - Maintainability - one less thing to have to keep in sync and to guard against typos
Replacing the default value with an empty string. Per Juliette's comment (PHPCSStandards#163 (comment)) there are three reasons why we want to do that: - The default value has no value in practice. It is an optional argument which is not enforced via the abstract functions, but is passed in all cases, so the default is never used in practice. - Setting the default value as file 1 also has an assumption implied, while IMO assumptions have no place in a test suite. - Maintainability - one less thing to have to keep in sync and to guard against typos
Description
This PR improves the code coverage for the AssignementInCondition sniff. This sniff has some defensive code to protect against parse errors, and those were not exercised by the tests. I followed the instructions on #143 for creating parse error tests.
I also checked if there are new assignment operators added in more recent versions of PHP that are not supported by this sniff, but I did not find anything.
Suggested changelog entry
Improve AssignementInCondition sniff code coverage
Related issues/external references
Part of #146
Types of changes
PR checklist