Skip to content

Add TOC to contribution instructions #2697

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

Merged
merged 1 commit into from
Apr 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ visit the `#clippy` IRC channel on `irc.mozilla.org`.

All contributors are expected to follow the [Rust Code of Conduct](http://www.rust-lang.org/conduct.html).

* [Getting started](#getting-started)
* [Finding something to fix/improve](#finding-something-to-fiximprove)
* [Writing code](#writing-code)
* [Author lint](#author-lint)
* [Documentation](#documentation)
* [Running test suite](#running-test-suite)
* [Testing manually](#testing-manually)
* [How Clippy works](#how-clippy-works)
* [Contributions](#contributions)

## Getting started

High level approach:
Expand Down Expand Up @@ -48,7 +58,7 @@ be more involved and require verifying types. The
lot of methods that are useful, though one of the most useful would be `expr_ty` (gives the type of
an AST expression). `match_def_path()` in Clippy's `utils` module can also be useful.

### Writing code
## Writing code

Compiling clippy from scratch can take almost a minute or more depending on your machine.
However, since Rust 1.24.0 incremental compilation is enabled by default and compile times for small changes should be quick.
Expand All @@ -59,7 +69,7 @@ to lint-writing, though it does get into advanced stuff. Most lints consist of a
of this.


#### Author lint
### Author lint

There is also the internal `author` lint to generate clippy code that detects the offending pattern. It does not work for all of the Rust syntax, but can give a good starting point.

Expand Down Expand Up @@ -96,7 +106,7 @@ if_chain! {

If the command was executed successfully, you can copy the code over to where you are implementing your lint.

#### Documentation
### Documentation

Please document your lint with a doc comment akin to the following:

Expand All @@ -122,18 +132,20 @@ Once your lint is merged it will show up in the [lint list](https://rust-lang-nu

### Running test suite

Clippy uses UI tests. UI tests check that the output of the compiler is exactly as expected.
Of course there's little sense in writing the output yourself or copying it around.
Therefore you can simply run `tests/ui/update-all-references.sh` (after running
`cargo test`) and check whether the output looks as you expect with `git diff`. Commit all
`*.stderr` files, too.
Use `cargo test` to run the whole testsuite.

If you don't want to wait for all tests to finish, you can also execute a single test file by using `TESTNAME` to specify the test to run:

```bash
TESTNAME=ui/empty_line_after_outer_attr cargo test --test compile-test
```

Clippy uses UI tests. UI tests check that the output of the compiler is exactly as expected.
Of course there's little sense in writing the output yourself or copying it around.
Therefore you should use `tests/ui/update-all-references.sh` (after running
`cargo test`) and check whether the output looks as you expect with `git diff`. Commit all
`*.stderr` files, too.

### Testing manually

Manually testing against an example file is useful if you have added some
Expand Down