Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/cpplint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

name: Cpplint

on:
workflow_dispatch:
push:
branches:
- main
- release/*
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
cpplint:
name: cpplint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5

- name: Cache
uses: actions/cache@v4
with:
key: ${{ runner.os }}-cpplint
path: ~/.cache/pip

- name: Pyhton
uses: actions/setup-python@v6
with:
python-version: "3.13"

- name: cpplint
run: |
python -m pip install --upgrade pip
pip install --upgrade cpplint
cpplint \
--repository=. \
--recursive \
--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 \
lib \
include \
src
4 changes: 4 additions & 0 deletions src/AsyncEventSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include "AsyncEventSource.h"
#include "AsyncWebServerLogging.h"

#include <algorithm>
#include <memory>
#include <utility>

#define ASYNC_SSE_NEW_LINE_CHAR (char)0xa

using namespace asyncsrv;
Expand Down
13 changes: 7 additions & 6 deletions src/AsyncEventSource.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov

#ifndef ASYNCEVENTSOURCE_H_
#define ASYNCEVENTSOURCE_H_
#pragma once

#include <Arduino.h>

Expand Down Expand Up @@ -44,6 +43,10 @@
#endif
#endif

#include <list>
#include <memory>
#include <utility>

class AsyncEventSource;
class AsyncEventSourceResponse;
class AsyncEventSourceClient;
Expand Down Expand Up @@ -312,8 +315,8 @@ class AsyncEventSource : public AsyncWebHandler {
// system callbacks (do not call from user code!)
void _addClient(AsyncEventSourceClient *client);
void _handleDisconnect(AsyncEventSourceClient *client);
bool canHandle(AsyncWebServerRequest *request) const override final;
void handleRequest(AsyncWebServerRequest *request) override final;
bool canHandle(AsyncWebServerRequest *request) const final;
void handleRequest(AsyncWebServerRequest *request) final;
};

class AsyncEventSourceResponse : public AsyncWebServerResponse {
Expand All @@ -333,5 +336,3 @@ class AsyncEventSourceResponse : public AsyncWebServerResponse {
return true;
}
};

#endif /* ASYNCEVENTSOURCE_H_ */
2 changes: 2 additions & 0 deletions src/AsyncJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "AsyncJson.h"
#include "AsyncWebServerLogging.h"

#include <utility>

#if ASYNC_JSON_SUPPORT == 1

// Json content type response classes
Expand Down
10 changes: 5 additions & 5 deletions src/AsyncJson.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ class AsyncCallbackJsonWebHandler : public AsyncWebHandler {
_onRequest = fn;
}

bool canHandle(AsyncWebServerRequest *request) const override final;
void handleRequest(AsyncWebServerRequest *request) override final;
bool canHandle(AsyncWebServerRequest *request) const final;
void handleRequest(AsyncWebServerRequest *request) final;
void handleUpload(
__unused AsyncWebServerRequest *request, __unused const String &filename, __unused size_t index, __unused uint8_t *data, __unused size_t len,
__unused bool final
) override final {}
void handleBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) override final;
bool isRequestHandlerTrivial() const override final {
) final {}
void handleBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) final;
bool isRequestHandlerTrivial() const final {
return !_onRequest;
}
};
Expand Down
3 changes: 3 additions & 0 deletions src/AsyncWebServerRequest.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov

#include <ESPAsyncWebServer.h>

