Skip to content

count number of comments in the codebase of a PR before you merge 🎉

License

Notifications You must be signed in to change notification settings

deep5050/count-comments-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

count-comments-action

count number of comments in the codebase of a PR before you merge it:tada:

Example

example

comment-to-code-ratio analysis report for this PR 🎉

File blank % comment % code
./dist/index.js 15.72 10.77 6403
./README.md 10.18 0.00 547
./index.js 26.58 0.00 58
./.github/workflows/test.yml 13.79 0.00 25
./action.yml 17.39 0.00 19
./report.md 20.83 0.00 19
./.github/workflows/meme.yml 11.76 0.00 15
./logo.svg 0.00 0.00 1
-------- -------- -------- --------
SUM: 15.46 9.88 7087

Horribly commented code averages 0-5% comment ratio.

Poorly commented code has a 5-10% comment ratio.

Average code has a 10-15% comment ratio.

Good code has a 15-25% comment ratio.

Excellent code has a > 25% comment ratio.

Use this action on your projects to generate a report like this.

How to use

name: "test"
on:
 pull_request_target:
   types: [opened, reopened]

jobs:
 test:
   name: setup environment
   runs-on: ubuntu-latest
   steps:
     - name: chekckout PR codebase
       uses: actions/checkout@v2
       with:
         ref: ${{ github.event.pull_request.head.sha }}
       
     - name: install cloc
       uses: actions/setup-node@v1
       with:
         node-version: '12'
     - run: sudo npm install cloc -g
       
     - name: count and reply
       uses: deep5050/count-comments-action@main
       with:
         GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         issue_number: 1
         options: '--quiet ./ --hide-rate --git --unix --md --out=report.md --timeout=20 --by-percent=cmb --by-file-by-lang --exclude-dir=node_modules, --exclude-lang=JSON,XML,YAML,YML'

Related

deep5050/comment-to-code-ratio-action - GitHub

deep5050/cppcheck-action - GitHub