Skip to content

Commit 1c7e6ca

Browse files
committed
More clang-tidy fixes
1 parent d5af39d commit 1c7e6ca

16 files changed

+190
-78
lines changed

.clang-tidy

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This is a generated file do not edit but instead edit .clang-tidy.checks and .clang-tidy.settings
2+
3+
Checks: '*,-abseil*,-altera-*,-android-*,-boost-*,-cppcoreguidelines-*,-darwin-*,-fuchsia-*,-hicpp-*,-llvmlibc-*,-linuxkernel-*,-mpi-*,-objc-*,-openmp-*,-zircon-*,-bugprone-unchecked-optional-access,-bugprone-narrowing-conversions,-bugprone-easily-swappable-parameters,-bugprone-branch-clone,-bugprone-implicit-widening-of-multiplication-result,-bugprone-suspicious-include,-bugprone-integer-division,-bugprone-suspicious-enum-usage,-cert-err58-cpp,-cert-dcl21-cpp,-cert-dcl50-cpp,-clang-analyzer-alpha*,-clang-analyzer-osx.*,-clang-analyzer-webkit.*,-clang-analyzer-cplusplus.NewDeleteLeaks,-clang-analyzer-core.CallAndMessage,-clang-analyzer-alpha.core.CastToStruct,-clang-analyzer-alpha.deadcode.UnreachableCode,-clang-analyzer-core.NonNullParamChecker,-concurrency-*,-clang-diagnostic-pragma-once-outside-header,-google-*,google-explicit-constructor,google-readability-namespace-comments,-llvm-include-order,-llvm-namespace-comment,-llvm-qualified-auto,-llvm-else-after-return,-llvm-header-guard,-misc-no-recursion,-misc-non-private-member-variables-in-classes,-misc-const-correctness,-misc-include-cleaner,-modernize-use-override,-modernize-use-bool-literals,-modernize-pass-by-value,-modernize-raw-string-literal,-modernize-use-using,-modernize-loop-convert,-modernize-return-braced-init-list,-modernize-use-equals-default,-modernize-use-trailing-return-type,-modernize-use-nodiscard,-modernize-avoid-bind,-modernize-avoid-c-arrays,-modernize-type-traits,-performance-unnecessary-copy-initialization,-performance-no-automatic-move,-performance-no-int-to-ptr,-performance-enum-size,-readability-else-after-return,-readability-named-parameter,-readability-implicit-bool-conversion,-readability-namespace-comments,-readability-qualified-auto,-readability-magic-numbers,-readability-braces-around-statements,-readability-function-cognitive-complexity,-readability-const-return-type,-readability-inconsistent-declaration-parameter-name,-readability-simplify-boolean-expr,-readability-redundant-access-specifiers,-readability-identifier-length,-readability-misleading-indentation,-readability-make-member-function-const,-readability-suspicious-call-argument,-readability-avoid-nested-conditional-operator,-clang-analyzer-security.insecureAPI.*,-performance-unnecessary-value-param,-readability-convert-member-functions-to-static,-bugprone-misplaced-widening-cast,'
4+
5+
CheckOptions:
6+
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
7+
value: 1
8+
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted
9+
value: 1
10+
- key: performance-move-const-arg.CheckTriviallyCopyableMove
11+
value: 0