/**
Expand Down
16 changes: 10 additions & 6 deletions src/AsyncWebSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include "AsyncWebSocket.h"
#include "AsyncWebServerLogging.h"

#include <cstring>

#include <libb64/cencode.h>

#if defined(ESP32)
Expand All @@ -21,6 +19,12 @@
#include <mbedtls/sha1.h>
#endif

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <memory>
#include <utility>

using namespace asyncsrv;

size_t webSocketSendFrameWindow(AsyncClient *client) {
Expand Down Expand Up @@ -48,10 +52,10 @@ size_t webSocketSendFrame(AsyncClient *client, bool final, uint8_t opcode, bool
uint8_t headLen = 2;
if (len && mask) {
headLen += 4;
mbuf[0] = rand() % 0xFF;
mbuf[1] = rand() % 0xFF;
mbuf[2] = rand() % 0xFF;
mbuf[3] = rand() % 0xFF;
mbuf[0] = rand() % 0xFF; // NOLINT(runtime/threadsafe_fn)
mbuf[1] = rand() % 0xFF; // NOLINT(runtime/threadsafe_fn)
mbuf[2] = rand() % 0xFF; // NOLINT(runtime/threadsafe_fn)
mbuf[3] = rand() % 0xFF; // NOLINT(runtime/threadsafe_fn)
}
if (len > 125) {
headLen += 2;
Expand Down
12 changes: 6 additions & 6 deletions src/AsyncWebSocket.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov

#ifndef ASYNCWEBSOCKET_H_
#define ASYNCWEBSOCKET_H_
#pragma once

#include <Arduino.h>

Expand Down Expand Up @@ -32,6 +31,9 @@
#include <ESPAsyncWebServer.h>
#include <AsyncWebServerLogging.h>

#include <cstdio>
#include <deque>
#include <list>
#include <memory>

#ifdef ESP8266
Expand Down Expand Up @@ -454,8 +456,8 @@ class AsyncWebSocket : public AsyncWebHandler {
AsyncWebSocketClient *_newClient(AsyncWebServerRequest *request);
void _handleDisconnect(AsyncWebSocketClient *client);
void _handleEvent(AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len);
bool canHandle(AsyncWebServerRequest *request) const override final;
void handleRequest(AsyncWebServerRequest *request) override final;
bool canHandle(AsyncWebServerRequest *request) const final;
void handleRequest(AsyncWebServerRequest *request) final;

// messagebuffer functions/objects.
AsyncWebSocketMessageBuffer *makeBuffer(size_t size = 0);
Expand Down Expand Up @@ -567,5 +569,3 @@ class AsyncWebSocketMessageHandler {
}
};
};

#endif /* ASYNCWEBSOCKET_H_ */
7 changes: 2 additions & 5 deletions src/BackPort_SHA1Builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <Arduino.h>
#if ESP_IDF_VERSION_MAJOR < 5

#ifndef SHA1Builder_h
#define SHA1Builder_h

#include <Stream.h>
#include <WString.h>

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

#endif // SHA1Builder_h

#endif // ESP_IDF_VERSION_MAJOR < 5
4 changes: 1 addition & 3 deletions src/ChunkPrint.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov

#ifndef CHUNKPRINT_H
#define CHUNKPRINT_H
#pragma once

#include <Print.h>

Expand All @@ -20,4 +19,3 @@ class ChunkPrint : public Print {
return this->Print::write(buffer, size);
}
};
#endif
12 changes: 6 additions & 6 deletions src/ESPAsyncWebServer.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov

#ifndef _ESPAsyncWebServer_H_
#define _ESPAsyncWebServer_H_
#pragma once

#include <Arduino.h>
#include <FS.h>
Expand All @@ -12,7 +11,10 @@
#include <deque>
#include <functional>
#include <list>
#include <memory>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

#if __has_include("ArduinoJson.h")
Expand Down Expand Up @@ -45,15 +47,15 @@
#error Platform not supported
#endif

#include "literals.h"

#include "AsyncWebServerVersion.h"
#define ASYNCWEBSERVER_FORK_ESP32Async

#ifdef ASYNCWEBSERVER_REGEX
#include <regex>
#endif

#include "./literals.h"

