Skip to content

Commit 365cdf7

Browse files
committed
Add static code analysis CI workflows and tools
1 parent 3f0767d commit 365cdf7

8 files changed

Lines changed: 100 additions & 5 deletions

File tree

.github/workflows/clang-format.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Clang Format
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
check-formatting:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v3
11+
- name: Run clang-format
12+
uses: DoozyX/clang-format-lint-action@v0.16.2
13+
with:
14+
source: '.'
15+
exclude: './3rdparty ./modules/bglib/include/cmd_def.h ./modules/bglib/src/cmd_def.cpp'
16+
extensions: 'h,c,hpp,cpp'
17+
clangFormatVersion: 16
18+
inplace: False

.github/workflows/cppcheck.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: C/C++ Static Code Analysis
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
cppcheck:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v3
11+
- name: Install CppCheck
12+
run: |
13+
sudo -H apt-get update -y
14+
sudo -H apt-get install cppcheck
15+
env:
16+
DEBIAN_FRONTEND: noninteractive
17+
- name: Run Cppcheck
18+
run: cppcheck --std=c++20 --error-exitcode=1 --xml --xml-version=2 --force modules 2>cppcheck_results.xml
19+
- name: Generate Report
20+
if: ${{ failure() }}
21+
run: cppcheck-htmlreport --title=NativeSDK --file=cppcheck_results.xml --report-dir=report
22+
- name: Upload Report
23+
if: ${{ failure() }}
24+
uses: actions/upload-artifact@v1
25+
with:
26+
name: report
27+
path: report

.github/workflows/spellcheck.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: 'Check Spelling'
2+
on:
3+
pull_request:
4+
push:
5+
6+
jobs:
7+
spellcheck:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- uses: streetsidesoftware/cspell-action@v2

cspell.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"version": "0.2",
3+
"language": "en",
4+
// Words to be considered correct that CSpell will not flag.
5+
"words": [
6+
"gson",
7+
"dylib",
8+
"bglib",
9+
"uart",
10+
"hwaddr",
11+
"APITYPES",
12+
"PACKSTRUCT",
13+
"anglion",
14+
"lolen",
15+
"simblee",
16+
"openbci",
17+
"simpleble",
18+
"rdparty"
19+
],
20+
// These words will always be flagged as incorrect.
21+
"flagWords": [],
22+
"ignorePaths": [
23+
".vscode",
24+
".git",
25+
".github",
26+
".clang-format",
27+
".gitignore",
28+
"cspell.json",
29+
"build",
30+
"compiled",
31+
"3rdparty",
32+
"cmake/default.cmake",
33+
"CMakeLists.txt",
34+
"modules/bglib/include/cmd_def.h",
35+
"modules/bglib/src/cmd_def.cpp",
36+
"modules/bglib/src/stubs.cpp",
37+
"modules/bglib/src/uart.cpp"
38+
]
39+
}

modules/bglib/include/openbci_gui_helpers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#pragma once
22

33
#ifdef _WIN32
4-
#define SHARED_EXPORT __declspec(dllexport)
4+
#define SHARED_EXPORT __declspec (dllexport)
55
#define CALLING_CONVENTION __cdecl
66
#else
7-
#define SHARED_EXPORT __attribute__((visibility("default")))
7+
#define SHARED_EXPORT __attribute__ ((visibility ("default")))
88
#define CALLING_CONVENTION
99
#endif
1010

modules/bglib/include/uart.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define UART_H
33

44
void uart_list_devices ();
5-
int uart_find_serialport (char *name);
5+
int uart_find_serial_port (char *name);
66
int uart_open (char *port);
77
void uart_close ();
88
int uart_tx (int len, unsigned char *data);

modules/bglib/src/uart.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void uart_list_devices ()
9292
return;
9393
}
9494

95-
int uart_find_serialport (char *name)
95+
int uart_find_serial_port (char *name)
9696
{
9797
BYTE *pbuf = NULL;
9898
DWORD reqSize = 0;

modules/native-ble/include/openbci_gui_native_helpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
#ifdef _WIN32
4-
#define SHARED_EXPORT __declspec(dllexport)
4+
#define SHARED_EXPORT __declspec (dllexport)
55
#define CALLING_CONVENTION __cdecl
66
#else
77
#define SHARED_EXPORT __attribute__ ((visibility ("default")))

0 commit comments

Comments
 (0)