Merge lp:~charlesk/indicator-datetime/add-cppcheck into lp:indicator-datetime/15.10

Proposed by Charles Kerr
Status: Needs review
Proposed branch: lp:~charlesk/indicator-datetime/add-cppcheck
Merge into: lp:indicator-datetime/15.10
Diff against target: 237 lines (+25/-16)
18 files modified
debian/control (+1/-0)
include/datetime/clock.h (+1/-1)
include/datetime/timezone-file.h (+1/-1)
src/awake.cpp (+1/-1)
src/clock.cpp (+1/-1)
src/exporter.cpp (+1/-1)
src/formatter-desktop.cpp (+1/-1)
src/haptic.cpp (+1/-1)
src/notifications.cpp (+1/-1)
src/planner-aggregate.cpp (+1/-1)
src/timezone-geoclue.cpp (+1/-1)
src/wakeup-timer-mainloop.cpp (+1/-1)
src/wakeup-timer-powerd.cpp (+1/-1)
tests/CMakeLists.txt (+8/-0)
tests/geoclue-fixture.h (+1/-1)
tests/test-dbus-fixture.h (+2/-2)
tests/test-timezone-geoclue.cpp (+1/-0)
tests/test-timezones.cpp (+0/-1)
To merge this branch: bzr merge lp:~charlesk/indicator-datetime/add-cppcheck
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Indicator Applet Developers Pending
Review via email: mp+266246@code.launchpad.net

Commit message

Add a cppcheck pass to the tests run by ctest.

Description of the change

Add a cppcheck pass to the tests run by ctest.

Various minor fixes spotted by cpptest; e.g. adding 'explicit' where applicable to single-argument ctors, removing dead stores

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
426. By Charles Kerr

sync with trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

426. By Charles Kerr

sync with trunk

425. By Charles Kerr

suppress false pureVirtualCall cppcheck failure. Lambda code blocks in menu's ctor invokes a pure virtual function, but the lambda's not invoked until later after the ctor is finished

424. By Charles Kerr

fix dead store (cppcheck)

423. By Charles Kerr

fix unnecesssary c_str() call (cppcheck)

422. By Charles Kerr

fix dead store due to missing test condition (cppcheck)

421. By Charles Kerr

in the DBus test fixture, ensure the bus fields are initialized to nullptr when the fixture is constructed. (cppcheck)

420. By Charles Kerr

fix possible nullptr dereference (cppcheck)

419. By Charles Kerr

add 'explicit' keyword to single-argument ctors (cppcheck)

418. By Charles Kerr

