Skip to content

Commit b62c6b1

Browse files
committed
Code quality improvements
1 parent 3e07e4f commit b62c6b1

32 files changed

+249
-113
lines changed

.clang-tidy

+147
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# Generated from CLion Inspection settings
2+
---
3+
Checks: '-*,
4+
bugprone-argument-comment,
5+
bugprone-assert-side-effect,
6+
bugprone-bad-signal-to-kill-thread,
7+
bugprone-branch-clone,
8+
bugprone-copy-constructor-init,
9+
bugprone-dangling-handle,
10+
bugprone-dynamic-static-initializers,
11+
bugprone-fold-init-type,
12+
bugprone-forward-declaration-namespace,
13+
bugprone-forwarding-reference-overload,
14+
bugprone-inaccurate-erase,
15+
bugprone-incorrect-roundings,
16+
bugprone-integer-division,
17+
bugprone-lambda-function-name,
18+
bugprone-macro-parentheses,
19+
bugprone-macro-repeated-side-effects,
20+
bugprone-misplaced-operator-in-strlen-in-alloc,
21+
bugprone-misplaced-pointer-arithmetic-in-alloc,
22+
bugprone-misplaced-widening-cast,
23+
bugprone-move-forwarding-reference,
24+
bugprone-multiple-statement-macro,
25+
bugprone-no-escape,
26+
bugprone-not-null-terminated-result,
27+
bugprone-parent-virtual-call,
28+
bugprone-posix-return,
29+
bugprone-reserved-identifier,
30+
bugprone-sizeof-container,
31+
bugprone-sizeof-expression,
32+
bugprone-spuriously-wake-up-functions,
33+
bugprone-string-constructor,
34+
bugprone-string-integer-assignment,
35+
bugprone-string-literal-with-embedded-nul,
36+
bugprone-suspicious-enum-usage,
37+
bugprone-suspicious-include,
38+
bugprone-suspicious-memory-comparison,
39+
bugprone-suspicious-memset-usage,
40+
bugprone-suspicious-missing-comma,
41+
bugprone-suspicious-semicolon,
42+
bugprone-suspicious-string-compare,
43+
bugprone-swapped-arguments,
44+
bugprone-terminating-continue,
45+
bugprone-throw-keyword-missing,
46+
bugprone-too-small-loop-variable,
47+
bugprone-undefined-memory-manipulation,
48+
bugprone-undelegated-constructor,
49+
bugprone-unhandled-self-assignment,
50+
bugprone-unused-raii,
51+
bugprone-unused-return-value,
52+
bugprone-use-after-move,
53+
bugprone-virtual-near-miss,
54+
cert-dcl21-cpp,
55+
cert-dcl58-cpp,
56+
cert-err34-c,
57+
cert-err52-cpp,
58+
cert-err60-cpp,
59+
cert-flp30-c,
60+
cert-msc50-cpp,
61+
cert-msc51-cpp,
62+
cert-str34-c,
63+
cppcoreguidelines-interfaces-global-init,
64+
cppcoreguidelines-narrowing-conversions,
65+
cppcoreguidelines-pro-type-member-init,
66+
cppcoreguidelines-pro-type-static-cast-downcast,
67+
cppcoreguidelines-slicing,
68+
google-default-arguments,
69+
google-explicit-constructor,
70+
google-runtime-operator,
71+
hicpp-exception-baseclass,
72+
hicpp-multiway-paths-covered,
73+
misc-misplaced-const,
74+
misc-new-delete-overloads,
75+
misc-no-recursion,
76+
misc-non-copyable-objects,
77+
misc-throw-by-value-catch-by-reference,
78+
misc-unconventional-assign-operator,
79+
misc-uniqueptr-reset-release,
80+
modernize-avoid-bind,
81+
modernize-concat-nested-namespaces,
82+
modernize-deprecated-headers,
83+
modernize-deprecated-ios-base-aliases,
84+
modernize-loop-convert,
85+
modernize-make-shared,
86+
modernize-make-unique,
87+
modernize-pass-by-value,
88+
modernize-raw-string-literal,
89+
modernize-redundant-void-arg,
90+
modernize-replace-auto-ptr,
91+
modernize-replace-disallow-copy-and-assign-macro,
92+
modernize-replace-random-shuffle,
93+
modernize-return-braced-init-list,
94+
modernize-shrink-to-fit,
95+
modernize-unary-static-assert,
96+
modernize-use-auto,
97+
modernize-use-bool-literals,
98+
modernize-use-emplace,
99+
modernize-use-equals-default,
100+
modernize-use-equals-delete,
101+
modernize-use-nodiscard,
102+
modernize-use-noexcept,
103+
modernize-use-nullptr,
104+
modernize-use-override,
105+
modernize-use-transparent-functors,
106+
modernize-use-uncaught-exceptions,
107+
mpi-buffer-deref,
108+
mpi-type-mismatch,
109+
openmp-use-default-none,
110+
performance-faster-string-find,
111+
performance-for-range-copy,
112+
performance-implicit-conversion-in-loop,
113+
performance-inefficient-algorithm,
114+
performance-inefficient-string-concatenation,
115+
performance-inefficient-vector-operation,
116+
performance-move-const-arg,
117+
performance-move-constructor-init,
118+
performance-no-automatic-move,
119+
performance-noexcept-move-constructor,
120+
performance-trivially-destructible,
121+
performance-type-promotion-in-math-fn,
122+
performance-unnecessary-copy-initialization,
123+
performance-unnecessary-value-param,
124+
portability-simd-intrinsics,
125+
readability-avoid-const-params-in-decls,
126+
readability-const-return-type,
127+
readability-container-size-empty,
128+
readability-convert-member-functions-to-static,
129+
readability-delete-null-pointer,
130+
readability-deleted-default,
131+
readability-inconsistent-declaration-parameter-name,
132+
readability-make-member-function-const,
133+
readability-misleading-indentation,
134+
readability-misplaced-array-index,
135+
readability-non-const-parameter,
136+
readability-redundant-control-flow,
137+
readability-redundant-declaration,
138+
readability-redundant-function-ptr-dereference,
139+
readability-redundant-smartptr-get,
140+
readability-redundant-string-cstr,
141+
readability-redundant-string-init,
142+
readability-simplify-subscript-expr,
143+
readability-static-accessed-through-instance,
144+
readability-static-definition-in-anonymous-namespace,
145+
readability-string-compare,
146+
readability-uniqueptr-delete-release,
147+
readability-use-anyofallof'

