Skip to content

Commit 6673954

Browse files
committed
Introduce cpplint
1 parent f48655a commit 6673954

20 files changed

+148
-81
lines changed

.github/workflows/cpplint.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+
name: Cpplint
4+
5+
on:
6+
workflow_dispatch:
7+
push:
8+
branches:
9+
- main
10+
- release/*
11+
pull_request:
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
cpplint:
19+
name: cpplint
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v5
24+
25+
- name: Cache
26+
uses: actions/cache@v4
27+
with:
28+
key: ${{ runner.os }}-cpplint
29+
path: ~/.cache/pip
30+
31+
- name: Pyhton
32+
uses: actions/setup-python@v6
33+
with:
34+
python-version: "3.13"
35+
36+
- name: cpplint
37+
run: |
38+
python -m pip install --upgrade pip
39+
pip install --upgrade cpplint
40+
cpplint \
41+
--repository=. \
42+
--recursive \
43+
--filter=-build/c++11,-build/namespaces,-readability/braces,-readability/casting,-readability/todo,-runtime/explicit,-runtime/indentation_namespace,-runtime/int,-runtime/references,-whitespace/blank_line,,-whitespace/braces,-whitespace/comments,-whitespace/indent,-whitespace/line_length,-whitespace/newline,-whitespace/parens \
44+
lib \
45+
include \
46+
src

src/AsyncEventSource.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#include "AsyncEventSource.h"
55
#include "AsyncWebServerLogging.h"
66

7+
#include <algorithm>
8+
#include <memory>
9+
#include <utility>
10+
711
#define ASYNC_SSE_NEW_LINE_CHAR (char)0xa
812

913
using namespace asyncsrv;

src/AsyncEventSource.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// SPDX-License-Identifier: LGPL-3.0-or-later
22
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
33

4-
#ifndef ASYNCEVENTSOURCE_H_
5-
#define ASYNCEVENTSOURCE_H_
4+
#pragma once
65

76
#include <Arduino.h>
87

@@ -44,6 +43,10 @@
4443
#endif
4544
#endif
4645

46+
#include <list>
47+
#include <memory>
48+
#include <utility>
49+
4750
class AsyncEventSource;
4851
class AsyncEventSourceResponse;
4952
class AsyncEventSourceClient;
@@ -312,8 +315,8 @@ class AsyncEventSource : public AsyncWebHandler {
312315
// system callbacks (do not call from user code!)
313316
void _addClient(AsyncEventSourceClient *client);
314317
void _handleDisconnect(AsyncEventSourceClient *client);
315-
bool canHandle(AsyncWebServerRequest *request) const override final;
316-
void handleRequest(AsyncWebServerRequest *request) override final;
318+
bool canHandle(AsyncWebServerRequest *request) const final;
319+
void handleRequest(AsyncWebServerRequest *request) final;
317320
};
318321

319322
class AsyncEventSourceResponse : public AsyncWebServerResponse {
@@ -333,5 +336,3 @@ class AsyncEventSourceResponse : public AsyncWebServerResponse {
333336
return true;
334337
}
335338
};
336-
337-
#endif /* ASYNCEVENTSOURCE_H_ */

src/AsyncJson.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "AsyncJson.h"
55
#include "AsyncWebServerLogging.h"
66

7+
#include <utility>
8+
79
#if ASYNC_JSON_SUPPORT == 1
810

911
// Json content type response classes

src/AsyncJson.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ class AsyncCallbackJsonWebHandler : public AsyncWebHandler {
113113
_onRequest = fn;
114114
}
115115

116-
bool canHandle(AsyncWebServerRequest *request) const override final;
117-
void handleRequest(AsyncWebServerRequest *request) override final;
116+
bool canHandle(AsyncWebServerRequest *request) const final;
117+
void handleRequest(AsyncWebServerRequest *request) final;
118118
void handleUpload(
119119
__unused AsyncWebServerRequest *request, __unused const String &filename, __unused size_t index, __unused uint8_t *data, __unused size_t len,
120120
__unused bool final
121-
) override final {}
122-
void handleBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) override final;
123-
bool isRequestHandlerTrivial() const override final {
121+
) final {}
122+
void handleBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) final;
123+
bool isRequestHandlerTrivial() const final {
124124
return !_onRequest;
125125
}
126126
};

