Skip to content

Update CONTRIBUTING.md to include Simplecov #2035

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
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
31 changes: 31 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,37 @@ We are running [mdformat](https://github.com/executablebooks/mdformat) for forma
$ mdformat . --number
```

### Test Coverage - Line and Branch

We are using [Simplecov](https://github.com/colszowka/simplecov) to track test coverage.

It is included and reported when you run `bundle exec rake` or `bundle exec rspec`.

To view the coverage report, open the `coverage/index.html` file in your browser.

E.g. on macOS:

```console
$ open coverage/index.html
```

If you have unreachable lines, you can add `# :nocov` around those lines. The code itself or a comment should explain why the line is unreachable.

Example:

```ruby
# :nocov:
raise ArgumentError("Unsupported style :#{style}")
# :nocov:
```

This can happen for a few reasons, including:

1. When you handle config with a case statement and there is no else block.
2. When matching with a node pattern even when you handle all cases: all other node types will be excluded before reaching your handler, because the node pattern will not match them.

You will need full line and branch coverage to merge. This helps detect edge cases and prevent errors.

## Creating new cops

- Document examples of good and bad code in your cop.
Expand Down