Source/Box.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ void Box::updatePorts()
428428
edge->setTooltip(tooltip);
429429
}
430430

431-
// Dont show for graphs or presentation mode
431+
// Don't show for graphs or presentation mode
432432
edge->setVisible(!(cnv->isGraph || cnv->presentationMode == var(true)));
433433
edge->repaint();
434434

Source/Canvas.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ void Canvas::mouseUp(const MouseEvent& e)
448448
}
449449
}
450450

451-
// Releasing a connect by drag action
451+
// Releasing a connect-by-drag action
452452
if (connectingWithDrag && connectingEdge)
453453
{
454454
if (nearestEdge)

Source/Connection.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ bool Connection::intersects(Rectangle<float> toCheck, int accuracy) const
173173
{
174174
auto point1 = Point<float>(i.x1, i.y1);
175175

176-
// Skip points to reduce accuracy a little bit for better performance
176+
// Skip points to reduce accuracy a bit for better performance
177177
for (int n = 0; n < accuracy; n++)
178178
{
179179
auto next = i.next();

Source/Connection.h

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ class Connection : public Component, public ComponentListener
7777
PathPlan currentPlan;
7878

7979
Value locked;
80-
Value connectionStyle;
8180

8281
Canvas* cnv;
8382

Source/Dialogs/Deken.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ class Deken : public Component, public ListBoxModel, public ScrollBar::Listener,
728728
}
729729
};
730730

731-
bool checkArchitecture(String platform)
731+
static bool checkArchitecture(String platform)
732732
{
733733
// Check OS
734734
if (platform.upToFirstOccurrenceOf("-", false, false) != os) return false;
@@ -743,8 +743,8 @@ class Deken : public Component, public ListBoxModel, public ScrollBar::Listener,
743743
return false;
744744
}
745745

746-
String floatsize = String(PD_FLOATSIZE);
747-
String os =
746+
static inline const String floatsize = String(PD_FLOATSIZE);
747+
static inline const String os =
748748
#if JUCE_LINUX
749749
"Linux"
750750
#elif JUCE_MAC
@@ -766,7 +766,7 @@ class Deken : public Component, public ListBoxModel, public ScrollBar::Listener,
766766
#endif
767767
;
768768

769-
StringArray machine =
769+
static inline const StringArray machine =
770770
#if defined(__x86_64__) || defined(__amd64__) || defined(_M_X64) || defined(_M_AMD64)
771771
{"amd64", "x86_64"}
772772
#elif defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(_M_IX86)

Source/Dialogs/Dialogs.h

-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ struct Dialog : public Component
8686

8787
struct Dialogs
8888
{
89-
Dialogs();
90-
9189
static void showSaveDialog(Component* centre, String filename, std::function<void(int)> callback);
9290
static void showArrayDialog(Component* centre, std::function<void(int, String, String)> callback);
9391

Source/Dialogs/SettingsDialog.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct ThemePanel : public Component, public Value::Listener
1212

1313
OwnedArray<PropertiesPanel::Property> panels;
1414

15-
ThemePanel(ValueTree globalSettings) : settingsTree(globalSettings)
15+
explicit ThemePanel(ValueTree globalSettings) : settingsTree(globalSettings)
1616
{
1717
fontValue.setValue(LookAndFeel::getDefaultLookAndFeel().getTypefaceForFont(Font())->getName());
1818
fontValue.addListener(this);

Source/Objects/ArrayObject.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,27 @@ class PdArray
2525
PdArray() = default;
2626

2727
// Gets the name of the array.
28-
String getName() const noexcept
28+
String getName() const
2929
{
3030
return name;
3131
}
3232

33-
PdArray::DrawType getDrawType() const noexcept
33+
PdArray::DrawType getDrawType() const
3434
{
3535
libpd_set_instance(static_cast<t_pdinstance*>(instance));
3636
return static_cast<DrawType>(libpd_array_get_style(name.toRawUTF8()));
3737
}
3838

3939
// Gets the scale of the array.
40-
std::array<float, 2> getScale() const noexcept
40+
std::array<float, 2> getScale() const
4141
{
4242
float min = -1, max = 1;
4343
libpd_set_instance(static_cast<t_pdinstance*>(instance));
4444
libpd_array_get_scale(name.toRawUTF8(), &min, &max);
4545
return {min, max};
4646
}
4747

48-
void setScale(std::array<float, 2> scale) noexcept
48+
void setScale(std::array<float, 2> scale)
4949
{
5050
auto& [min, max] = scale;
5151
libpd_set_instance(static_cast<t_pdinstance*>(instance));
@@ -282,7 +282,7 @@ struct GraphicalArray : public Component
282282
}
283283
}
284284

285-
size_t getArraySize() const noexcept
285+
size_t getArraySize() const
286286
{
287287
return vec.size();
288288
}
@@ -470,7 +470,7 @@ struct ArrayObject final : public GUIObject
470470
g.drawRoundedRectangle(getLocalBounds().toFloat().reduced(0.5f), 2.0f, 1.0f);
471471
}
472472

473-
PdArray getArray() const noexcept
473+
PdArray getArray() const
474474
{
475475
return {libpd_array_get_name(static_cast<t_canvas*>(ptr)->gl_list), cnv->pd->m_instance};
476476
}

Source/Objects/AtomObject.h

+17-10
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,16 @@ struct AtomObject : public GUIObject
7676
auto* gatom = static_cast<t_fake_gatom*>(ptr);
7777
gatom->a_text.te_width = b.getWidth() / fontWidth;
7878
}
79-
79+
8080
void resized() override
8181
{
82+
int fontWidth = glist_fontwidth(cnv->patch.getPointer());
83+
int width = jlimit(30, maxSize, (getWidth() / fontWidth) * fontWidth);
84+
int height = jlimit(18, maxSize, getHeight());
85+
if (getWidth() != width || getHeight() != height)
86+
{
87+
box->setSize(width + Box::doubleMargin, height + Box::doubleMargin);
88+
}
8289
}
8390