.clang-tidy.checks

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# I want all checks by default. That way I'll have to black list new checks rather than whitelist them
2+
*
3+
4+
-abseil* # Try
5+
-altera-*
6+
-android-*
7+
-boost-*
8+
-cppcoreguidelines-* # Try
9+
-darwin-*
10+
-fuchsia-*
11+
-hicpp-* # Tryu
12+
-llvmlibc-*
13+
-linuxkernel-*
14+
-mpi-*
15+
-objc-*
16+
-openmp-*
17+
-zircon-*
18+
19+
-bugprone-unchecked-optional-access # https://github.com/llvm/llvm-project/issues/55530
20+
-bugprone-narrowing-conversions
21+
-bugprone-easily-swappable-parameters
22+
-bugprone-branch-clone
23+
-bugprone-implicit-widening-of-multiplication-result
24+
-bugprone-suspicious-include # This one doesn't like us importing moc_XXX.cpp files
25+
-bugprone-integer-division
26+
-bugprone-suspicious-enum-usage # in Qt5 this complains about Qt::CTRL | Qt::Key_a which is the right way to do it in Qt6
27+
28+
-cert-err58-cpp
29+
-cert-dcl21-cpp
30+
31+
# I only use this when I ignore the parameters altogether (See ContactsPage.cpp e.g)
32+
-cert-dcl50-cpp
33+
34+
-clang-analyzer-alpha*
35+
-clang-analyzer-osx.*
36+
-clang-analyzer-webkit.*
37+
-clang-analyzer-cplusplus.NewDeleteLeaks
38+
-clang-analyzer-core.CallAndMessage
39+
-clang-analyzer-alpha.core.CastToStruct
40+
-clang-analyzer-alpha.deadcode.UnreachableCode
41+
-clang-analyzer-core.NonNullParamChecker
42+
43+
-concurrency-*
44+
45+
# This gives false possitive in all header files.
46+
-clang-diagnostic-pragma-once-outside-header
47+
48+
-google-* # Try
49+
google-explicit-constructor
50+
google-readability-namespace-comments
51+
52+
-llvm-include-order
53+
-llvm-namespace-comment
54+
-llvm-qualified-auto
55+
-llvm-else-after-return
56+
-llvm-header-guard # complains even though we have #pragma once
57+
58+
-misc-no-recursion
59+
-misc-non-private-member-variables-in-classes # I agree instance variables should be private, but often I do this by design - too noisy.
60+
-misc-const-correctness # Lots of hits, lets ignore it for now.
61+
-misc-include-cleaner # Completely broken as of Oct 2023
62+
63+
-modernize-use-override
64+
-modernize-use-bool-literals
65+
-modernize-pass-by-value
66+
-modernize-raw-string-literal
67+
-modernize-use-using
68+
-modernize-loop-convert
69+
-modernize-return-braced-init-list
70+
-modernize-use-equals-default
71+
-modernize-use-trailing-return-type
72+
-modernize-use-nodiscard
73+
-modernize-avoid-bind
74+
-modernize-avoid-c-arrays
75+
-modernize-type-traits # Lots of errors from QTestLib
76+
77+
-performance-unnecessary-copy-initialization
78+
-performance-no-automatic-move # often doesn't do much of a difference in Qt apps, due to their ref counting.
79+
-performance-no-int-to-ptr
80+
-performance-enum-size # int is faster than int8_t
81+
82+
-readability-else-after-return
83+
-readability-named-parameter
84+
-readability-implicit-bool-conversion # Lots of warnings about if (myPointer) -> if (myPointer != nullptr)
85+
-readability-namespace-comments
86+
-readability-qualified-auto
87+
-readability-magic-numbers
88+
-readability-braces-around-statements
89+
-readability-function-cognitive-complexity
90+
-readability-const-return-type
91+
-readability-inconsistent-declaration-parameter-name
92+
-readability-simplify-boolean-expr
93+
-readability-redundant-access-specifiers
94+
-readability-identifier-length
95+
-readability-misleading-indentation
96+
-readability-make-member-function-const # complains about functions updating pointers too
97+
-readability-suspicious-call-argument
98+
-readability-avoid-nested-conditional-operator # I simply do not agree that this is hard to read, esp with clang-format formatting it nicely
99+
100+
-clang-analyzer-security.insecureAPI.*
101+
102+
# Try all the rest in this file
103+
-performance-unnecessary-value-param
104+
-readability-convert-member-functions-to-static
105+
-bugprone-misplaced-widening-cast

.clang-tidy.settings

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CheckOptions:
2+
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
3+
value: 1
4+
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted
5+
value: 1
6+
- key: performance-move-const-arg.CheckTriviallyCopyableMove
7+
value: 0

QXlsx/header/xlsxdocument.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class QXLSX_EXPORT Document : public QObject
130130
bool autosizeColumnWidth(const CellRange &range);
131131
bool autosizeColumnWidth(int column);
132132
bool autosizeColumnWidth(int colFirst, int colLast);
133-
bool autosizeColumnWidth(void);
133+
bool autosizeColumnWidth();
134134

135135
private:
136136
QMap<int, int> getMaximalColumnWidth(int firstRow = 1, int lastRow = INT_MAX);

QXlsx/header/xlsxworksheet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class QXLSX_EXPORT Worksheet : public AbstractSheet
186186
void setWhiteSpaceVisible(bool visible);
187187
bool setStartPage(int spagen); // add by liufeijin20181028
188188

