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/AbstractClassNamePrefix: improve code coverage #641

Conversation

rodrigoprimo
Copy link
Contributor

Description

This PR improves code coverage for the Generic.NamingConventions.AbstractClassNamePrefix sniff and removes an incorrect code comment.

Related issues/external references

Part of #146

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
    • This change is only breaking for integrators, not for external standards or end-users.
  • Documentation improvement

PR checklist

  • I have checked there is no other PR open for the same change.
  • I have read the Contribution Guidelines.
  • I grant the project the right to include and distribute the code under the BSD-3-Clause license (and I have the right to grant these rights).
  • I have added tests to cover my changes.
  • I have verified that the code complies with the projects coding standards.
  • [Required for new sniffs] I have added XML documentation for the sniff.

Copy link
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

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

Hi @rodrigoprimo, all good in principle, but can do with some fine-tuning still. See inline comments.

I'm also wondering if, while the test file is being touched anyway, some minor cleanup should be done ?

  • // error => // Error. (multiple times)
  • $var = 'abstract class IncorrectNameButOk'; => $var = 'abstract class TextStringsAreDisregarded'; (test isn't really testing anything, but I can see why it is there, so let's leave it in, but make it more descriptive)
  • abstract class abstractOkName => abstract class abstractOkCaseOfPrefixIsNotEnforced
  • class NameAbstractBar {} => class NotAnAbstractClassSoNoPrefixRequired {}

Also the $abstractVar = ''; and $abstracVar = ''; tests aren't testing anything, so could be removed.

@rodrigoprimo
Copy link
Contributor Author

Thanks for your review, @jrfnl. I replied to the inline comments and implemented the additional cleanup that you suggested. When you get a chance, could you please check this PR again?

Copy link
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

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

Thanks @rodrigoprimo ! Looking good.

I'm going to rebase the PR and squash a few commits before merging and I'll make a few more small tweaks to the tests to clean up even further.

@jrfnl
Copy link
Member

jrfnl commented Oct 25, 2024

@rodrigoprimo Actually, before I rebase & squash, would you like me to add a separate commit to show the additional tweaks I want to make ?

[Edit]: just give me a sign once you've had a chance to look at the additional changes. I'll merge after that.

@jrfnl jrfnl force-pushed the test-coverage-abstract-class-name-prefix branch from 82bb018 to 787bd71 Compare October 25, 2024 18:53
@rodrigoprimo
Copy link
Contributor Author

@jrfnl, I just checked the commits you added, and they look good to me. Thanks!

Doing this to be able to create tests with syntax errors in additional, separate test case files.
This sniff only listens to `T_CLASS`. It does not listen to
`T_ANON_CLASS`. So the removed code comment is incorrect. The if
condition is still valid to bail early when live coding, but it does not
ever apply to anonymous classes.
…ests

Test improvements:
* Adjust some existing tests to have comments and new lines in unexpected places.
* Adjust some existing tests to include extended classes and implemented interfaces.
* Add tests with `final` and `readonly` class modifier keywords.
* Make some tests more descriptive by making the class name reflect what is being tested.
* Add a few comments to pre-existing tests to clarify why they exist.
* Add a separate test case file with a live coding/parse error test.
* Remove some code snippets which weren't testing anything.

Clean up the test file:
* Remove redundant whitespace in the test case file.
* Use proper punctuation in comments in test case file.
@jrfnl jrfnl force-pushed the test-coverage-abstract-class-name-prefix branch from 787bd71 to b80228e Compare October 25, 2024 20:23
@jrfnl
Copy link
Member

jrfnl commented Oct 25, 2024

Rebased & cleaned up the commits. Merging once the build has passed.

@jrfnl jrfnl added this to the 3.11.0 milestone Oct 25, 2024
@jrfnl jrfnl merged commit 7185370 into PHPCSStandards:master Oct 25, 2024
41 checks passed
@jrfnl jrfnl deleted the test-coverage-abstract-class-name-prefix branch October 25, 2024 20:59
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