src/AsyncWebServerRequest.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// SPDX-License-Identifier: LGPL-3.0-or-later
2+
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
3+
14
#include <ESPAsyncWebServer.h>
25

36
/**

src/AsyncWebSocket.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
#include "AsyncWebSocket.h"
55
#include "AsyncWebServerLogging.h"
66

7-
#include <cstring>
8-
97
#include <libb64/cencode.h>
108

119
#if defined(ESP32)
@@ -21,6 +19,12 @@
2119
#include <mbedtls/sha1.h>
2220
#endif
2321

22+
#include <algorithm>
23+
#include <cstdio>
24+
#include <cstring>
25+
#include <memory>
26+
#include <utility>
27+
2428
using namespace asyncsrv;
2529

2630
size_t webSocketSendFrameWindow(AsyncClient *client) {
@@ -48,10 +52,10 @@ size_t webSocketSendFrame(AsyncClient *client, bool final, uint8_t opcode, bool
4852
uint8_t headLen = 2;
4953
if (len && mask) {
5054
headLen += 4;
51-
mbuf[0] = rand() % 0xFF;
52-
mbuf[1] = rand() % 0xFF;
53-
mbuf[2] = rand() % 0xFF;
54-
mbuf[3] = rand() % 0xFF;
55+
mbuf[0] = rand() % 0xFF; // NOLINT(runtime/threadsafe_fn)
56+
mbuf[1] = rand() % 0xFF; // NOLINT(runtime/threadsafe_fn)
57+
mbuf[2] = rand() % 0xFF; // NOLINT(runtime/threadsafe_fn)
58+
mbuf[3] = rand() % 0xFF; // NOLINT(runtime/threadsafe_fn)
5559
}
5660
if (len > 125) {
5761
headLen += 2;

src/AsyncWebSocket.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// SPDX-License-Identifier: LGPL-3.0-or-later
22
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
33

4-
#ifndef ASYNCWEBSOCKET_H_
5-
#define ASYNCWEBSOCKET_H_
4+
#pragma once
65

76
#include <Arduino.h>
87

@@ -32,6 +31,9 @@
3231
#include <ESPAsyncWebServer.h>
3332
#include <AsyncWebServerLogging.h>
3433

34+
#include <cstdio>
35+
#include <deque>
36+
#include <list>
3537
#include <memory>
3638

3739
#ifdef ESP8266
@@ -454,8 +456,8 @@ class AsyncWebSocket : public AsyncWebHandler {
454456
AsyncWebSocketClient *_newClient(AsyncWebServerRequest *request);
455457
void _handleDisconnect(AsyncWebSocketClient *client);
456458
void _handleEvent(AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len);
457-
bool canHandle(AsyncWebServerRequest *request) const override final;
458-
void handleRequest(AsyncWebServerRequest *request) override final;
459+
bool canHandle(AsyncWebServerRequest *request) const final;
460+
void handleRequest(AsyncWebServerRequest *request) final;
459461

460462
// messagebuffer functions/objects.
461463
AsyncWebSocketMessageBuffer *makeBuffer(size_t size = 0);
@@ -567,5 +569,3 @@ class AsyncWebSocketMessageHandler {
567569
}
568570
};
569571
};
570-
571-
#endif /* ASYNCWEBSOCKET_H_ */

src/BackPort_SHA1Builder.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#pragma once
16+
1517
#include <Arduino.h>
1618
#if ESP_IDF_VERSION_MAJOR < 5
1719

18-
#ifndef SHA1Builder_h
19-
#define SHA1Builder_h
20-
2120
#include <Stream.h>
2221
#include <WString.h>
2322

@@ -39,6 +38,4 @@ class SHA1Builder {
3938
void getBytes(uint8_t *output);
4039
};
4140

42-
#endif // SHA1Builder_h
43-
4441
#endif // ESP_IDF_VERSION_MAJOR < 5

src/ChunkPrint.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// SPDX-License-Identifier: LGPL-3.0-or-later
22
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
33

4-
#ifndef CHUNKPRINT_H
5-
#define CHUNKPRINT_H
4+
#pragma once
65

76
#include <Print.h>
87

@@ -20,4 +19,3 @@ class ChunkPrint : public Print {
2019
return this->Print::write(buffer, size);
2120
}
2221
};
23-
#endif

0 commit comments

Comments
 (0)