cargo-crap 0.3.0

Change Risk Anti-Patterns (CRAP) metric for Rust projects
Documentation
# Posts the cargo-crap PR comment generated by the CI workflow.
#
# Runs via workflow_run so it always executes in the context of the base repo
# (main branch), giving it write access to post comments even on fork PRs —
# where the CI job's GITHUB_TOKEN would be read-only.
name: Post PR Comment

on:
  workflow_run:
    workflows: [CI]
    types: [completed]

permissions:
  pull-requests: write
  actions: read

jobs:
  comment:
    name: Post or update PR comment
    runs-on: ubuntu-latest
    if: github.event.workflow_run.event == 'pull_request'
    steps:
      - name: Download PR comment artifact
        uses: actions/download-artifact@v4
        with:
          name: crap-pr-comment
          path: .
          run-id: ${{ github.event.workflow_run.id }}
          github-token: ${{ secrets.GITHUB_TOKEN }}
        continue-on-error: true

      - name: Post or update PR comment
        uses: actions/github-script@v7
        with:
          script: |
            const fs = require('fs');
            if (!fs.existsSync('crap-comment.md') || !fs.existsSync('pr-number.txt')) return;
            const body = fs.readFileSync('crap-comment.md', 'utf8');
            const prNumber = parseInt(fs.readFileSync('pr-number.txt', 'utf8').trim(), 10);
            if (!prNumber) return;
            const marker = '<!-- cargo-crap-report -->';
            const { data: comments } = await github.rest.issues.listComments({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: prNumber,
            });
            const existing = comments.find(c => c.body.startsWith(marker));
            if (existing) {
              await github.rest.issues.updateComment({
                owner: context.repo.owner,
                repo: context.repo.repo,
                comment_id: existing.id,
                body,
              });
            } else {
              await github.rest.issues.createComment({
                owner: context.repo.owner,
                repo: context.repo.repo,
                issue_number: prNumber,
                body,
              });
            }