Skip to content

Commit b214e17

Browse files
committed
clang tidy
1 parent 8410802 commit b214e17

28 files changed

+80
-100
lines changed

examples/count/main.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using namespace reactor;
66
using namespace std::chrono_literals;
77

8-
class Count : public Reactor {
8+
class Count final : public Reactor {
99
private:
1010
// actions
1111
Timer timer{"timer", this};

examples/hello/main.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using namespace reactor;
77
using namespace std::chrono_literals;
88

9-
class Hello : public Reactor {
9+
class Hello final : public Reactor {
1010
private:
1111
// actions
1212
Timer timer{"timer", this, 1s, 2s};

examples/multiport_mutation/consumer.hh

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* Tassilo Tanneberger
77
*/
88

9-
#ifndef CONSUMER_HH // NOLINT
10-
#define CONSUMER_HH // NOLINT
9+
#ifndef MULTIPORT_MUTATION_CONSUMER_HH
10+
#define MULTIPORT_MUTATION_CONSUMER_HH
1111

1212
#include <reactor-cpp/reactor-cpp.hh>
1313
#include <reactor-cpp/scopes.hh>
@@ -45,4 +45,4 @@ public:
4545
void assemble() override { handle.declare_trigger(&in); }
4646
};
4747

48-
#endif // CONSUMER_HH
48+
#endif // MULTIPORT_MUTATION_CONSUMER_HH

examples/multiport_mutation/load_balancer.hh

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* Tassilo Tanneberger
77
*/
88

9-
#ifndef MULTIPORT_MUTATION_LOAD_BALANCER_HH // NOLINT
10-
#define MULTIPORT_MUTATION_LOAD_BALANCER_HH // NOLINT
9+
#ifndef MULTIPORT_MUTATION_LOAD_BALANCER_HH
10+
#define MULTIPORT_MUTATION_LOAD_BALANCER_HH
1111

1212
#include <reactor-cpp/mutations/multiport.hh>
1313
#include <reactor-cpp/reactor-cpp.hh>

examples/multiport_mutation/main.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Deployment final : public Reactor { // NOLINT
2929
int state = 0;
3030

3131
public:
32-
Inner(Reactor* reactor)
32+
explicit Inner(Reactor* reactor)
3333
: MutableScope(reactor) {}
3434
void reaction_1(const Input<unsigned>& scale, std::vector<std::unique_ptr<Consumer>>& reactor_bank,
3535
ModifableMultiport<Output<unsigned>>& load_balancer) {
@@ -41,8 +41,8 @@ class Deployment final : public Reactor { // NOLINT
4141
};
4242

4343
std::function get_input_port = [](const std::unique_ptr<Consumer>& consumer) { return &consumer->in; };
44-
auto rescale = std::make_shared<ResizeMultiportToBank<unsigned, Consumer>>(&load_balancer, &reactor_bank,
45-
get_input_port, lambda, new_size);
44+
const auto rescale = std::make_shared<ResizeMultiportToBank<unsigned, Consumer>>(
45+
&load_balancer, &reactor_bank, get_input_port, lambda, new_size);
4646

4747
add_to_transaction(rescale);
4848

examples/multiport_mutation/producer.hh

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* Tassilo Tanneberger
77
*/
88

9-
#ifndef MULTIPORT_MUTATION_PRODUCER_HH // NOLINT
10-
#define MULTIPORT_MUTATION_PRODUCER_HH // NOLINT
9+
#ifndef MULTIPORT_MUTATION_PRODUCER_HH
10+
#define MULTIPORT_MUTATION_PRODUCER_HH
1111

1212
#include <reactor-cpp/reactor-cpp.hh>
1313

examples/ports/main.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using namespace reactor;
66
using namespace std::chrono_literals;
77

8-
class Trigger : public Reactor {
8+
class Trigger final : public Reactor {
99
private:
1010
Timer timer;
1111
Reaction r_timer{"r_timer", 1, this, [this]() { on_timer(); }};
@@ -25,7 +25,7 @@ class Trigger : public Reactor {
2525
void on_timer() { trigger.set(); }
2626
};
2727

28-
class Counter : public Reactor {
28+
class Counter final : public Reactor {
2929
private:
3030
int value_{0};
3131
Reaction r_trigger{"r_trigger", 1, this, [this]() { on_trigger(); }};
@@ -49,7 +49,7 @@ class Counter : public Reactor {
4949
}
5050
};
5151

52-
class Printer : public Reactor {
52+
class Printer final : public Reactor {
5353
private:
5454
Reaction r_value{"r_value", 1, this, [this]() { on_value(); }};
5555

@@ -64,10 +64,10 @@ class Printer : public Reactor {
6464
r_value.declare_trigger(&value);
6565
}
6666

67-
void on_value() { std::cout << this->name() << ": " << *value.get() << '\n'; }
67+
void on_value() const { std::cout << this->name() << ": " << *value.get() << '\n'; }
6868
};
6969

70-
class Adder : public Reactor {
70+
class Adder final : public Reactor {
7171
private:
7272
Reaction r_add{"r_add", 1, this, [this]() { add(); }};
7373

examples/power_train/main.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
using namespace reactor;
66

7-
class LeftPedal : public Reactor {
7+
class LeftPedal final : public Reactor {
88
public:
99
// ports
1010
Output<void> angle{"angle", this}; // NOLINT
@@ -30,7 +30,7 @@ class LeftPedal : public Reactor {
3030
}
3131
};
3232

33-
class RightPedal : public Reactor {
33+
class RightPedal final : public Reactor {
3434
public:
3535
// ports
3636
Output<void> angle{"angle", this}; // NOLINT
@@ -60,7 +60,7 @@ class RightPedal : public Reactor {
6060
}
6161
};
6262

63-
class BrakeControl : public Reactor {
63+
class BrakeControl final : public Reactor {
6464
public:
6565
// ports
6666
Input<void> angle{"angle", this}; // NOLINT
@@ -81,7 +81,7 @@ class BrakeControl : public Reactor {
8181
}
8282
};
8383

84-
class EngineControl : public Reactor {
84+
class EngineControl final : public Reactor {
8585
public:
8686
// ports
8787
Input<void> angle{"angle", this}; // NOLINT
@@ -118,7 +118,7 @@ class EngineControl : public Reactor {
118118
}
119119
};
120120

121-
class Brake : public Reactor {
121+
class Brake final : public Reactor {
122122
public:
123123
// ports
124124
Input<void> force{"force", this}; // NOLINT
@@ -136,7 +136,7 @@ class Brake : public Reactor {
136136
void assemble() override { r1.declare_trigger(&force); }
137137
};
138138

139-
class Engine : public Reactor {
139+
class Engine final : public Reactor {
140140
public:
141141
// ports
142142
Input<void> torque{"torque", this}; // NOLINT

include/reactor-cpp/assert.hh

+3-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "reactor-cpp/fwd.hh"
1414

1515
#include <cassert>
16-
#include <sstream>
1716
#include <stdexcept>
1817
#include <string>
1918

@@ -71,7 +70,7 @@ public:
7170
: std::runtime_error(build_message(msg)) {}
7271
};
7372

74-
constexpr void validate([[maybe_unused]] bool condition, [[maybe_unused]] const std::string_view message) {
73+
constexpr void validate([[maybe_unused]] const bool condition, [[maybe_unused]] const std::string_view message) {
7574
if constexpr (runtime_validation) {
7675
if (!condition) {
7776
print_backtrace();
@@ -80,8 +79,8 @@ constexpr void validate([[maybe_unused]] bool condition, [[maybe_unused]] const
8079
}
8180
}
8281

83-
template <typename E> constexpr auto extract_value(E enum_value) -> typename std::underlying_type_t<E> {
84-
return static_cast<typename std::underlying_type_t<E>>(enum_value);
82+
template <typename E> constexpr auto extract_value(E enum_value) -> std::underlying_type_t<E> {
83+
return static_cast<std::underlying_type_t<E>>(enum_value);
8584
}
8685

8786
void assert_phase([[maybe_unused]] const ReactorElement* ptr, [[maybe_unused]] Phase phase);

include/reactor-cpp/connection.hh

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "logical_time.hh"
1818
#include "port.hh"
1919
#include "reaction.hh"
20-
#include "reactor.hh"
2120
#include "time.hh"
2221
#include "time_barrier.hh"
2322

@@ -69,7 +68,7 @@ protected:
6968
return [this](const BasePort& port) {
7069
// We know that port must be of type Port<T>
7170
auto& typed_port = reinterpret_cast<const Port<T>&>(port); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
72-
if constexpr (std::is_same<T, void>::value) {
71+
if constexpr (std::is_same_v<T, void>) {
7372
this->schedule();
7473
} else {
7574
this->schedule(std::move(typed_port.get()));
@@ -81,7 +80,7 @@ public:
8180
void setup() noexcept override {
8281
Action<T>::setup();
8382

84-
if constexpr (std::is_same<T, void>::value) {
83+
if constexpr (std::is_same_v<T, void>) {
8584
for (auto port : this->downstream_ports()) {
8685
port->set();
8786
}
@@ -134,7 +133,7 @@ public:
134133
// without locking.
135134
auto tag = Tag::from_logical_time(scheduler->logical_time());
136135
[[maybe_unused]] bool result{false};
137-
if constexpr (std::is_same<T, void>::value) {
136+
if constexpr (std::is_same_v<T, void>) {
138137
result = this->schedule_at(tag);
139138
} else {
140139
result = this->schedule_at(std::move(typed_port.get()), tag);

include/reactor-cpp/logging.hh

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010
#define REACTOR_CPP_LOGGING_HH
1111

1212
#include "reactor-cpp/config.hh"
13-
#include "reactor-cpp/time.hh"
14-
#include <chrono>
13+
1514
#include <iostream>
1615
#include <memory>
1716
#include <mutex>
1817
#include <string>
19-
#include <utility>
2018

2119
namespace reactor::log {
2220

include/reactor-cpp/multiport.hh

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ namespace reactor {
2424

2525
class BaseMultiport { // NOLINT cppcoreguidelines-special-member-functions,-warnings-as-errors
2626
protected:
27-
std::atomic<std::size_t> size_{0};
28-
std::vector<std::size_t> present_ports_{};
27+
std::atomic<std::size_t> size_{0}; // NOLINT cppcoreguidelines-non-private-member-variables-in-classes
28+
std::vector<std::size_t> present_ports_{}; // NOLINT cppcoreguidelines-non-private-member-variables-in-classes
2929

3030
private:
3131
std::string name_{};
@@ -53,11 +53,11 @@ protected:
5353
public:
5454
BaseMultiport(std::string name, Reactor* container)
5555
: name_(std::move(name))
56-
, container_(container) {};
56+
, container_(container) {}
5757
~BaseMultiport() = default;
5858

5959
[[nodiscard]] auto name() const noexcept -> const std::string& { return name_; }
60-
auto container() const noexcept -> Reactor* { return container_; }
60+
[[nodiscard]] auto container() const noexcept -> Reactor* { return container_; }
6161
};
6262

6363
template <class T, class A = std::allocator<T>>

include/reactor-cpp/mutations/multiport.hh

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#ifndef REACTOR_CPP_MUTATIONS_MULTIPORT_HH
1010
#define REACTOR_CPP_MUTATIONS_MULTIPORT_HH
1111

12-
#include <vector>
13-
1412
#include "../multiport.hh"
1513
#include "../mutations.hh"
1614
#include "../port.hh"

include/reactor-cpp/reaction.hh

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public:
6161

6262
void startup() final {}
6363
void shutdown() final {}
64-
void trigger();
64+
void trigger() const;
6565
void set_index(unsigned index);
6666

6767
template <class Dur> void set_deadline(Dur deadline, const std::function<void(void)>& handler) {

include/reactor-cpp/reactor.hh

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#define REACTOR_CPP_REACTOR_HH
1111

1212
#include <set>
13-
#include <sstream>
1413
#include <string>
1514

1615
#include "action.hh"

include/reactor-cpp/reactor_element.hh

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#define REACTOR_CPP_REACTOR_ELEMENT_HH
1212

1313
#include <cstdint>
14-
#include <memory>
15-
#include <set>
1614
#include <sstream>
1715
#include <string>
1816

include/reactor-cpp/semaphore.hh

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef REACTOR_CPP_SEMAPHORE_HH
1010
#define REACTOR_CPP_SEMAPHORE_HH
1111

12-
#include <atomic>
1312
#include <condition_variable>
1413
#include <mutex>
1514

include/reactor-cpp/statistics.hh

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#include <atomic>
1313

14-
#include "reactor-cpp/config.hh"
1514
#include "reactor-cpp/logging.hh"
1615

1716
namespace reactor {
@@ -23,7 +22,7 @@ private:
2322
#else
2423
constexpr static bool enabled_{false};
2524
#endif
26-
// NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables)
25+
// NOLINT BEGIN(cppcoreguidelines-avoid-non-const-global-variables)
2726
inline static std::atomic_size_t reactor_instances_{0};
2827
inline static std::atomic_size_t connections_{0};
2928
inline static std::atomic_size_t reactions_{0};
@@ -34,7 +33,7 @@ private:
3433
inline static std::atomic_size_t triggered_actions_{0};
3534
inline static std::atomic_size_t set_ports_{0};
3635
inline static std::atomic_size_t scheduled_actions_{0};
37-
// NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables)
36+
// NOLINT END(cppcoreguidelines-avoid-non-const-global-variables)
3837

3938
static void increment(std::atomic_size_t& counter) {
4039
if constexpr (enabled_) {

include/reactor-cpp/time_barrier.hh

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef REACTOR_CPP_TIME_BARRIER_HH
1010
#define REACTOR_CPP_TIME_BARRIER_HH
1111

12-
#include "fwd.hh"
1312
#include "logical_time.hh"
1413
#include "scheduler.hh"
1514
#include "time.hh"

include/reactor-cpp/value_ptr.hh

+2-5
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
#include <memory>
1919
#include <type_traits>
2020

21-
#include "reactor-cpp/logging.hh"
22-
2321
namespace reactor {
2422

2523
namespace detail {
@@ -459,16 +457,15 @@ public:
459457
// get_mutable_copy()
460458
friend class ImmutableValuePtr<T, true>;
461459

462-
// Give the factory function make_mutable_value() access to the private
463-
// constructor
460+
// Give the factory function make_mutable_value() access to the private constructor
464461
template <class U, class... Args>
465462
friend auto reactor::make_mutable_value(Args&&... args) -> reactor::MutableValuePtr<U>;
466463
};
467464

468465
template <class T> class ImmutableValuePtr<T, true> {
469466
public:
470467
/// A type alias that adds ``const`` to ``T``
471-
using const_T = typename std::add_const_t<T>;
468+
using const_T = std::add_const_t<T>;
472469

473470
private:
474471
T value_{};

0 commit comments

Comments
 (0)