Skip to content

Commit d6fa6cf

Browse files
chore: update global workflows (#134)
Co-authored-by: ReenigneArcher <[email protected]>
1 parent 63599b0 commit d6fa6cf

File tree

79 files changed

+2216
-2552
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+2216
-2552
lines changed

.clang-format

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,34 @@
66
# Generated from CLion C/C++ Code Style settings
77
BasedOnStyle: LLVM
88
AccessModifierOffset: -2
9-
AlignAfterOpenBracket: DontAlign
10-
AlignConsecutiveAssignments: false
9+
AlignAfterOpenBracket: BlockIndent
10+
AlignConsecutiveAssignments: None
11+
AlignEscapedNewlines: DontAlign
1112
AlignOperands: Align
1213
AllowAllArgumentsOnNextLine: false
1314
AllowAllConstructorInitializersOnNextLine: false
1415
AllowAllParametersOfDeclarationOnNextLine: false
15-
AllowShortBlocksOnASingleLine: Always
16+
AllowShortBlocksOnASingleLine: Empty
1617
AllowShortCaseLabelsOnASingleLine: false
17-
AllowShortFunctionsOnASingleLine: All
18-
AllowShortIfStatementsOnASingleLine: WithoutElse
19-
AllowShortLambdasOnASingleLine: All
18+
AllowShortEnumsOnASingleLine: false
19+
AllowShortFunctionsOnASingleLine: Empty
20+
AllowShortIfStatementsOnASingleLine: Never
21+
AllowShortLambdasOnASingleLine: None
2022
AllowShortLoopsOnASingleLine: true
2123
AlignTrailingComments: false
22-
AlwaysBreakAfterReturnType: All
24+
AlwaysBreakAfterDefinitionReturnType: None
25+
AlwaysBreakAfterReturnType: None
26+
AlwaysBreakBeforeMultilineStrings: true
2327
AlwaysBreakTemplateDeclarations: MultiLine
24-
BreakBeforeBraces: Custom
28+
BinPackArguments: false
29+
BinPackParameters: false
30+
BracedInitializerIndentWidth: 2
2531
BraceWrapping:
2632
AfterCaseLabel: false
2733
AfterClass: false
2834
AfterControlStatement: Never
2935
AfterEnum: false
36+
AfterExternBlock: true
3037
AfterFunction: false
3138
AfterNamespace: false
3239
AfterObjCDeclaration: false
@@ -36,39 +43,75 @@ BraceWrapping:
3643
IndentBraces: false
3744
SplitEmptyFunction: false
3845
SplitEmptyRecord: true
46+
BreakArrays: true
3947
BreakBeforeBinaryOperators: None
48+
BreakBeforeBraces: Attach
4049
BreakBeforeTernaryOperators: false
4150
BreakConstructorInitializers: AfterColon
4251
BreakInheritanceList: AfterColon
4352
ColumnLimit: 0
4453
CompactNamespaces: false
4554
ContinuationIndentWidth: 2
55+
Cpp11BracedListStyle: true
56+
EmptyLineAfterAccessModifier: Never
57+
EmptyLineBeforeAccessModifier: Always
58+
ExperimentalAutoDetectBinPacking: true
59+
FixNamespaceComments: true
60+
IncludeBlocks: Regroup
61+
IndentAccessModifiers: false
62+
IndentCaseBlocks: true
4663
IndentCaseLabels: true
64+
IndentExternBlock: Indent
65+
IndentGotoLabels: true
4766
IndentPPDirectives: BeforeHash
4867
IndentWidth: 2
68+
IndentWrappedFunctionNames: true
69+
InsertBraces: true
70+
InsertNewlineAtEOF: true
4971
KeepEmptyLinesAtTheStartOfBlocks: false
72+
LineEnding: LF
5073
MaxEmptyLinesToKeep: 1
5174
NamespaceIndentation: All
75+
ObjCBinPackProtocolList: Never
5276
ObjCSpaceAfterProperty: true
5377
ObjCSpaceBeforeProtocolList: true
78+
PackConstructorInitializers: Never
79+
PenaltyBreakBeforeFirstCallParameter: 1
80+
PenaltyBreakComment: 1
81+
PenaltyBreakString: 1
82+
PenaltyBreakFirstLessLess: 0
83+
PenaltyExcessCharacter: 1000000
84+
PenaltyReturnTypeOnItsOwnLine: 100000000
5485
PointerAlignment: Right
86+
ReferenceAlignment: Pointer
5587
ReflowComments: true
88+
RemoveBracesLLVM: false
89+
RemoveSemicolon: false
90+
SeparateDefinitionBlocks: Always
91+
SortIncludes: CaseInsensitive
92+
SortUsingDeclarations: Lexicographic
5693
SpaceAfterCStyleCast: true
5794
SpaceAfterLogicalNot: false
58-
SpaceAfterTemplateKeyword: true
95+
SpaceAfterTemplateKeyword: false
5996
SpaceBeforeAssignmentOperators: true
97+
SpaceBeforeCaseColon: false
6098
SpaceBeforeCpp11BracedList: true
6199
SpaceBeforeCtorInitializerColon: false
62100
SpaceBeforeInheritanceColon: false
101+
SpaceBeforeJsonColon: false
63102
SpaceBeforeParens: ControlStatements
64103
SpaceBeforeRangeBasedForLoopColon: true
104+
SpaceBeforeSquareBrackets: false
105+
SpaceInEmptyBlock: false
65106
SpaceInEmptyParentheses: false
66107
SpacesBeforeTrailingComments: 2
67108
SpacesInAngles: Never
68109
SpacesInCStyleCastParentheses: false
69110
SpacesInContainerLiterals: false
111+
SpacesInLineCommentPrefix:
112+
Maximum: 3
113+
Minimum: 1
70114
SpacesInParentheses: false
71115
SpacesInSquareBrackets: false
72116
TabWidth: 2
73-
Cpp11BracedListStyle: false
74117
UseTab: Never

scripts/update_clang_format.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
'tests',
99
]
1010
file_types = [
11+
'c',
1112
'cpp',
1213
'h',
14+
'h',
1315
'm',
1416
'mm'
1517
]

