Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 9 additions & 5 deletions scripts/pr_review_copilot.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"effort": str,
"table_header": str,
"table_findings": str,
"table_finding_marker": str,
"discussion_link": str,
}

Expand Down Expand Up @@ -108,8 +109,8 @@ class Reading(NamedTuple):

`open` is the count of open findings the body states, None where it states none or one this
reader cannot believe. `listed` is the larger of the items its findings lists hold and the
file table's filled findings cells, since both name the same findings. A cell counts once
however many findings it names, so the table alone can undercount.
file table's findings, since both name the same findings. A filled cell counts each finding
marker it carries, and once where it carries none, so the table alone can still undercount.
`unthreaded` is how many findings it names that no thread on the pull request carries.
`table` is the paths the body's file table names, None where it carries no table. `unplaced`
is each part the reader cannot place, with its text, the subset of `notes` that can hold a
Expand Down Expand Up @@ -175,6 +176,7 @@ def each(patterns: list[str]) -> list[re.Pattern[str]]:
"comment_heading": re.compile(vocabulary["comment_heading"] or r"(?!)", re.IGNORECASE),
"effort": re.compile(vocabulary["effort"] or r"(?!)", re.IGNORECASE),
"discussion_link": re.compile(vocabulary["discussion_link"] or r"(?!)"),
"table_finding_marker": re.compile(vocabulary["table_finding_marker"] or r"(?!)"),
}


Expand Down Expand Up @@ -532,10 +534,12 @@ def placed(n: int, t: Token) -> bool:
table = (table or []) + [p for row in rows if row for p in paths(row[0])]
if vocab["table_findings"] in heads:
column = heads.index(vocab["table_findings"])
marker = vocab["table_finding_marker"]
texts = [inline_text(row[column]) for row in rows if len(row) > column]
tabled += sum(
any(c.isalnum() for c in inline_text(row[column]))
for row in rows
if len(row) > column
max(1, len(marker.findall(text)))
for text in texts
if any(c.isalnum() for c in text)
)
i += 1

Expand Down
1 change: 1 addition & 0 deletions scripts/reviewers/coderabbit.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
"effort": "",
"table_header": "",
"table_findings": "",
"table_finding_marker": "",
"discussion_link": ""
}
1 change: 1 addition & 0 deletions scripts/reviewers/copilot.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@
"effort": "review effort(?: level)?:? *(?:default *\\( *(?P<default>lite|balanced|max) *\\)|(?P<level>lite|balanced|max))",
"table_header": "file",
"table_findings": "findings",
"table_finding_marker": "\\[P\\d\\]",
"discussion_link": "#discussion_r(?P<id>\\d+)$"
}
1 change: 1 addition & 0 deletions scripts/reviewers/qodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
"effort": "",
"table_header": "",
"table_findings": "",
"table_finding_marker": "",
"discussion_link": ""
}
1 change: 1 addition & 0 deletions tests/test_pr_review_copilot.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ def test_the_nested_list_and_the_findings_column_each_count_alone(self) -> None:
(narrative(cells=("", " ")), 2),
(narrative(listed=()), 2),
(narrative(listed=("one.",), cells=("One.", "", "Two.")), 2),
(narrative(listed=(), cells=("Moderate ([P1]): one. Nit ([P2]): two.", "Three.")), 3),
(what_changed(), 0),
):
with self.subTest(sections=sections[-60:]):
Expand Down
Loading