Skip to content

Commit 89990e2

Browse files
committed
CONTRIBUTING: limit line length for readability
1 parent 68bb4dc commit 89990e2

File tree

1 file changed

+79
-35
lines changed

1 file changed

+79
-35
lines changed

.github/CONTRIBUTING.md

Lines changed: 79 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ Thank you for your interest in contributing to PHP_CodeSniffer!
66

77
## Reporting Bugs
88

9-
Please search the [open issues](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues) to see if your issue has been reported already and if so, comment in that issue if you have additional information, instead of opening a new one.
9+
Please search the [open issues](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues) to see if your issue has been reported
10+
already and if so, comment in that issue if you have additional information, instead of opening a new one.
1011

1112
Before reporting a bug, you should check what sniff an error is coming from.
1213
Running `phpcs` with the `-s` flag will show the name of the sniff for each error.
1314

14-
If the error code starts with anything other than `Generic`, `MySource`, `PEAR`, `PSR1`, `PSR2`, `PSR12`, `Squiz` or `Zend`, the error is likely coming from an external PHP_CodeSniffer standard.
15+
If the error code starts with anything other than `Generic`, `MySource`, `PEAR`, `PSR1`, `PSR2`, `PSR12`, `Squiz` or `Zend`,
16+
the error is likely coming from an external PHP_CodeSniffer standard.
1517
**Please report bugs for externally maintained sniffs to the appropriate repository.**
1618

17-
Bug reports containing a minimal code sample which can be used to reproduce the issue are highly appreciated as those are most easily actionable.
19+
Bug reports containing a minimal code sample which can be used to reproduce the issue are highly appreciated as those are most
20+
easily actionable.
1821

1922
:point_right: Reports which only include a _screenshot_ of the code will be closed without hesitation as not actionable.
2023

@@ -24,14 +27,17 @@ Bug reports containing a minimal code sample which can be used to reproduce the
2427
PHP_CodeSniffer is a developer tool and should generally not be used in a production environment.
2528

