Skip to content

Commit c6a705d

Browse files
committed
Fix Reviewdog format, add docs
1 parent e65d00f commit c6a705d

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@ This is a proof-of-concept Python library to format errors.
22

33
It is based on the [Reviewdog Diagnostic Format](https://github.com/reviewdog/reviewdog/tree/master/proto/rdf).
44

5+
pyrde can:
6+
7+
* Generate text errors on the terminal.
8+
* Generate CSV files with errors for statistical analysis.
9+
* Generate [pull request comments](https://github.com/alexpdp7/pyrde/pull/1) using Reviewdog.
10+
511
See [the example directory](example/) for an example.

example/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@ $ bad_lines example.txt --error-format csv
55
message,severity,path,start_line,start_column,end_line,end_column,code,code_url,line
66
Line 'foo.' contains foo,ERROR,example.txt,2,,,,BAD_LINE,,foo.
77
```
8+
9+
To use Reviewdog to review PRs:
10+
11+
```
12+
$ bad_lines --error-format reviewdog example/example.txt | CI_PULL_REQUEST=1 CI_REPO_OWNER=alexpdp7 CI_REPO_NAME=pyrde CI_COMMIT=e1da9791bdf4406d60ee1d38ced1095e4d24c4e3 REVIEWDOG_GITHUB_API_TOKEN=... reviewdog -f rdjsonl -diff="git diff FETCH_HEAD" -guess -reporter=github-pr-review -name bad_lines
13+
```
14+
15+
See <https://github.com/alexpdp7/pyrde/pull/1> for the results.

example/example.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def main():
1919
content = file.read_text()
2020
bad_lines = [(number, line) for number, line in enumerate(content.splitlines()) if "foo" in line]
2121
for number, line in bad_lines:
22-
db.add_diagnostic("Line '{line}' contains foo", {"line": line}, diagnostics.Severity.ERROR, file, number, None, None, None, "BAD_LINE", None)
22+
db.add_diagnostic("Line '{line}' contains foo", {"line": line}, diagnostics.Severity.ERROR, file, number + 1, None, None, None, "BAD_LINE", None)
2323
errors = True
2424

2525
db.finish()

0 commit comments

Comments
 (0)