189-
QVector<CellLocation> getFullCells(int *maxRow, int *maxCol);
189+
QVector<CellLocation> getFullCells(int *maxRow, int *maxCol) const;
190190

191191
private:
192192
void saveToXmlFile(QIODevice *device) const override;

QXlsx/source/xlsxcell.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ Cell::Cell(const Cell *const cell)
8484
*/
8585
Cell::~Cell()
8686
{
87-
if (nullptr != d_ptr)
88-
delete d_ptr;
87+
delete d_ptr;
8988
}
9089

9190
/*!

QXlsx/source/xlsxcellformula.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ CellFormula::CellFormula(const CellFormula &other)
104104
*/
105105
CellFormula &CellFormula::operator=(const CellFormula &other)
106106
{
107-
d = other.d;
107+
if (this != &other) // Self-assignment check [cert-oop54-cpp]
108+
{
109+
this->d = other.d;
110+
}
108111
return *this;
109112
}
110113

QXlsx/source/xlsxchart.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,25 +1168,6 @@ void ChartPrivate::saveXmlSer(QXmlStreamWriter &writer, XlsxSeries *ser, int id)
11681168
writer.writeEndElement();
11691169
}
11701170

1171-
#if 0
1172-
if (!ser->axDataSource_numRef.isEmpty())
1173-
{
1174-
if (chartType == Chart::CT_ScatterChart || chartType == Chart::CT_BubbleChart)
1175-
{
1176-
writer.writeStartElement(QStringLiteral("c:xVal"));
1177-
}
1178-
else
1179-
{
1180-
writer.writeStartElement(QStringLiteral("c:cat"));
1181-
}
1182-
1183-
writer.writeStartElement(QStringLiteral("c:numRef"));
1184-
writer.writeTextElement(QStringLiteral("c:f"), ser->axDataSource_numRef);
1185-
writer.writeEndElement();//c:numRef
1186-
writer.writeEndElement();//c:cat or c:xVal
1187-
}
1188-
#endif
1189-
11901171
if (!ser->numberDataSource_numRef.isEmpty()) {
11911172
if (chartType == Chart::CT_ScatterChart || chartType == Chart::CT_BubbleChart)
11921173
writer.writeStartElement(QStringLiteral("c:yVal"));

QXlsx/source/xlsxchartsheet.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ Chartsheet::Chartsheet(const QString &name, int id, Workbook *workbook, CreateFl
4242
if (flag == Chartsheet::F_NewFromScratch) {
4343
d_func()->drawing = std::make_shared<Drawing>(this, flag);
4444

45-
DrawingAbsoluteAnchor *anchor =
46-
new DrawingAbsoluteAnchor(drawing(), DrawingAnchor::Picture);
45+
auto anchor = new DrawingAbsoluteAnchor(drawing(), DrawingAnchor::Picture);
4746

4847
anchor->pos = QPoint(0, 0);
4948
anchor->ext = QSize(9293679, 6068786);

QXlsx/source/xlsxconditionalformatting.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ ConditionalFormatting::ConditionalFormatting(const ConditionalFormatting &other)
147147
*/
148148
ConditionalFormatting &ConditionalFormatting::operator=(const ConditionalFormatting &other)
149149
{
150-
this->d = other.d;
150+
if (this != &other) // Self-assignment check [cert-oop54-cpp]
151+
{
152+
this->d = other.d;
153+
}
151154
return *this;
152155
}
153156

@@ -786,9 +789,11 @@ bool ConditionalFormatting::saveToXml(QXmlStreamWriter &writer) const
786789
writer.writeTextElement(QStringLiteral("formula"),
787790
it.value().toString().arg(startCell));
788791
}
789-
} else if ((it = rule->attrs.constFind(XlsxCfRuleData::A_formula1)) !=
790-
rule->attrs.constEnd()) {
791-
writer.writeTextElement(QStringLiteral("formula"), it.value().toString());
792+
} else {
793+
it = rule->attrs.constFind(XlsxCfRuleData::A_formula1);
794+
if (it != rule->attrs.constEnd()) {
795+
writer.writeTextElement(QStringLiteral("formula"), it.value().toString());
796+
}
792797
}
793798

794799
it = rule->attrs.constFind(XlsxCfRuleData::A_formula2);

0 commit comments

Comments
 (0)