Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Generic/CamelCapsFunctionName: improve code coverage #642

Conversation

rodrigoprimo
Copy link
Contributor

Description

This PR improves code coverage for the Generic.NamingConventions.CamelCapsFunctionName sniff and makes the following minor changes to the sniff code:

  • Removes two incorrect code comments.
  • Update a code comment to better describe what it does.
  • Removes an unnecessary return; at the end of a method.

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.

@rodrigoprimo
Copy link
Contributor Author

Thanks for your review, @jrfnl! I just pushed a new commit implementing the changes that you suggested and this PR is ready for a final check.

* This sniff only listens to `T_FUNCTION`. It does not listen to
    `T_FN` or `T_CLOSURE`. So the inline code comments were incorrect. The if
    conditions are still valid to bail early when live coding, but they do not
    ever apply to closures or arrow functions (anymore - it was possible in the past though).
* The inline comments regarding leading underscores was inaccurate as the code
    removes all leading underscores, not just the first.
Doing this to be able to create tests with syntax errors on separate
files.
…essary return

The `return;` is unnecessary as the last statement in a method.

Test improvements:
* Add separate test case files with live coding/parse error tests.
* Add tests verifying sand safeguarding that the name of methods in interfaces is also checked.
* Add tests covering the public `strict` property which can be toggled from within rulesets.
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.

@rodrigoprimo All good. Thanks for making those updates.

I'll rebase & squash the fixup commits before merging.

@jrfnl jrfnl force-pushed the test-coverage-camel-caps-function-name branch from b73e136 to d59edc4 Compare October 29, 2024 05:17
@jrfnl jrfnl added this to the 3.11.0 milestone Oct 29, 2024
@jrfnl jrfnl merged commit 2fe2330 into PHPCSStandards:master Oct 29, 2024
41 checks passed
@jrfnl jrfnl deleted the test-coverage-camel-caps-function-name branch October 29, 2024 06:40
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants