Skip to content

Commit 01dcc26

Browse files
committed
Formatting and code analysis 'issues'.
Signed-off-by: Maaike Zijderveld, iolar <git.mail@iolar.nl>
1 parent e1653da commit 01dcc26

File tree

9 files changed

+36
-29
lines changed

9 files changed

+36
-29
lines changed

include/ocpp/v2/functional_blocks/authorization.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Authorization : public AuthorizationInterface {
5454
std::atomic_bool auth_cache_cleanup_handler_running;
5555

5656
public:
57-
Authorization(const BlockContext& context);
57+
explicit Authorization(const BlockContext& context);
5858
~Authorization();
5959
void start_auth_cache_cleanup_thread() override;
6060
void handle_message(const ocpp::EnhancedMessage<MessageType>& message) override;

include/ocpp/v2/functional_blocks/availability.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ class Availability : public AvailabilityInterface {
8686
Everest::SteadyTimer heartbeat_timer;
8787

8888
public:
89-
Availability(const BlockContext& block_context,
90-
std::optional<TimeSyncCallback> time_sync_callback,
89+
Availability(const BlockContext& block_context, std::optional<TimeSyncCallback> time_sync_callback,
9190
std::optional<AllConnectorsUnavailableCallback> all_connectors_unavailable_callback);
9291
~Availability();
9392
void handle_message(const ocpp::EnhancedMessage<MessageType>& message) override;

include/ocpp/v2/functional_blocks/meter_values.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class MeterValuesInterface : public MessageHandlerInterface {
2929
class MeterValues : public MeterValuesInterface {
3030
public:
3131
virtual ~MeterValues() override = default;
32-
MeterValues(const BlockContext& block_context);
32+
explicit MeterValues(const BlockContext& block_context);
3333
void handle_message(const ocpp::EnhancedMessage<MessageType>& message) override;
3434
void update_aligned_data_interval() override;
3535
void on_meter_value(const int32_t evse_id, const MeterValue& meter_value) override;

include/ocpp/v2/functional_blocks/reservation.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ typedef std::function<ocpp::ReservationCheckStatus(const int32_t evse_id, const
2020

2121
class ReservationInterface : public MessageHandlerInterface {
2222
public:
23-
virtual ~ReservationInterface() {};
23+
virtual ~ReservationInterface() = default;
2424
virtual void on_reservation_status(const int32_t reservation_id, const ReservationUpdateStatusEnum status) = 0;
2525
virtual ocpp::ReservationCheckStatus
2626
is_evse_reserved_for_other(const EvseInterface& evse, const IdToken& id_token,

include/ocpp/v2/functional_blocks/tariff_and_cost.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class TariffAndCostInterface : public MessageHandlerInterface {
3434

3535
class TariffAndCost : public TariffAndCostInterface {
3636
public:
37-
TariffAndCost(const BlockContext& block_context, MeterValuesInterface &meter_values,
37+
TariffAndCost(const BlockContext& block_context, MeterValuesInterface& meter_values,
3838
std::optional<SetDisplayMessageCallback>& set_display_message_callback,
3939
std::optional<SetRunningCostCallback>& set_running_cost_callback,
4040
boost::asio::io_service& io_service);

lib/ocpp/v2/functional_blocks/diagnostics.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
// Copyright Pionix GmbH and Contributors to EVerest
33

44
#include <ocpp/v2/functional_blocks/diagnostics.hpp>
5-
6-
#include <ocpp/v2/functional_blocks/block_context.hpp>
75
#include <ocpp/common/constants.hpp>
86
#include <ocpp/v2/connectivity_manager.hpp>
97
#include <ocpp/v2/ctrlr_component_variables.hpp>
108
#include <ocpp/v2/database_handler.hpp>
119
#include <ocpp/v2/device_model.hpp>
1210
#include <ocpp/v2/functional_blocks/authorization.hpp>
11+
#include <ocpp/v2/functional_blocks/block_context.hpp>
1312
#include <ocpp/v2/utils.hpp>
1413

1514
#include <ocpp/v2/messages/ClearVariableMonitoring.hpp>
@@ -27,7 +26,7 @@ const auto DEFAULT_MAX_CUSTOMER_INFORMATION_DATA_LENGTH = 51200;
2726

2827
namespace ocpp::v2 {
2928

30-
Diagnostics::Diagnostics(const BlockContext &context, AuthorizationInterface& authorization,
29+
Diagnostics::Diagnostics(const BlockContext& context, AuthorizationInterface& authorization,
3130
GetLogRequestCallback get_log_request_callback,
3231
std::optional<GetCustomerInformationCallback> get_customer_information_callback,
3332
std::optional<ClearCustomerInformationCallback> clear_customer_information_callback) :
@@ -196,7 +195,8 @@ void Diagnostics::handle_customer_information_req(Call<CustomerInformationReques
196195
}
197196

198197
const auto max_customer_information_data_length =
199-
this->context.device_model.get_optional_value<int>(ControllerComponentVariables::MaxCustomerInformationDataLength)
198+
this->context.device_model
199+
.get_optional_value<int>(ControllerComponentVariables::MaxCustomerInformationDataLength)
200200
.value_or(DEFAULT_MAX_CUSTOMER_INFORMATION_DATA_LENGTH);
201201
if (data.length() > max_customer_information_data_length) {
202202
EVLOG_warning << "NotifyCustomerInformation.req data field is too large. Cropping it down to: "
@@ -246,10 +246,10 @@ void Diagnostics::handle_set_monitoring_level_req(Call<SetMonitoringLevelRequest
246246
if (msg.severity < MonitoringLevelSeverity::MIN or msg.severity > MonitoringLevelSeverity::MAX) {
247247
response.status = GenericStatusEnum::Rejected;
248248
} else {
249-
auto result = this->context.device_model.set_value(ControllerComponentVariables::ActiveMonitoringLevel.component,
250-
ControllerComponentVariables::ActiveMonitoringLevel.variable.value(),
251-
AttributeEnum::Actual, std::to_string(msg.severity),
252-
VARIABLE_ATTRIBUTE_VALUE_SOURCE_CSMS, true);
249+
auto result = this->context.device_model.set_value(
250+
ControllerComponentVariables::ActiveMonitoringLevel.component,
251+
ControllerComponentVariables::ActiveMonitoringLevel.variable.value(), AttributeEnum::Actual,
252+
std::to_string(msg.severity), VARIABLE_ATTRIBUTE_VALUE_SOURCE_CSMS, true);
253253

254254
if (result != SetVariableStatusEnum::Accepted) {
255255
EVLOG_warning << "Could not persist in device model new monitoring level: " << msg.severity;

lib/ocpp/v2/functional_blocks/security.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
// Copyright Pionix GmbH and Contributors to EVerest
33

44
#include <ocpp/v2/functional_blocks/security.hpp>
5-
6-
#include <ocpp/v2/connectivity_manager.hpp>
75
#include <ocpp/common/constants.hpp>
86
#include <ocpp/common/ocpp_logging.hpp>
7+
#include <ocpp/v2/connectivity_manager.hpp>
98
#include <ocpp/v2/ctrlr_component_variables.hpp>
109
#include <ocpp/v2/device_model.hpp>
1110
#include <ocpp/v2/functional_blocks/block_context.hpp>

lib/ocpp/v2/functional_blocks/tariff_and_cost.cpp

+16-9
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33

44
#include <ocpp/v2/functional_blocks/tariff_and_cost.hpp>
55

6-
#include <ocpp/v2/functional_blocks/block_context.hpp>
76
#include <ocpp/v2/ctrlr_component_variables.hpp>
87
#include <ocpp/v2/device_model.hpp>
98
#include <ocpp/v2/evse_manager.hpp>
9+
#include <ocpp/v2/functional_blocks/block_context.hpp>
1010
#include <ocpp/v2/functional_blocks/meter_values.hpp>
1111

1212
#include <ocpp/v2/messages/CostUpdated.hpp>
1313

1414
const auto DEFAULT_PRICE_NUMBER_OF_DECIMALS = 3;
1515

1616
namespace ocpp::v2 {
17-
TariffAndCost::TariffAndCost(const BlockContext &block_context, MeterValuesInterface& meter_values,
17+
TariffAndCost::TariffAndCost(const BlockContext& block_context, MeterValuesInterface& meter_values,
1818
std::optional<SetDisplayMessageCallback>& set_display_message_callback,
1919
std::optional<SetRunningCostCallback>& set_running_cost_callback,
2020
boost::asio::io_service& io_service) :
@@ -111,7 +111,8 @@ void TariffAndCost::handle_cost_and_tariff(const TransactionEventResponse& respo
111111
if (/*custom_data.contains("vendorId") and
112112
(custom_data.at("vendorId").get<std::string>() == "org.openchargealliance.org.qrcode") and */
113113
custom_data.contains("qrCodeText") and
114-
this->context.device_model.get_optional_value<bool>(ControllerComponentVariables::DisplayMessageQRCodeDisplayCapable)
114+
this->context.device_model
115+
.get_optional_value<bool>(ControllerComponentVariables::DisplayMessageQRCodeDisplayCapable)
115116
.value_or(false)) {
116117
running_cost.qr_code_text = custom_data.at("qrCodeText");
117118
}
@@ -166,7 +167,8 @@ void TariffAndCost::handle_cost_and_tariff(const TransactionEventResponse& respo
166167
}
167168

168169
const int number_of_decimals =
169-
this->context.device_model.get_optional_value<int>(ControllerComponentVariables::NumberOfDecimalsForCostValues)
170+
this->context.device_model
171+
.get_optional_value<int>(ControllerComponentVariables::NumberOfDecimalsForCostValues)
170172
.value_or(DEFAULT_PRICE_NUMBER_OF_DECIMALS);
171173
uint32_t decimals =
172174
(number_of_decimals < 0 ? DEFAULT_PRICE_NUMBER_OF_DECIMALS : static_cast<uint32_t>(number_of_decimals));
@@ -209,7 +211,8 @@ void TariffAndCost::handle_costupdated_req(const Call<CostUpdatedRequest> call)
209211
running_cost.cost = static_cast<double>(call.msg.totalCost);
210212
running_cost.transaction_id = call.msg.transactionId;
211213

212-
std::optional<int32_t> transaction_evse_id = this->context.evse_manager.get_transaction_evseid(running_cost.transaction_id);
214+
std::optional<int32_t> transaction_evse_id =
215+
this->context.evse_manager.get_transaction_evseid(running_cost.transaction_id);
213216
if (!transaction_evse_id.has_value()) {
214217
// We just put an error in the log as the spec does not define what to do here. It is not possible to return
215218
// a 'Rejected' or something in that manner.
@@ -232,7 +235,8 @@ void TariffAndCost::handle_costupdated_req(const Call<CostUpdatedRequest> call)
232235
return;
233236
}
234237

235-
const std::optional<int32_t> evse_id_opt = this->context.evse_manager.get_transaction_evseid(running_cost.transaction_id);
238+
const std::optional<int32_t> evse_id_opt =
239+
this->context.evse_manager.get_transaction_evseid(running_cost.transaction_id);
236240
if (!evse_id_opt.has_value()) {
237241
EVLOG_warning << "Can not set running cost triggers as there is no evse id found with the transaction id from "
238242
"the incoming CostUpdatedRequest";
@@ -256,14 +260,17 @@ bool TariffAndCost::is_multilanguage_enabled() const {
256260
}
257261

258262
bool TariffAndCost::is_tariff_enabled() const {
259-
return this->context.device_model.get_optional_value<bool>(ControllerComponentVariables::TariffCostCtrlrAvailableTariff)
263+
return this->context.device_model
264+
.get_optional_value<bool>(ControllerComponentVariables::TariffCostCtrlrAvailableTariff)
260265
.value_or(false) and
261-
this->context.device_model.get_optional_value<bool>(ControllerComponentVariables::TariffCostCtrlrEnabledTariff)
266+
this->context.device_model
267+
.get_optional_value<bool>(ControllerComponentVariables::TariffCostCtrlrEnabledTariff)
262268
.value_or(false);
263269
}
264270

265271
bool TariffAndCost::is_cost_enabled() const {
266-
return this->context.device_model.get_optional_value<bool>(ControllerComponentVariables::TariffCostCtrlrAvailableCost)
272+
return this->context.device_model
273+
.get_optional_value<bool>(ControllerComponentVariables::TariffCostCtrlrAvailableCost)
267274
.value_or(false) and
268275
this->context.device_model.get_optional_value<bool>(ControllerComponentVariables::TariffCostCtrlrEnabledCost)
269276
.value_or(false);

tests/lib/ocpp/v2/test_composite_schedule.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,17 @@ class CompositeScheduleTestFixtureV2 : public DatabaseTestingUtils {
193193
this->database_handler =
194194
std::make_unique<DatabaseHandlerFake>(std::move(database_connection), MIGRATION_FILES_LOCATION_V2);
195195
database_handler->open_connection();
196-
this->block_context = std::make_unique<BlockContext>(this->mock_dispatcher, *this->device_model, this->connectivity_manager, *this->evse_manager,
197-
*this->database_handler, this->evse_security, this->component_state_manager);
196+
this->block_context = std::make_unique<BlockContext>(
197+
this->mock_dispatcher, *this->device_model, this->connectivity_manager, *this->evse_manager,
198+
*this->database_handler, this->evse_security, this->component_state_manager);
198199
return std::make_unique<TestSmartCharging>(*block_context, set_charging_profiles_callback_mock.AsStdFunction());
199200
}
200201

201202
void reconfigure_for_nr_of_evses(int32_t nr_of_evses) {
202203
this->evse_manager = std::make_unique<EvseManagerFake>(nr_of_evses);
203-
this->block_context = std::make_unique<BlockContext>(this->mock_dispatcher, *this->device_model, this->connectivity_manager, *this->evse_manager,
204-
*this->database_handler, this->evse_security, this->component_state_manager);
204+
this->block_context = std::make_unique<BlockContext>(
205+
this->mock_dispatcher, *this->device_model, this->connectivity_manager, *this->evse_manager,
206+
*this->database_handler, this->evse_security, this->component_state_manager);
205207
this->handler =
206208
std::make_unique<TestSmartCharging>(*block_context, set_charging_profiles_callback_mock.AsStdFunction());
207209
}

0 commit comments

Comments
 (0)