Skip to content

Update CONTRIBUTING.md #9

Update CONTRIBUTING.md

Update CONTRIBUTING.md #9

Workflow file for this run

name: Code Quality Checks
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
code-quality-report:
runs-on: ubuntu-latest
permissions:
issues: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install pyflakes
pip install stdlib-list
pip install pylint
pip install nltk
- name: Analyze Code Quality
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Dead Code Detection
dead_code_report=$(pyflakes . | grep -E "imported but unused|defined but not used" || true)
# Code Duplication Detection
duplication_report=$(pylint --disable=all --enable=duplicate-code . || true)
# Comment Quality Check
comment_report=$(python3 -c '
import re

Check failure on line 42 in .github/workflows/codeql.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/codeql.yml

Invalid workflow file

You have an error in your yaml syntax on line 42
import os
def analyze_comments(file_path):
issues = []
with open(file_path, "r") as f:
for line_num, line in enumerate(f, 1):
comment_match = re.search(r"#\s*(.+)", line)
if comment_match:
comment = comment_match.group(1)
if len(comment) < 3:
issues.append(f"{file_path}:{line_num} - Comment too short")
vague_words = ["thing", "stuff", "do", "make", "handle"]
for word in vague_words:
if word in comment.lower():
issues.append(f"{file_path}:{line_num} - Vague comment")
return issues
def main():
total_issues = []
for root, dirs, files in os.walk("."):
for file in files:
if file.endswith(".py"):
file_path = os.path.join(root, file)
file_issues = analyze_comments(file_path)
total_issues.extend(file_issues)
print("\n".join(total_issues))
main()' || true)
# Prepare the issue body
issue_body=""
if [ -n "$dead_code_report" ]; then
issue_body+="## πŸ’€ Dead Code Detection\n\`\`\`\n$dead_code_report\n\`\`\`\n\n"
fi
if [ -n "$duplication_report" ]; then
issue_body+="## πŸ“‹ Code Duplication\n\`\`\`\n$duplication_report\n\`\`\`\n\n"
fi
if [ -n "$comment_report" ]; then
issue_body+="## πŸ’¬ Comment Quality Issues\n\`\`\`\n$comment_report\n\`\`\`\n\n"
fi
if [ -n "$issue_body" ]; then
echo "$issue_body" > code_quality_report.md
gh issue create \
--title "Code Quality Report - $(date +'%Y-%m-%d')" \
--body-file code_quality_report.md \
--label "code-quality"
fi