Skip to content

Commit a7da808

Browse files
committed
Update CONTRIBUTING.md to include Simplecov
1 parent 27e37d5 commit a7da808

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

.github/CONTRIBUTING.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,37 @@ We are running [mdformat](https://github.com/executablebooks/mdformat) for forma
5151
$ mdformat . --number
5252
```
5353

54+
### Test Coverage - Line and Branch
55+
56+
We are using [Simplecov](https://github.com/colszowka/simplecov) to track test coverage.
57+
58+
It is included and reported when you run `bundle exec rake` or `bundle exec rspec`.
59+
60+
To view the coverage report, open the `coverage/index.html` file in your browser.
61+
62+
E.g. on macOS:
63+
64+
```console
65+
$ open coverage/index.html
66+
```
67+
68+
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.
69+
70+
Example:
71+
72+
```ruby
73+
# :nocov:
74+
raise ArgumentError("Unsupported style :#{style}")
75+
# :nocov:
76+
```
77+
78+
This can happen for a few reasons, including:
79+
80+
1. When you handle config with a case statement and there is no else block.
81+
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.
82+
83+
You will need full line and branch coverage to merge. This helps detect edge cases and prevent errors.
84+
5485
## Creating new cops
5586

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

0 commit comments

Comments
 (0)