8491
int getAtomHeight() const
@@ -192,17 +199,17 @@ struct AtomObject : public GUIObject
192199
}
193200
}
194201

195-
float getFontHeight() const noexcept
202+
float getFontHeight() const
196203
{
197204
return static_cast<t_fake_gatom*>(ptr)->a_fontsize;
198205
}
199206

200-
void setFontHeight(float newSize) noexcept
207+
void setFontHeight(float newSize)
201208
{
202209
static_cast<t_fake_gatom*>(ptr)->a_fontsize = newSize;
203210
}
204211

205-
Rectangle<int> getLabelBounds() const noexcept
212+
Rectangle<int> getLabelBounds() const
206213
{
207214
auto objectBounds = box->getBounds().reduced(Box::margin);
208215
int fontHeight = getAtomHeight() - 6;
@@ -267,25 +274,25 @@ struct AtomObject : public GUIObject
267274
atom->a_label = gensym(newText.toRawUTF8());
268275
}
269276

270-
void setLabelPosition(int wherelabel) noexcept
277+
void setLabelPosition(int wherelabel)
271278
{
272279
auto* gatom = static_cast<t_fake_gatom*>(ptr);
273280
gatom->a_wherelabel = wherelabel - 1;
274281
}
275282

276-
String getSendSymbol() noexcept
283+
String getSendSymbol()
277284
{
278285
auto* atom = static_cast<t_fake_gatom*>(ptr);
279286
return String(atom->a_symfrom->s_name);
280287
}
281288