add cppcheck to the standard 'make test' invocation

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2015-07-28 08:42:25 +0000
3+++ debian/control 2015-09-10 14:07:25 +0000
4@@ -19,6 +19,7 @@
5 libdbustest1-dev,
6 dbus-test-runner,
7 python3-dbusmock,
8+ cppcheck,
9 # for 12h/24h locale unit tests:
10 locales,
11 language-pack-touch-en | language-pack-en-base,
12
13=== modified file 'include/datetime/clock.h'
14--- include/datetime/clock.h 2015-04-03 17:36:46 +0000
15+++ include/datetime/clock.h 2015-09-10 14:07:25 +0000
16@@ -74,7 +74,7 @@
17 class LiveClock: public Clock
18 {
19 public:
20- LiveClock (const std::shared_ptr<const Timezone>& zones);
21+ explicit LiveClock(const std::shared_ptr<const Timezone>& zones);
22 virtual ~LiveClock();
23 virtual DateTime localtime() const override;
24
25
26=== modified file 'include/datetime/timezone-file.h'
27--- include/datetime/timezone-file.h 2014-09-13 20:45:23 +0000
28+++ include/datetime/timezone-file.h 2015-09-10 14:07:25 +0000
29@@ -34,7 +34,7 @@
30 class FileTimezone: public Timezone
31 {
32 public:
33- FileTimezone(const std::string& filename);
34+ explicit FileTimezone(const std::string& filename);
35 ~FileTimezone();
36
37 private:
38
39=== modified file 'src/awake.cpp'
40--- src/awake.cpp 2015-03-31 18:54:26 +0000
41+++ src/awake.cpp 2015-09-10 14:07:25 +0000
42@@ -36,7 +36,7 @@
43 {
44 public:
45
46- Impl(const std::string& app_name):
47+ explicit Impl(const std::string& app_name):
48 m_app_name(app_name),
49 m_cancellable(g_cancellable_new())
50 {
51
52=== modified file 'src/clock.cpp'
53--- src/clock.cpp 2014-09-15 14:56:52 +0000
54+++ src/clock.cpp 2015-09-10 14:07:25 +0000
55@@ -40,7 +40,7 @@
56 {
57 public:
58
59- Impl(Clock& owner):
60+ explicit Impl(Clock& owner):
61 m_owner(owner),
62 m_cancellable(g_cancellable_new())
63 {
64
65=== modified file 'src/exporter.cpp'
66--- src/exporter.cpp 2014-09-02 15:37:03 +0000
67+++ src/exporter.cpp 2015-09-10 14:07:25 +0000
68@@ -37,7 +37,7 @@
69 {
70 public:
71
72- Impl(const std::shared_ptr<Settings>& settings):
73+ explicit Impl(const std::shared_ptr<Settings>& settings):
74 m_settings(settings),
75 m_alarm_props(datetime_alarm_properties_skeleton_new())
76 {
77
78=== modified file 'src/formatter-desktop.cpp'
79--- src/formatter-desktop.cpp 2014-03-28 00:25:34 +0000
80+++ src/formatter-desktop.cpp 2015-09-10 14:07:25 +0000
81@@ -46,7 +46,7 @@
82 {
83 str = date_string;
84 }
85- else // time_string
86+ else if (time_string)
87 {
88 str = time_string;
89 }
90
91=== modified file 'src/haptic.cpp'
92--- src/haptic.cpp 2014-08-01 00:52:42 +0000
93+++ src/haptic.cpp 2015-09-10 14:07:25 +0000
94@@ -37,7 +37,7 @@
95 {
96 public:
97
98- Impl(const Mode& mode):
99+ explicit Impl(const Mode& mode):
100 m_mode(mode),
101 m_cancellable(g_cancellable_new())
102 {
103
104=== modified file 'src/notifications.cpp'
105--- src/notifications.cpp 2014-09-17 17:08:01 +0000
106+++ src/notifications.cpp 2015-09-10 14:07:25 +0000
107@@ -115,7 +115,7 @@
108
109 public:
110
111- Impl(const std::string& app_name):
112+ explicit Impl(const std::string& app_name):
113 m_app_name(app_name)
114 {
115 if (!notify_init(app_name.c_str()))
116
117=== modified file 'src/planner-aggregate.cpp'
118--- src/planner-aggregate.cpp 2014-09-02 15:35:27 +0000
119+++ src/planner-aggregate.cpp 2015-09-10 14:07:25 +0000
120@@ -30,7 +30,7 @@
121 class AggregatePlanner::Impl
122 {
123 public:
124- Impl(AggregatePlanner* owner):
125+ explicit Impl(AggregatePlanner* owner):
126 m_owner(owner)
127 {
128 }
129
130=== modified file 'src/timezone-geoclue.cpp'
131--- src/timezone-geoclue.cpp 2014-09-13 20:45:23 +0000
132+++ src/timezone-geoclue.cpp 2015-09-10 14:07:25 +0000
133@@ -36,7 +36,7 @@
134
135 public:
136
137- Impl(GeoclueTimezone& owner):
138+ explicit Impl(GeoclueTimezone& owner):
139 m_owner(owner),
140 m_cancellable(g_cancellable_new())
141 {
142
143=== modified file 'src/wakeup-timer-mainloop.cpp'
144--- src/wakeup-timer-mainloop.cpp 2014-06-10 14:00:14 +0000
145+++ src/wakeup-timer-mainloop.cpp 2015-09-10 14:07:25 +0000
146@@ -36,7 +36,7 @@
147
148 public:
149
150- Impl(const std::shared_ptr<Clock>& clock):
151+ explicit Impl(const std::shared_ptr<Clock>& clock):
152 m_clock(clock)
153 {
154 }
155
156=== modified file 'src/wakeup-timer-powerd.cpp'
157--- src/wakeup-timer-powerd.cpp 2014-11-04 18:27:27 +0000
158+++ src/wakeup-timer-powerd.cpp 2015-09-10 14:07:25 +0000
159@@ -38,7 +38,7 @@
160 {
161 public:
162
163- Impl(const std::shared_ptr<Clock>& clock):
164+ explicit Impl(const std::shared_ptr<Clock>& clock):
165 m_clock(clock),
166 m_cancellable(g_cancellable_new())
167 {
168
169=== modified file 'tests/CMakeLists.txt'
170--- tests/CMakeLists.txt 2015-07-22 12:00:11 +0000
171+++ tests/CMakeLists.txt 2015-09-10 14:07:25 +0000
172@@ -36,6 +36,14 @@
173 include_directories (${CMAKE_CURRENT_BINARY_DIR})
174 include_directories (${DBUSTEST_INCLUDE_DIRS})
175
176+add_test(cppcheck cppcheck
177+ --quiet
178+ --enable=all
179+ --error-exitcode=2
180+ --suppress=pureVirtualCall
181+ -I${CMAKE_SOURCE_DIR}/include
182+ ${CMAKE_SOURCE_DIR}/src
183+ ${CMAKE_SOURCE_DIR}/tests)
184
185 add_definitions (-DSANDBOX="${CMAKE_CURRENT_BINARY_DIR}")
186
187
188=== modified file 'tests/geoclue-fixture.h'
189--- tests/geoclue-fixture.h 2014-09-17 16:51:51 +0000
190+++ tests/geoclue-fixture.h 2015-09-10 14:07:25 +0000
191@@ -146,7 +146,7 @@
192
193 void setGeoclueTimezoneOnIdle (const std::string& newZone)
194 {
195- g_timeout_add (50, emit_address_changed_idle, new EmitAddressChangedData(mock, obj_geo_addr, newZone.c_str()));
196+ g_timeout_add (50, emit_address_changed_idle, new EmitAddressChangedData(mock, obj_geo_addr, newZone));
197 }
198
199 };
200
201=== modified file 'tests/test-dbus-fixture.h'
202--- tests/test-dbus-fixture.h 2014-09-17 16:51:51 +0000
203+++ tests/test-dbus-fixture.h 2015-09-10 14:07:25 +0000
204@@ -65,8 +65,8 @@
205
206 protected:
207
208- GTestDBus * test_dbus;
209- GDBusConnection * system_bus;
210+ GTestDBus * test_dbus = nullptr;
211+ GDBusConnection * system_bus = nullptr;
212 const std::vector<std::string> service_dirs;
213
214 virtual void SetUp() override
215
216=== modified file 'tests/test-timezone-geoclue.cpp'
217--- tests/test-timezone-geoclue.cpp 2014-01-31 00:40:13 +0000
218+++ tests/test-timezone-geoclue.cpp 2015-09-10 14:07:25 +0000
219@@ -44,5 +44,6 @@
220 const std::string timezone_2 = "America/Chicago";
221 setGeoclueTimezoneOnIdle(timezone_2);
222 g_main_loop_run(loop);
223+ EXPECT_TRUE(changed);
224 EXPECT_EQ(timezone_2, tz.timezone.get());
225 }
226
227=== modified file 'tests/test-timezones.cpp'
228--- tests/test-timezones.cpp 2014-09-17 16:51:51 +0000
229+++ tests/test-timezones.cpp 2015-09-10 14:07:25 +0000
230@@ -90,7 +90,6 @@
231 EXPECT_EQ(2, zones.size());
232 EXPECT_EQ(1, zones.count(timezone_file));
233 EXPECT_EQ(1, zones.count(timezone_geo));
234- zones_changed = false;
235
236 // now tweak the geoclue value... the geoclue-detected timezone should change,
237 // causing the 'timezones' property to change

Subscribers

People subscribed via source and target branches