Skip to content

🐛 Code-Review: change phabricator regex to allow URLs - #4086

Merged
spencerschrock merged 1 commit into
ossf:mainfrom
spencerschrock:fix-phabricator-re
May 7, 2024
Merged

🐛 Code-Review: change phabricator regex to allow URLs#4086
spencerschrock merged 1 commit into
ossf:mainfrom
spencerschrock:fix-phabricator-re

Conversation

@spencerschrock

Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

bug fix

What is the current behavior?

The old regex used \w which only allowed [0-9A-Za-z_], however most projects use full URLs with phabricator (e.g.
https://reviews.foo.org/D###). This led to errors parsing the revisions, where https was seen as the revision (the portion which matched \w), leading to an underreporting of code review practices as everything was considered 1 changeset.

go run main.go --repo freebsd/freebsd-src --checks Code-Review --format json --show-details | jq
{
  "date": "2024-05-06T14:23:32-07:00",
  "repo": {
    "name": "github.com/freebsd/freebsd-src",
    "commit": "a7db82cfd940431037e748280825931a46ed2d12"
  },
  "scorecard": {
    "version": "devel",
    "commit": "unknown"
  },
  "score": 0.0,
  "checks": [
    {
      "details": null,
      "score": 0,
      "reason": "Found 1/14 approved changesets -- score normalized to 0",
      "name": "Code-Review",
      "documentation": {
        "url": "https://github.com/ossf/scorecard/blob/main/docs/checks.md#code-review",
        "short": "Determines if the project requires human code review before pull requests (aka merge requests) are merged."
      }
    }
  ],
  "metadata": null
}

What is the new behavior (if this is a feature change)?**

The new regex focuses on matching D#### which is on the same line as "Differential Revision" . This regex does force the D prefix for a revision.

go run main.go --repo freebsd/freebsd-src --checks Code-Review --format json --show-details | jq
{
  "date": "2024-05-06T14:23:12-07:00",
  "repo": {
    "name": "github.com/freebsd/freebsd-src",
    "commit": "a7db82cfd940431037e748280825931a46ed2d12"
  },
  "scorecard": {
    "version": "devel",
    "commit": "unknown"
  },
  "score": 5.0,
  "checks": [
    {
      "details": null,
      "score": 5,
      "reason": "Found 17/30 approved changesets -- score normalized to 5",
      "name": "Code-Review",
      "documentation": {
        "url": "https://github.com/ossf/scorecard/blob/main/docs/checks.md#code-review",
        "short": "Determines if the project requires human code review before pull requests (aka merge requests) are merged."
      }
    }
  ],
  "metadata": null
}
  • Tests for the changes have been added (for bug fixes/features)

Which issue(s) this PR fixes

Fixes #4038

Special notes for your reviewer

I also made use of subtests in the corresponding test because it helps isolate the test failures better.

Does this PR introduce a user-facing change?

For user-facing changes, please add a concise, human-readable release note to
the release-note

(In particular, describe what changes users might need to make in their
application as a result of this pull request.)

Fixed an issue where Phabricator reviews weren't being parsed properly.

The old regex used \w which only allowed [0-9A-Za-z_], however most
projects use full URLs with phabricator (e.g.
https://reviews.foo.org/D###). This led to errors parsing the revisions,
where "https" was seen as the revision, leading to an underreporting of
code review practices.

The new regex focuses on the D#### part and uses it as the revision.

Signed-off-by: Spencer Schrock <sschrock@google.com>
@spencerschrock
spencerschrock requested a review from a team as a code owner May 6, 2024 22:09
@spencerschrock
spencerschrock requested review from justaugustus and naveensrinivasan and removed request for a team May 6, 2024 22:09
@spencerschrock

Copy link
Copy Markdown
Member Author

/scdiff generate Code-Review

@github-actions

github-actions Bot commented May 7, 2024

Copy link
Copy Markdown

@spencerschrock
spencerschrock merged commit 2506905 into ossf:main May 7, 2024
@spencerschrock
spencerschrock deleted the fix-phabricator-re branch May 7, 2024 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

BUG: Code-Review missing review markers

2 participants