282-
String getReceiveSymbol() noexcept
289+
String getReceiveSymbol()
283290
{
284291
auto* atom = static_cast<t_fake_gatom*>(ptr);
285292
return String(atom->a_symto->s_name);
286293
}
287294

288-
void setSendSymbol(const String& symbol) const noexcept
295+
void setSendSymbol(const String& symbol) const
289296
{
290297
if (symbol.isEmpty()) return;
291298

@@ -294,7 +301,7 @@ struct AtomObject : public GUIObject
294301
atom->a_expanded_to = canvas_realizedollar(atom->a_glist, atom->a_symto);
295302
}
296303

297-
void setReceiveSymbol(const String& symbol) const noexcept
304+
void setReceiveSymbol(const String& symbol) const
298305
{
299306
if (symbol.isEmpty()) return;
300307

@@ -323,7 +330,7 @@ struct AtomObject : public GUIObject
323330
}
324331

325332
/* undo previous operation: strip leading "-" if found. This is used
326-
both to restore send, etc, names when loading from a file, and to
333+
both to restore send, etc., names when loading from a file, and to
327334
set them from the properties dialog. In the former case, since before
328335
version 0.52 '$" was aliases to "#", we also bash any "#" characters
329336
to "$". This is unnecessary when reading files saved from 0.52 or later,

Source/Objects/BangObject.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ struct BangObject final : public IEMObject
126126
}
127127
}
128128

129-
float getMaximum() const noexcept
129+
float getMaximum() const
130130
{
131131
return (static_cast<t_my_numbox*>(ptr))->x_max;
132132
}

0 commit comments

Comments
 (0)