src/common/file_settings_persistence.cpp

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,30 @@
1515

1616
namespace display_device {
1717
FileSettingsPersistence::FileSettingsPersistence(std::filesystem::path filepath):
18-
m_filepath { std::move(filepath) } {
18+
m_filepath {std::move(filepath)} {
1919
if (m_filepath.empty()) {
20-
throw std::runtime_error { "Empty filename provided for FileSettingsPersistence!" };
20+
throw std::runtime_error {"Empty filename provided for FileSettingsPersistence!"};
2121
}
2222
}
2323

24-
bool
25-
FileSettingsPersistence::store(const std::vector<std::uint8_t> &data) {
24+
bool FileSettingsPersistence::store(const std::vector<std::uint8_t> &data) {
2625
try {
27-
std::ofstream stream { m_filepath, std::ios::binary | std::ios::trunc };
26+
std::ofstream stream {m_filepath, std::ios::binary | std::ios::trunc};
2827
if (!stream) {
2928
DD_LOG(error) << "Failed to open " << m_filepath << " for writing!";
3029
return false;
3130
}
3231

33-
std::copy(std::begin(data), std::end(data), std::ostreambuf_iterator<char> { stream });
32+
std::copy(std::begin(data), std::end(data), std::ostreambuf_iterator<char> {stream});
3433
return true;
35-
}
36-
catch (const std::exception &error) {
34+
} catch (const std::exception &error) {
3735
DD_LOG(error) << "Failed to write to " << m_filepath << "! Error:\n"
3836
<< error.what();
3937
return false;
4038
}
4139
}
4240

43-
std::optional<std::vector<std::uint8_t>>
44-
FileSettingsPersistence::load() const {
41+
std::optional<std::vector<std::uint8_t>> FileSettingsPersistence::load() const {
4542
if (std::error_code error_code; !std::filesystem::exists(m_filepath, error_code)) {
4643
if (error_code) {
4744
DD_LOG(error) << "Failed to load " << m_filepath << "! Error:\n"
@@ -53,24 +50,21 @@ namespace display_device {
5350
}
5451

5552
try {
56-
std::ifstream stream { m_filepath, std::ios::binary };
53+
std::ifstream stream {m_filepath, std::ios::binary};
5754
if (!stream) {
5855
DD_LOG(error) << "Failed to open " << m_filepath << " for reading!";
5956
return std::nullopt;
6057
}
6158

62-
return std::vector<std::uint8_t> { std::istreambuf_iterator<char> { stream },
63-
std::istreambuf_iterator<char> {} };
64-
}
65-
catch (const std::exception &error) {
59+
return std::vector<std::uint8_t> {std::istreambuf_iterator<char> {stream}, std::istreambuf_iterator<char> {}};
60+
} catch (const std::exception &error) {
6661
DD_LOG(error) << "Failed to read " << m_filepath << "! Error:\n"
6762
<< error.what();
6863
return std::nullopt;
6964
}
7065
}
7166

72-
bool
73-
FileSettingsPersistence::clear() {
67+
bool FileSettingsPersistence::clear() {
7468
// Return valud does not matter since we check the error code in case the file could NOT be removed.
7569
std::error_code error_code;
7670
std::filesystem::remove(m_filepath, error_code);

src/common/include/display_device/audio_context_interface.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ namespace display_device {
2727
* const auto result { iface->capture() };
2828
* @examples_end
2929
*/
30-
[[nodiscard]] virtual bool
31-
capture() = 0;
30+
[[nodiscard]] virtual bool capture() = 0;
3231

3332
/**
3433
* @brief Check if the context is already captured.
@@ -38,8 +37,7 @@ namespace display_device {
3837
* const auto result { iface->isCaptured() };
3938
* @examples_end
4039
*/
41-
[[nodiscard]] virtual bool
42-
isCaptured() const = 0;
40+
[[nodiscard]] virtual bool isCaptured() const = 0;
4341

4442
/**
4543
* @brief Release captured audio context for the devices (if any).
@@ -48,7 +46,6 @@ namespace display_device {
4846
* const auto result { iface->release() };
4947
* @examples_end
5048
*/
51-
virtual void
52-
release() = 0;
49+
virtual void release() = 0;
5350
};
5451
} // namespace display_device

src/common/include/display_device/detail/json_converter.h

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,16 @@
1010

1111
namespace display_device {
1212
// A shared "toJson" implementation. Extracted here for UTs + coverage.
13-
template <typename Type>
14-
std::string
15-
toJsonHelper(const Type &obj, const std::optional<unsigned int> &indent, bool *success) {
13+
template<typename Type>
14+
std::string toJsonHelper(const Type &obj, const std::optional<unsigned int> &indent, bool *success) {
1615
try {
1716
if (success) {
1817
*success = true;
1918
}
2019

2120
nlohmann::json json_obj = obj;
2221
return json_obj.dump(static_cast<int>(indent.value_or(-1)));
23-
}
24-
catch (const std::exception &err) { // GCOVR_EXCL_BR_LINE for fallthrough branch
22+
} catch (const std::exception &err) { // GCOVR_EXCL_BR_LINE for fallthrough branch
2523
if (success) {
2624
*success = false;
2725
}
@@ -31,9 +29,8 @@ namespace display_device {
3129
}
3230

3331
// A shared "fromJson" implementation. Extracted here for UTs + coverage.
34-
template <typename Type>
35-
bool
36-
fromJsonHelper(const std::string &string, Type &obj, std::string *error_message = nullptr) {
32+
template<typename Type>
33+
bool fromJsonHelper(const std::string &string, Type &obj, std::string *error_message = nullptr) {
3734
try {
3835
if (error_message) {
3936
error_message->clear();
@@ -42,8 +39,7 @@ namespace display_device {
4239
Type parsed_obj = nlohmann::json::parse(string);
4340
obj = std::move(parsed_obj);
4441
return true;
45-
}
46-
catch (const std::exception &err) {
42+
} catch (const std::exception &err) {
4743
if (error_message) {
4844
*error_message = err.what();
4945
}
@@ -52,12 +48,12 @@ namespace display_device {
5248
}
5349
}
5450

55-
#define DD_JSON_DEFINE_CONVERTER(Type) \
51+
#define DD_JSON_DEFINE_CONVERTER(Type) \
5652
std::string toJson(const Type &obj, const std::optional<unsigned int> &indent, bool *success) { \
57-
return toJsonHelper(obj, indent, success); \
58-
} \
59-
bool fromJson(const std::string &string, Type &obj, std::string *error_message) { \
60-
return fromJsonHelper<Type>(string, obj, error_message); \
53+
return toJsonHelper(obj, indent, success); \
54+
} \
55+
bool fromJson(const std::string &string, Type &obj, std::string *error_message) { \
56+
return fromJsonHelper<Type>(string, obj, error_message); \
6157
}
6258
} // namespace display_device
6359
#endif

0 commit comments

Comments
 (0)