-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from Team766/Add-Linter
create yml workflow to ensure code is linted and lint it if it isn't. CLOSES PLANE 209
- Loading branch information
Showing
21 changed files
with
200 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: C++ Lint and Auto-Fix | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: write # Required for pushing auto-fix commits | ||
|
||
jobs: | ||
lint: | ||
name: Lint C++ Code | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.head_ref }} # Checkout the correct branch | ||
fetch-depth: 0 # Ensure full commit history for pushing changes | ||
|
||
- name: Install clang-format and cppcheck | ||
run: sudo apt-get install -y clang-format cppcheck | ||
|
||
- name: Run clang-format and fix issues | ||
run: | | ||
FILES=$(find . -type f \( -name "*.cpp" -o -name "*.hpp" -o -name "*.h" \) | tr '\n' ' ') | ||
if [ -z "$FILES" ]; then | ||
echo "No C++ source files found. Skipping clang-format." | ||
exit 0 | ||
fi | ||
clang-format -i $FILES | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
# Ensure we are on the correct branch | ||
git checkout ${{ github.head_ref }} | ||
git add . | ||
if ! git diff --cached --quiet; then | ||
git commit -m "Auto-format C++ code using clang-format" | ||
git push origin ${{ github.head_ref }} | ||
fi | ||
- name: Run cppcheck (C++ Mode) | ||
run: | | ||
FILES=$(find . -type f \( -name "*.cpp" -o -name "*.hpp" -o -name "*.h" \) | tr '\n' ' ') | ||
if [ -z "$FILES" ]; then | ||
echo "No C++ source files found. Skipping cppcheck." | ||
exit 0 | ||
fi | ||
echo "Running cppcheck on: $FILES" | ||
cppcheck --enable=all --error-exitcode=1 --inline-suppr --force --quiet --language=c++ \ | ||
--suppress=missingInclude \ | ||
--suppress=missingIncludeSystem \ | ||
--suppress=unusedStructMember \ | ||
--suppress=noExplicitConstructor \ | ||
--suppress=passedByValue \ | ||
--suppress=useInitializationList \ | ||
--suppress=cstyleCast \ | ||
--suppress=unusedFunction \ | ||
--suppress=unmatchedSuppression $FILES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#ifndef NETWORK_TABLES_CONFIG_H_ | ||
#define NETWORK_TABLES_CONFIG_H_ | ||
|
||
inline const char* TABLE_ADDRESS = "10.7.66.2"; | ||
inline const char* TABLE_NAME = "/SmartDashboard"; | ||
inline const char *TABLE_ADDRESS = "10.7.66.2"; | ||
inline const char *TABLE_NAME = "/SmartDashboard"; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.