// See https://github.com/ESP32Async/ESPAsyncWebServer/commit/3d3456e9e81502a477f6498c44d0691499dda8f9#diff-646b25b11691c11dce25529e3abce843f0ba4bd07ab75ec9eee7e72b06dbf13fR388-R392
// This setting slowdown chunk serving but avoids crashing or deadlocks in the case where slow chunk responses are created, like file serving form SD Card
#ifndef ASYNCWEBSERVER_USE_CHUNK_INFLIGHT
Expand Down Expand Up @@ -1584,5 +1586,3 @@ class DefaultHeaders {
#if ASYNC_JSON_SUPPORT == 1
#include <AsyncJson.h>
#endif

#endif /* _AsyncWebServer_H_ */
2 changes: 2 additions & 0 deletions src/Middleware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "WebAuthentication.h"
#include <ESPAsyncWebServer.h>

#include <list>

AsyncMiddlewareChain::~AsyncMiddlewareChain() {
for (AsyncMiddleware *m : _middlewares) {
if (m->_freeOnRemoval) {
Expand Down
7 changes: 4 additions & 3 deletions src/WebAuthentication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
#if defined(ESP32) || defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
#include <MD5Builder.h>
#else
#include "md5.h"
#include <md5.h>
#endif
#include "literals.h"

#include "./literals.h"

using namespace asyncsrv;

Expand Down Expand Up @@ -84,7 +85,7 @@ String genRandomMD5() {
#ifdef ESP8266
uint32_t r = RANDOM_REG32;
#else
uint32_t r = rand();
uint32_t r = rand(); // NOLINT(runtime/threadsafe_fn)
#endif
char *out = (char *)malloc(33);
if (out == NULL || !getMD5((uint8_t *)(&r), 4, out)) {
Expand Down
5 changes: 1 addition & 4 deletions src/WebAuthentication.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov

#ifndef WEB_AUTHENTICATION_H_
#define WEB_AUTHENTICATION_H_
#pragma once

#include "Arduino.h"

Expand All @@ -19,5 +18,3 @@ String generateDigestHash(const char *username, const char *password, const char
String generateBasicHash(const char *username, const char *password);

String genRandomMD5();

#endif
24 changes: 11 additions & 13 deletions src/WebHandlerImpl.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov

#ifndef ASYNCWEBSERVERHANDLERIMPL_H_
#define ASYNCWEBSERVERHANDLERIMPL_H_
#pragma once

#include <string>
#include "stddef.h"
#include <stddef.h>
#include <time.h>

#include <string>

class AsyncStaticWebHandler : public AsyncWebHandler {
using File = fs::File;
using FS = fs::FS;
Expand All @@ -29,8 +29,8 @@ class AsyncStaticWebHandler : public AsyncWebHandler {

public:
AsyncStaticWebHandler(const char *uri, FS &fs, const char *path, const char *cache_control);
bool canHandle(AsyncWebServerRequest *request) const override final;
void handleRequest(AsyncWebServerRequest *request) override final;
bool canHandle(AsyncWebServerRequest *request) const final;
void handleRequest(AsyncWebServerRequest *request) final;
AsyncStaticWebHandler &setTryGzipFirst(bool value);
AsyncStaticWebHandler &setIsDir(bool isDir);
AsyncStaticWebHandler &setDefaultFile(const char *filename);
Expand Down Expand Up @@ -77,13 +77,11 @@ class AsyncCallbackWebHandler : public AsyncWebHandler {
_onBody = fn;
}

bool canHandle(AsyncWebServerRequest *request) const override final;
void handleRequest(AsyncWebServerRequest *request) override final;
void handleUpload(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final) override final;
void handleBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) override final;
bool isRequestHandlerTrivial() const override final {
bool canHandle(AsyncWebServerRequest *request) const final;
void handleRequest(AsyncWebServerRequest *request) final;
void handleUpload(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final) final;
void handleBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) final;
bool isRequestHandlerTrivial() const final {
return !_onRequest;
}
};

#endif /* ASYNCWEBSERVERHANDLERIMPL_H_ */
Loading