google/mcp-security
View on GitHubAdd GitHub status check to prevent trailing spaces in code
Open
#104 opened on Jun 25, 2025
enhancementgood first issue
Repository metrics
- Stars
- (504 stars)
- PR merge metrics
- (PR metrics pending)
Description
Description
Add a GitHub status check to automatically detect and prevent code with trailing spaces from being merged into the repository.
Motivation
Trailing spaces in code can cause issues with:
- Git diffs showing unnecessary changes
- Some linters and code formatters
- Consistency across the codebase
Proposed Solution
Implement a GitHub Actions workflow that:
- Runs on all pull requests
- Checks for trailing spaces in all files
- Fails the status check if trailing spaces are found
- Provides clear feedback about which files contain trailing spaces
Implementation Options
-
GitHub Actions with a simple script
- Use a bash script with
grepor similar tools - Lightweight and easy to maintain
- Use a bash script with
-
Pre-existing GitHub Actions
- Use actions like
zbeekman/EditorConfig-Action@v1 - Or
peter-evans/find-comment@v2with custom logic
- Use actions like
-
Super-linter
- Use GitHub's super-linter which includes trailing space checks
- More comprehensive but might be overkill
Example Workflow
name: Check Trailing Spaces
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
trailing-spaces:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check for trailing spaces
run: |
if grep -r '[[:space:]]$' --include="*.py" --include="*.md" --include="*.json" --include="*.yaml" --include="*.yml" .; then
echo "::error::Trailing spaces found in files above"
exit 1
else
echo "No trailing spaces found"
fi
Additional Considerations
- Should we automatically fix trailing spaces or just report them?
- Which file types should be checked?
- Should we exclude certain directories (e.g.,
node_modules,.git)?