2629
Having said that, responsible disclosure of security issues is highly appreciated.
27-
Issues can be reported privately to the maintainers by opening a [Security vulnerability report](https://github.com/PHPCSStandards/PHP_CodeSniffer/security/advisories/new).
30+
Issues can be reported privately to the maintainers by opening a
31+
[Security vulnerability report](https://github.com/PHPCSStandards/PHP_CodeSniffer/security/advisories/new).
2832

2933

3034
### Support/Questions About Using PHP_CodeSniffer
3135

32-
Please read the [documentation in the wiki](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki) before opening an issue with a support question.
36+
Please read the [documentation in the wiki](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki) before opening an issue
37+
with a support question.
3338

34-
The [discussion forum](https://github.com/PHPCSStandards/PHP_CodeSniffer/discussions) or [StackOverflow](https://stackoverflow.com/questions/tagged/phpcodesniffer) are the appropriate places for support questions.
39+
The [discussion forum](https://github.com/PHPCSStandards/PHP_CodeSniffer/discussions) or
40+
[StackOverflow](https://stackoverflow.com/questions/tagged/phpcodesniffer) are the appropriate places for support questions.
3541

3642

3743
## Contributing Without Writing Code
@@ -43,16 +49,19 @@ We welcome bug triage.
4349
Bug triage is the action of verifying a reported bug is reproducible and is actually an issue.
4450
This includes checking whether the bug is something which should be fixed in **_this_** repository.
4551

46-
To find bugs which need triage, look for issues and PRs with the ["Status: triage"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20triage) label.
52+
To find bugs which need triage, look for issues and PRs with the
53+
["Status: triage"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20triage) label.
4754

4855
#### Typical bug triage tasks:
4956
* Verify whether the bug is reproducible with the given information.
5057
* Ask for additional information if it is not.
51-
* If you find the issue is reported to the wrong repo, ask the reporter to report it to the correct external standard repo and suggest closing the issue.
58+
* If you find the issue is reported to the wrong repo, ask the reporter to report it to the correct external standard repo
59+
and suggest closing the issue.
5260

5361
Additionally, for older issues:
5462
* Check whether an issue still exists or has been fixed in `master` since the issue was initially reported.
55-
* If it has been fixed, document (in a comment) which commit/PR was responsible for fixing the issue and suggest closing the ticket.
63+
* If it has been fixed, document (in a comment) which commit/PR was responsible for fixing the issue
64+
and suggest closing the ticket.
5665

5766

5867
### Testing Open Pull Requests
@@ -61,22 +70,27 @@ Testing pull requests to verify they fix the issue they are supposed to fix with
6170

6271
To get access to a PHPCS version which includes the patch from a pull request, you can:
6372
* Either use a git clone of the PHP_CodeSniffer repository and check out the PR.
64-
* Or download the PHAR file(s) for the PR, which is available from the [Test workflow](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/test.yml) as an artifact of the workflow run.
73+
* Or download the PHAR file(s) for the PR, which is available from the
74+
[Test workflow](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/test.yml)
75+
as an artifact of the workflow run.
6576
The PHAR files can be found on the summary page of the test workflow run for the PR.
6677
If the workflow has not been run (yet), the PHAR artifact may not be available (yet).
6778

6879
#### Typical test tasks:
6980
* Verify that the patch solves the originally reported problem.
7081
* Verify that the tests added in the PR fail without the fix and pass with the fix.
7182
* For a fix for false negatives: verify that the correct error message(s) are thrown by the patched code.
72-
* Run the patched PHPCS version against real codebases to see if the fix creates any side effects (new false positives/false negatives).
83+
* Run the patched PHPCS version against real codebases to see if the fix creates any side effects
84+
(new false positives/false negatives).
7385

7486

7587
### Writing sniff documentation
7688

77-
Sniffs in PHP_CodeSniffer should preferably be accompanied by documentation. There is currently still a lot of [documentation missing](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/148).
89+
Sniffs in PHP_CodeSniffer should preferably be accompanied by documentation. There is currently still a lot of
90+
[documentation missing](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/148).
7891

79-
Sniff documentation is provided via XML files in the standard's `Docs` directory and is available to end-users via the command-line and/or can be compiled into an HTML or Markdown file.
92+
Sniff documentation is provided via XML files in the standard's `Docs` directory and is available to end-users
93+
via the command-line and/or can be compiled into an HTML or Markdown file.
8094

8195
To see an example of some of the available documentation, run:
8296
```bash
@@ -95,11 +109,13 @@ The XML files consist of several parts:
95109
* The `title` attribute in the `<documentation>` tag should generally reflect the name of the sniff.
96110
* Each XML file can contain multiple `<standard>` blocks.
97111
* Each `<standard>` block can be accompanied by one or more `<code_comparison>` blocks.
98-
* Each code comparison block should have two `<code>` blocks, the first one showing "valid" code, the second one showing "invalid" code.
112+
* Each code comparison block should have two `<code>` blocks, the first one showing "valid" code, the second one
113+
showing "invalid" code.
99114

100115
Some guidelines to get you started:
101116
* Keep it as simple as possible.
102-
* When a sniff shows multiple different errors/warnings, it is recommended to have a separate `<standard>` block for each error/warning.
117+
* When a sniff shows multiple different errors/warnings, it is recommended to have a separate `<standard>` block
118+
for each error/warning.
103119
* The title of a "good" code sample (on the left) should start with `Valid:`.
104120
* The title of a "bad" code sample (on the right) should start with `Invalid:`.
105121
* Don't use example code which can be traced back to a specific project.
@@ -123,39 +139,52 @@ There are also tasks looking for contributions, which don't necessarily fall int
123139

124140
#### Issues marked with "Status: waiting for opinions"
125141

126-
Proposals for new features, proposals for (structural) changes to PHP_CodeSniffer itself or to the contributor workflow, will initially be marked with the ["Status: waiting for opinions"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20waiting%20for%20opinions) label.
142+
Proposals for new features, proposals for (structural) changes to PHP_CodeSniffer itself or to the contributor workflow,
143+
will initially be marked with the
144+
["Status: waiting for opinions"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20waiting%20for%20opinions)
145+
label.
127146

128147
This is an open invitation for interested parties to gather their thoughts about the issue and to leave their opinion.
129148

130-
> Kind request: If you don't have something to add to the discussion, but do want to indicate a positive or negative opinion on a topic, please add an emoji on the original post instead of leaving a comment.
149+
> Kind request: If you don't have something to add to the discussion, but do want to indicate a positive or negative opinion
150+
> on a topic, please add an emoji on the original post instead of leaving a comment.
131151
132152
#### Issues marked with "Status: needs investigation"
133153

134154
Sometimes an issue has been identified, but it has not yet been pinpointed what the exact cause of the problem is.
135155

136-
Other times, like with syntax changes in PHP itself, PHP_CodeSniffer _may_, or _may not_, handle them correctly and this will need verification.
156+
Other times, like with syntax changes in PHP itself, PHP_CodeSniffer _may_, or _may not_, handle them correctly
157+
and this will need verification.
137158

138-
Issues like these will be marked with the ["Status: needs investigation"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20needs%20investigation) and investigating those can be a good way to learn more about the source code of PHP_CodeSniffer.
159+
Issues like these will be marked with the
160+
["Status: needs investigation"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20needs%20investigation)
161+
and investigating those can be a good way to learn more about the source code of PHP_CodeSniffer.
139162

140163
#### Issues marked with "Status: help wanted"
141164

142-
If you don't know where to start, having a browse through issues marked with the ["Status: help wanted"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20help%20wanted) and/or the ["Status: good first issue"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20good%20first%20issue) labels.
165+
If you don't know where to start, having a browse through issues marked with the
166+
["Status: help wanted"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20help%20wanted) and/or the
167+
["Status: good first issue"](https://github.com/PHPCSStandards/PHP_CodeSniffer/labels/Status%3A%20good%20first%20issue) labels.
143168

144169

145170
## Contributing With Code
146171

147172
### Requesting/Submitting New Features
148173

149-
Ideally, start by [opening an issue](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/new/choose) to check whether the feature is something which is suitable to be included in PHP_CodeSniffer.
174+
Ideally, start by [opening an issue](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/new/choose) to check whether
175+
the feature is something which is suitable to be included in PHP_CodeSniffer.
150176

151177
It's possible that a feature may be rejected at an early stage, and it's better to find out before you write the code.
152178

153-
It is also good to discuss potential different implementation options ahead of time and get guidance for the preferred option from the maintainers.
179+
It is also good to discuss potential different implementation options ahead of time and get guidance for the preferred option
180+
from the maintainers.
154181

155-
Note: There may be an issue or PR open already. If so, please join the discussion in that issue or PR instead of opening a duplicate issue/PR.
182+
Note: There may be an issue or PR open already. If so, please join the discussion in that issue or PR instead of opening
183+
a duplicate issue/PR.
156184

157185
> Please note: Auto-fixers will only be accepted for "non-risky" sniffs.
158-
> If a fixer could cause parse errors or a change in the behaviour of the scanned code, the fixer will **NOT** be accepted in PHP_CodeSniffer and may be better suited to an external standard.
186+
> If a fixer could cause parse errors or a change in the behaviour of the scanned code, the fixer will **NOT** be accepted
187+
> in PHP_CodeSniffer and may be better suited to an external standard.
159188
160189

161190
### Getting started
@@ -168,7 +197,8 @@ Note: There may be an issue or PR open already. If so, please join the discussio
168197

169198
### While working on a patch
170199

171-
Please make sure your code conforms to the PHPCS coding standard, is covered by tests and that all the PHP_CodeSniffer unit tests still pass.
200+
Please make sure your code conforms to the PHPCS coding standard, is covered by tests and that all the PHP_CodeSniffer
201+
unit tests still pass.
172202

173203
Also, please make sure your code is compatible with the PHP_CodeSniffer minimum supported PHP version, PHP 5.4.
174204

@@ -178,7 +208,8 @@ To help you with this, a number of convenience scripts are available:
178208
* `composer cbf` will run the autofixers for code style violations.
179209
* `composer test` will run the unit tests.
180210
* `composer coverage` will run the unit tests with code coverage and show a text summary.
181-
* `composer coverage-local` will run the unit tests with code coverage and generate an HTML coverage report, which will be placed in a `build/coverage-html` subdirectory.
211+
* `composer coverage-local` will run the unit tests with code coverage and generate an HTML coverage report,
212+
which will be placed in a `build/coverage-html` subdirectory.
182213
* `composer build` will build the phpcs.phar and phpcbf.phar files.
183214

184215
N.B.: You can ignore any skipped tests as these are for external tools.
@@ -195,28 +226,39 @@ For example, for the sniff named `Generic.NamingConventions.ConstructorName`:
195226
* The sniff lives in the `src/Standards/Generic/Sniffs/NamingConventions/` directory.
196227
* The tests live in the `src/Standards/Generic/Tests/NamingConventions/` directory.
197228
* The tests consist of two files:
198-
- `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc` which is the test _case_ file containing code for the sniff to analyse.
199-
- `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php` which is the test file, containing two methods, `getErrorList()` and `getWarningList()`, which should each return an array with as the keys the line number in the test _case_ file and as the values the number of errors or warnings which are expected on each line.
200-
Only lines on which errors/warnings are expected need to be included in the lists. All other lines will automatically be set to expect no errors and no warnings.
229+
- `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc` which is the test _case_ file containing
230+
code for the sniff to analyse.
231+
- `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.php` which is the test file, containing two methods,
232+
`getErrorList()` and `getWarningList()`, which should each return an array with as the keys the line number
233+
in the test _case_ file and as the values the number of errors or warnings which are expected on each line.
234+
Only lines on which errors/warnings are expected need to be included in the lists. All other lines will automatically
235+
be set to expect no errors and no warnings.
201236

202237
#### Multiple test case files
203238

204-
At times, one test _case_ file is not enough, for instance when the sniff needs to behave differently depending on whether or code is namespaced or not, or when a sniff needs to check something at the top of a file.
239+
At times, one test _case_ file is not enough, for instance when the sniff needs to behave differently depending on whether or code
240+
is namespaced or not, or when a sniff needs to check something at the top of a file.
205241

206242
The test framework allows for multiple test _case_ files.
207243
In that case, the files should be numbered and the number should be placed between the file name and the extension.
208244

209-
So for the above example, the `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc` would be renamed to `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.1.inc` and additional test case files should be numbered sequentially like `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.2.inc`, `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.3.inc` etc.
245+
So for the above example, the `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc` would be renamed to
246+
`src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.1.inc` and additional test case files should be numbered
247+
sequentially like `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.2.inc`,
248+
`src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.3.inc` etc.
210249

211-
The `getErrorList()` and the `getWarningList()` methods will receive an optional `$testFile=''` parameter with the file name of the file being scanned - `ConstructorNameUnitTest.2.inc` - and should return the appropriate array for each file.
250+
The `getErrorList()` and the `getWarningList()` methods will receive an optional `$testFile=''` parameter with the file name
251+
of the file being scanned - `ConstructorNameUnitTest.2.inc` - and should return the appropriate array for each file.
212252

213253
#### Testing fixers
214254

215255
If a sniff contains errors/warnings which can be auto-fixed, these fixers should also be tested.
216256

217257
This is done by adding a test _case_ file with an extra `.fixed` extension for each test _case_ file which expects fixes.
218258

219-
For example, if the above `Generic.NamingConventions.ConstructorName` would contain an auto-fixer, there should be an additional `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc.fixed` file containing the code as it is expected to be after the fixer has run.
259+
For example, if the above `Generic.NamingConventions.ConstructorName` would contain an auto-fixer, there should be an
260+
additional `src/Standards/Generic/Tests/NamingConventions/ConstructorNameUnitTest.inc.fixed` file containing the code
261+
as it is expected to be after the fixer has run.
220262

221263
The test framework will compare the actual fixes made with the expected fixes and will fail the tests if these don't match.
222264

@@ -226,7 +268,8 @@ Some guidelines for submitting pull requests (PRs) and improving the chance that
226268
* Please keep your PR as small as possible, but no smaller than that.
227269
If your change is complex, make sure you add a proper commit message explaining what you have done and why.
228270
* Please clean up your branch before pulling your PR.
229-
Small PRs using atomic, descriptive commits are hugely appreciated as it will make reviewing your changes easier for the maintainers.
271+
Small PRs using atomic, descriptive commits are hugely appreciated as it will make reviewing your changes
272+
easier for the maintainers.
230273
* Only open your PR when you've finished work on it, and you are confident that it is ready for review.
231274
* Please make sure your pull request passes all continuous integration checks.
232275
PRs which are failing their CI checks will likely be ignored by the maintainers or closed.
@@ -237,4 +280,5 @@ However, the maintainers time is also valuable and often, more scarce, so please
237280

238281
## Licensing
239282

240-
By contributing code to this repository, you agree to license your code for use under the [BSD-3-Clause license](https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt).
283+
By contributing code to this repository, you agree to license your code for use under the
284+
[BSD-3-Clause license](https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt).

0 commit comments

Comments
 (0)