Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
e27213e
Add clang-tidy config
hikinggrass Oct 11, 2025
bd0fc78
Fix clang-format config to always keep qualifiers aligned left
hikinggrass Oct 11, 2025
dc9d31a
Update gitignore file
hikinggrass Oct 11, 2025
2612ee1
Fix doxygen comment formatting on generated files
hikinggrass Oct 11, 2025
84bec6d
Fix header guard
hikinggrass Oct 11, 2025
c6716b3
Use const refs in generated messages and types
hikinggrass Oct 11, 2025
ade4503
Use const (ref) where possible
hikinggrass Oct 11, 2025
0da2471
Use explicit comparisons in if statements and prefer empty() to size(…
hikinggrass Oct 11, 2025
5abbbfc
Use = default for ctors and use override for virtual functions
hikinggrass Oct 11, 2025
af0de49
Use ctor initializer list
hikinggrass Oct 11, 2025
4514ecf
Do not declare multiple variables at once
hikinggrass Oct 11, 2025
a089d90
Initialize members and variables
hikinggrass Oct 11, 2025
9a39eb0
Use using instead of typedef
hikinggrass Oct 11, 2025
e6d200e
Simplify if/else handling, eg. no use of else after return
hikinggrass Oct 11, 2025
2578082
Use stoul instead of atoi
hikinggrass Oct 11, 2025
c162d3e
Fix missing value in enum declaration
hikinggrass Oct 11, 2025
41d1032
Add clamp_to and convert_to_positive_size_t utils functions
hikinggrass Oct 11, 2025
6d12cfd
Use anonymous namespace instead of static
hikinggrass Oct 11, 2025
1a8909c
Use enum class instead of enum
hikinggrass Oct 11, 2025
f870412
remove repeating visibilities
hikinggrass Oct 11, 2025
8eb99ea
Fix parameter names not being identical in hpp and cpp
hikinggrass Oct 11, 2025
e855c0c
remove redundant inline
hikinggrass Oct 11, 2025
1f1f748
Access static member via class not this
hikinggrass Oct 11, 2025
6d0606a
Use move
hikinggrass Oct 11, 2025
0e90f07
Make log_on_fail static
hikinggrass Oct 11, 2025
102cd08
Fix size_t usage in profile
hikinggrass Oct 11, 2025
7e2797b
Fix includes
hikinggrass Oct 11, 2025
e00d560
Use std::is_same_v
hikinggrass Oct 11, 2025
6d46530
Add readability NOLINT comments
hikinggrass Oct 11, 2025
d69c5da
Reserve space in containers
hikinggrass Oct 11, 2025
9894a38
Use std::array
hikinggrass Oct 11, 2025
e3d4b92
Use nullptr instead of NULL
hikinggrass Oct 11, 2025
755223d
Ensure that reset() of object instead of smart ptr is used
hikinggrass Oct 11, 2025
20b7176
Fix unchecked optional access
hikinggrass Oct 11, 2025
48d2b0f
Add some utils tests
hikinggrass Oct 11, 2025
b21fbee
Modify drop_transaction_data algorithm to fix some clang-tidy issues
hikinggrass Oct 11, 2025
a5ebe13
Ensure operator precedence
hikinggrass Oct 11, 2025
08c5fd0
Use iterator instead of tracking a position manually
hikinggrass Oct 11, 2025
6388e90
Comment out unused parameters
hikinggrass Oct 11, 2025
0a22df2
catch exceptions in destructors
hikinggrass Oct 11, 2025
b8e3b07
Remove moves that do not do anything
hikinggrass Oct 11, 2025
0808f2e
Add NOLINT comments for needed reinterpret_casts
hikinggrass Oct 11, 2025
ebda6de
clamp values so they do not overflow
hikinggrass Oct 11, 2025
d639af2
Use lambdas instead of bind
hikinggrass Oct 13, 2025
3439d7e
Use emplace_back instead of push_back
hikinggrass Oct 13, 2025
b48955b
Cast values to appropriate types
hikinggrass Oct 13, 2025
1a1af5b
Remove unused variables and initialization
hikinggrass Oct 13, 2025
b748dc8
compare to string::npos
hikinggrass Oct 13, 2025
feeefe1
Do not return void from void function
hikinggrass Oct 13, 2025
bfab6ea
Remove redundant .get() or .c_str()
hikinggrass Oct 13, 2025
44e22c4
remove duplicate if statement
hikinggrass Oct 13, 2025
e33ce88
use container.find()
hikinggrass Oct 13, 2025
e1975ae
Ignore widening conversion warnings on very small constant values
hikinggrass Oct 13, 2025
c76826d
Fix type of variable
hikinggrass Oct 13, 2025
8c80858
clang-format
hikinggrass Oct 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
QualifierAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
Expand Down
58 changes: 58 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Checks: >
*,
bugprone-*,
cert-*,
concurrency-*,
cppcoreguidelines-*,
misc-*,
performance-*,
-abseil-*,
-altera-*,
-android-*,
-boost-*,
-fuchsia-*,
-google-*,
-hicpp-*,
-llvm-*,
-llvmlibc-*,
-zircon-*,
-bugprone-easily-swappable-parameters,
-cert-err60-cpp,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-use-default-member-init,
-misc-include-cleaner,
-misc-non-private-member-variables-in-classes,
-modernize-pass-by-value,
-modernize-use-trailing-return-type,
-modernize-use-default-member-init,
-modernize-return-braced-init-list,
-modernize-use-scoped-lock,
-modernize-concat-nested-namespaces,
-modernize-use-nodiscard,
-modernize-raw-string-literal,
-performance-avoid-endl,
-performance-enum-size,
-performance-unnecessary-value-param,
-readability-avoid-const-params-in-decls,
-readability-function-cognitive-complexity,
-readability-identifier-length,
-readability-magic-numbers,
-readability-qualified-auto,
-readability-simplify-boolean-expr,
-readability-use-anyofallof,
-readability-use-std-min-max,
-concurrency-mt-unsafe,
-portability-avoid-pragma-once,
-portability-template-virtual-member-function,
-cppcoreguidelines-avoid-const-or-ref-data-members,
-cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-special-member-functions,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-pro-type-member-init,
-cert-err58-cpp,
# (the last -cppcoreguidelines and -cert-err58-cpp lines are temporary)
HeaderFilterRegex: ".*"
CheckOptions:
- { key: performance-unnecessary-value-param.AllowedTypes, value: ((std::shared_ptr)) }
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/build
/build*
!.gitignore
*vscode
.cache/
Expand All @@ -7,3 +7,5 @@ CMakeLists.txt.user
__pycache__
!doc/build-with-fetchcontent
/dist
clang-tidy-*.yaml
clang-tidy-*.txt
31 changes: 17 additions & 14 deletions 3rd_party/websocketpp_utils/base64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@

*/

#ifndef _BASE64_EVEREST_HPP_
#define _BASE64_EVEREST_HPP_
#ifndef BASE64_EVEREST_HPP_
#define BASE64_EVEREST_HPP_

#include <string>

namespace ocpp {

static std::string const base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
static const std::string base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";

Expand All @@ -62,14 +62,14 @@ static inline bool is_base64(unsigned char c) {
* @param len The length of input in bytes
* @return A base64 encoded string representing input
*/
inline std::string base64_encode(unsigned char const* input, size_t len) {
inline std::string base64_encode(const unsigned char* input, size_t len) {
std::string ret;
int i = 0;
int j = 0;
unsigned char char_array_3[3];
unsigned char char_array_4[4];

while (len--) {
while ((len--) != 0) {
char_array_3[i++] = *(input++);
if (i == 3) {
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
Expand All @@ -84,7 +84,7 @@ inline std::string base64_encode(unsigned char const* input, size_t len) {
}
}

if (i) {
if (i != 0) {
for (j = i; j < 3; j++) {
char_array_3[j] = '\0';
}
Expand All @@ -111,7 +111,7 @@ inline std::string base64_encode(unsigned char const* input, size_t len) {
* @param input The input data
* @return A base64 encoded string representing input
*/
inline std::string base64_encode(std::string const& input) {
inline std::string base64_encode(const std::string& input) {
return base64_encode(reinterpret_cast<const unsigned char*>(input.data()), input.size());
}

Expand All @@ -120,15 +120,16 @@ inline std::string base64_encode(std::string const& input) {
* @param input The base64 encoded input data
* @return A string representing the decoded raw bytes
*/
inline std::string base64_decode(std::string const& input) {
inline std::string base64_decode(const std::string& input) {
size_t in_len = input.size();
int i = 0;
int j = 0;
int in_ = 0;
unsigned char char_array_4[4], char_array_3[3];
unsigned char char_array_4[4];
unsigned char char_array_3[3];
std::string ret;

while (in_len-- && (input[in_] != '=') && is_base64(input[in_])) {
while (((in_len--) != 0) && (input[in_] != '=') && is_base64(input[in_])) {
char_array_4[i++] = input[in_];
in_++;
if (i == 4) {
Expand All @@ -147,12 +148,14 @@ inline std::string base64_decode(std::string const& input) {
}
}

if (i) {
for (j = i; j < 4; j++)
if (i != 0) {
for (j = i; j < 4; j++) {
char_array_4[j] = 0;
}

for (j = 0; j < 4; j++)
for (j = 0; j < 4; j++) {
char_array_4[j] = static_cast<unsigned char>(base64_chars.find(char_array_4[j]));
}

char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
Expand All @@ -168,4 +171,4 @@ inline std::string base64_decode(std::string const& input) {

} // namespace ocpp

#endif // _BASE64_HPP_
#endif // BASE64_EVEREST_HPP_
63 changes: 32 additions & 31 deletions 3rd_party/websocketpp_utils/uri.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#define WEBSOCKETPP_URI_EVEREST_HPP

#include <algorithm>
#include <cstdint>

Check warning on line 32 in 3rd_party/websocketpp_utils/uri.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

3rd_party/websocketpp_utils/uri.hpp#L32

Include file: <cstdint> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <sstream>
#include <stdexcept>
#include <string>
Expand All @@ -38,20 +39,20 @@
// TODO: figure out why this fixes horrible linking errors.

/// Default port for ws://
static uint16_t const uri_default_port = 80;
static const uint16_t uri_default_port = 80;
/// Default port for wss://
static uint16_t const uri_default_secure_port = 443;
static const uint16_t uri_default_secure_port = 443;
Comment on lines +42 to +44
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jumping on something I saw, maybe we should use std::uint16_t?


class uri {
public:
explicit uri(std::string const& uri_string) : m_valid(false) {
explicit uri(const std::string& uri_string) : m_valid(false) {
std::string::const_iterator it;
std::string::const_iterator temp;

int state = 0;

it = uri_string.begin();
size_t uri_len = uri_string.length();
const size_t uri_len = uri_string.length();

if (uri_len >= 7 && std::equal(it, it + 6, "wss://")) {
m_secure = true;
Expand Down Expand Up @@ -95,11 +96,11 @@

if (temp == uri_string.end()) {
return;
} else {
// validate IPv6 literal parts
// can contain numbers, a-f and A-F
m_host.append(it, temp);
}
// validate IPv6 literal parts
// can contain numbers, a-f and A-F
m_host.append(it, temp);

it = temp + 1;
if (it == uri_string.end()) {
state = 2;
Expand All @@ -120,7 +121,8 @@
if (it == uri_string.end()) {
state = 2;
break;
} else if (*it == '/') {
}
if (*it == '/') {
state = 2;
} else if (*it == ':') {
// end hostname start port
Expand All @@ -141,7 +143,8 @@
// refactoring
// state = 3;
break;
} else if (*it == '/') {
}
if (*it == '/') {
state = 3;
} else {
port += *it;
Expand All @@ -155,7 +158,7 @@
m_resource.append(it, uri_string.end());
}

uri(bool secure, std::string const& host, uint16_t port, std::string const& resource) :
uri(bool secure, const std::string& host, uint16_t port, const std::string& resource) :
m_scheme(secure ? "wss" : "ws"),
m_host(host),
m_resource(resource.empty() ? "/" : resource),
Expand All @@ -164,7 +167,7 @@
m_valid(true) {
}

uri(bool secure, std::string const& host, std::string const& resource) :
uri(bool secure, const std::string& host, const std::string& resource) :
m_scheme(secure ? "wss" : "ws"),
m_host(host),
m_resource(resource.empty() ? "/" : resource),
Expand All @@ -173,12 +176,12 @@
m_valid(true) {
}

uri(bool secure, std::string const& host, std::string const& port, std::string const& resource) :
uri(bool secure, const std::string& host, const std::string& port, const std::string& resource) :
m_scheme(secure ? "wss" : "ws"), m_host(host), m_resource(resource.empty() ? "/" : resource), m_secure(secure) {
m_port = get_port_from_string(port, m_valid);
}

uri(std::string const& scheme, std::string const& host, uint16_t port, std::string const& resource) :
uri(const std::string& scheme, const std::string& host, uint16_t port, const std::string& resource) :
m_scheme(scheme),
m_host(host),
m_resource(resource.empty() ? "/" : resource),
Expand All @@ -187,7 +190,7 @@
m_valid(true) {
}

uri(std::string scheme, std::string const& host, std::string const& resource) :
uri(std::string scheme, const std::string& host, const std::string& resource) :
m_scheme(scheme),
m_host(host),
m_resource(resource.empty() ? "/" : resource),
Expand All @@ -196,7 +199,7 @@
m_valid(true) {
}

uri(std::string const& scheme, std::string const& host, std::string const& port, std::string const& resource) :
uri(const std::string& scheme, const std::string& host, const std::string& port, const std::string& resource) :
m_scheme(scheme),
m_host(host),
m_resource(resource.empty() ? "/" : resource),
Expand All @@ -212,22 +215,21 @@
return m_secure;
}

std::string const& get_scheme() const {
const std::string& get_scheme() const {
return m_scheme;
}

std::string const& get_host() const {
const std::string& get_host() const {
return m_host;
}

std::string get_host_port() const {
if (m_port == (m_secure ? uri_default_secure_port : uri_default_port)) {
return m_host;
} else {
std::stringstream p;
p << m_host << ":" << m_port;
return p.str();
}
std::stringstream p;
p << m_host << ":" << m_port;
return p.str();
}

std::string get_authority() const {
Expand All @@ -246,7 +248,7 @@
return p.str();
}

std::string const& get_resource() const {
const std::string& get_resource() const {
return m_resource;
}

Expand All @@ -271,22 +273,21 @@
* @return query portion of the URI.
*/
std::string get_query() const {
std::size_t found = m_resource.find('?');
const std::size_t found = m_resource.find('?');
if (found != std::string::npos) {
return m_resource.substr(found + 1);
} else {
return "";
}
return "";
}

private:
uint16_t get_port_from_string(std::string const& port, bool& out_valid) const {
uint16_t get_port_from_string(const std::string& port, bool& out_valid) const {
out_valid = true;
if (port.empty()) {
return (m_secure ? uri_default_secure_port : uri_default_port);
}

unsigned int t_port = static_cast<unsigned int>(atoi(port.c_str()));
const auto t_port = std::stoul(port);

if (t_port > 65535) {
out_valid = false;
Expand All @@ -302,9 +303,9 @@
std::string m_scheme;
std::string m_host;
std::string m_resource;
uint16_t m_port;
bool m_secure;
bool m_valid;
uint16_t m_port = 0;
bool m_secure = false;
bool m_valid = false;
};

} // namespace ocpp
Expand Down
2 changes: 1 addition & 1 deletion include/ocpp/common/aligned_timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ClockAlignedTimer : private Everest::Timer<std::chrono::system_clock> {

private:
system_time_point start_point;
std::chrono::seconds call_interval;
std::chrono::seconds call_interval = std::chrono::seconds(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am guessing the behavior is that the timer doesn't start when the interval is 0, I just want to confirm though


std::function<void()> callback;

Expand Down
Loading