Skip to content

Commit f6965ee

Browse files
GaryJonesdingo-d
andauthored
Update CONTRIBUTING.md with tips for successful PRs (#2598)
* Update CONTRIBUTING.md heading levels to aid navigation * Add guidelines for successful PRs in CONTRIBUTING.md --------- Co-authored-by: Denis Žoljom <dingo-d@users.noreply.github.com>
1 parent 6e6883b commit f6965ee

File tree

1 file changed

+36
-13
lines changed

1 file changed

+36
-13
lines changed

.github/CONTRIBUTING.md

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
# Contributing to the WordPress Coding Standards
2+
13
Hi, thank you for your interest in contributing to the WordPress Coding Standards! We look forward to working with you.
24

3-
# Reporting Bugs
5+
## Reporting Bugs
46

57
Please search the repo to see if your issue has been reported already and if so, comment in that issue instead of opening a new one.
68

@@ -9,35 +11,56 @@ Running `phpcs` with the `-s` flag will show the name of the sniff with each err
911

1012
Bug reports containing a minimal code sample which can be used to reproduce the issue are highly appreciated as those are most easily actionable.
1113

12-
## Upstream Issues
14+
### Upstream Issues
1315

1416
Since WordPressCS employs many sniffs that are part of PHP_CodeSniffer itself or PHPCSExtra, sometimes an issue will be caused by a bug in PHPCS or PHPCSExtra and not in WordPressCS itself.
1517
If the error message in question doesn't come from a sniff whose name starts with `WordPress`, the issue is probably a bug in PHPCS or PHPCSExtra.
1618

1719
* Bugs for sniffs starting with `Generic`, `PEAR`, `PSR1`, `PSR2`, `PSR12`, `Squiz` or `Zend` should be [reported to PHPCS](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues).
1820
* Bugs for sniffs starting with `Modernize`, `NormalizedArrays` or `Universal` should be [reported to PHPCSExtra](https://github.com/PHPCSStandards/PHPCSExtra/issues).
1921

20-
# Contributing patches and new features
22+
## Contributing patches and new features
23+
24+
### Tips for Successful PRs
25+
26+
We welcome contributions from everyone, and want your PR to have the best chance of being reviewed and merged. To help with this, please keep the following in mind:
27+
28+
* **Respect copyright and licensing.**
29+
Only submit code that you have written yourself or that comes from sources where the license clearly allows inclusion. Submitting code that infringes on copyright or licensing terms puts both you and the project at legal risk, and such contributions cannot be accepted.
30+
31+
* **Do not submit AI-generated code.**
32+
Pull requests containing AI-generated code are not acceptable. Beyond copyright and licensing uncertainties, AI-generated contributions consistently require disproportionate amounts of maintainer time to review, correct, or rewrite. This wastes limited project resources and slows progress for everyone. Submitting AI-generated code may be treated as a violation of our [Code of Conduct](../CODE_OF_CONDUCT.md).
33+
34+
* **Focus on quality and clarity.**
35+
Take time to explain *why* the change is needed, and include tests or examples where appropriate. Clear, self-written explanations make it more straightforward for reviewers to understand what you are trying to achieve.
36+
37+
* **Think about long-term maintainability.**
38+
Code should align with WordPress Coding Standards and be written in a way that others can readily read, understand, and maintain.
39+
40+
* **Be collaborative.**
41+
If you're unsure about an approach, open an issue first to start a conversation.
42+
43+
By following these tips, you'll save time for both yourself and the maintainers — and increase the likelihood that your contribution can be merged smoothly.
2144

22-
## Branches
45+
### Branches
2346

2447
Ongoing development will be done in the `develop` branch with merges to `main` once considered stable.
2548

2649
To contribute an improvement to this project, fork the repo, run `composer install`, make your changes to the code, run the unit tests and code style checks by running `composer check-all`, and if all is good, open a pull request to the `develop` branch.
2750
Alternatively, if you have push access to this repo, create a feature branch prefixed by `feature/` and then open an intra-repo PR from that branch to `develop`.
2851

29-
# Considerations when writing sniffs
52+
## Considerations when writing sniffs
3053

31-
## Public properties
54+
### Public properties
3255

3356
When writing sniffs, always remember that any `public` sniff property can be overruled via a custom ruleset by the end-user.
3457
Only make a property `public` if that is the intended behavior.
3558

3659
When you introduce new `public` sniff properties, or your sniff extends a class from which you inherit a `public` property, please don't forget to update the [public properties wiki page](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties) with the relevant details once your PR has been merged into the `develop` branch.
3760

38-
# Unit Testing
61+
## Unit Testing
3962

40-
## Pre-requisites
63+
### Pre-requisites
4164
* WordPress-Coding-Standards
4265
* PHP_CodeSniffer 3.13.0 or higher
4366
* PHPCSUtils 1.1.0 or higher
@@ -46,11 +69,11 @@ When you introduce new `public` sniff properties, or your sniff extends a class
4669

4770
The WordPress Coding Standards use the `PHP_CodeSniffer` native unit test framework for unit testing the sniffs.
4871

49-
## Getting ready to test
72+
### Getting ready to test
5073

5174
Presuming you have cloned WordPressCS for development, to run the unit tests you need to make sure you have run `composer install` from the root directory of your WordPressCS git clone.
5275

53-
## Custom develop setups
76+
### Custom develop setups
5477

5578
If you are developing with a stand-alone PHP_CodeSniffer (git clone) installation and want to use that git clone to test WordPressCS, there are three extra things you need to do:
5679
1. Install [PHPCSUtils](https://github.com/PHPCSStandards/PHPCSUtils).
@@ -73,7 +96,7 @@ If you are developing with a stand-alone PHP_CodeSniffer (git clone) installatio
7396
</php>
7497
```
7598
76-
## Running the unit tests
99+
### Running the unit tests
77100
78101
From the root of your WordPressCS install, run the unit tests like so:
79102
```bash
@@ -99,7 +122,7 @@ Time: 10.19 seconds, Memory: 40.00 MB
99122
OK (57 tests, 0 assertions)
100123
```
101124
102-
## Unit Testing conventions
125+
### Unit Testing conventions
103126
104127
If you look inside the `WordPress/Tests` subdirectory, you'll see the structure mimics the `WordPress/Sniffs` subdirectory structure. For example, the `WordPress/Sniffs/PHP/POSIXFunctionsSniff.php` sniff has its unit test class defined in `WordPress/Tests/PHP/POSIXFunctionsUnitTest.php` which checks the `WordPress/Tests/PHP/POSIXFunctionsUnitTest.inc` test case file. See the file naming convention?
105128

@@ -171,6 +194,6 @@ You'll see the line number and number of ERRORs we need to return in the `getErr
171194

172195
The `--sniffs=...` directive limits the output to the sniff you are testing.
173196

174-
## Code Standards for this project
197+
### Code Standards for this project
175198

176199
The sniffs and test files - not test _case_ files! - for WordPressCS should be written such that they pass the `WordPress-Extra` and the `WordPress-Docs` code standards using the custom ruleset as found in `/.phpcs.xml.dist`.

0 commit comments

Comments
 (0)