mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Merge #5949: chore: apply CI for clang-format only for dash files
adc0e4b382
fix: apply changes for .clang-format to make it matched with our code style (Konstantin Akimov)0c884f9740
chore: narrow score of clang-diff-format for dash specific files only (Konstantin Akimov)4bc0e1f697
chore: intentionally introducing wrong formatting to bip39.cpp to trigger CI (Konstantin Akimov)2c74ad427d
fix: adjust wallet/bip39 accordingly linter comments (Konstantin Akimov)d3faa8522c
refactor: use better masks for list of files; add missing bip39.{h,cpp} (Konstantin Akimov)7788f1db0e
refactor: move list of non backported files o test/util/data/non-backported.txt (Konstantin Akimov) Pull request description: ## Issue being fixed or feature implemented **Note**: should be this PR either https://github.com/dashpay/dash/pull/5942 be merged, not both CI clang-format triggers to non-dash files + clang format is differ from out current formatting. ## What was done? See each commits ## How Has This Been Tested? See CI result To test locally how new style will look, just run this command: ``` diff -u <(cat {coinjoin,governance,llmq,evo,masternode}/*.{h,cpp}) <(clang-format-16 {coinjoin,governance,llmq,evo,masternode}/*.{h,cpp} ) ``` ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone Top commit has no ACKs. Tree-SHA512: d87f30ba78e04f886d7eb2b6b235c20a966bc4438e6428a83ecff5c795d72777516d4270eb9769ffebef9f06e9509acf3c535b4c87b1be6c8a5aef7e2b7efecb
This commit is contained in:
commit
85caf8aa34
2
.github/workflows/clang-diff-format.yml
vendored
2
.github/workflows/clang-diff-format.yml
vendored
@ -14,7 +14,7 @@ jobs:
|
|||||||
run: git fetch
|
run: git fetch
|
||||||
- name: Run Clang-Format-Diff.py
|
- name: Run Clang-Format-Diff.py
|
||||||
run: |
|
run: |
|
||||||
git diff -U0 origin/develop -- . ':(exclude)src/qt/dashstrings.cpp' ':(exclude)src/qt/locale/' | ./contrib/devtools/clang-format-diff.py -p1 > diff_output.txt
|
git diff -U0 origin/develop -- $(git ls-files -- $(cat test/util/data/non-backported.txt)) | ./contrib/devtools/clang-format-diff.py -p1 > diff_output.txt
|
||||||
if [ -s diff_output.txt ]; then
|
if [ -s diff_output.txt ]; then
|
||||||
echo "Clang format differences found:"
|
echo "Clang format differences found:"
|
||||||
cat diff_output.txt
|
cat diff_output.txt
|
||||||
|
@ -3,17 +3,19 @@ AccessModifierOffset: -4
|
|||||||
AlignAfterOpenBracket: true
|
AlignAfterOpenBracket: true
|
||||||
AlignEscapedNewlinesLeft: true
|
AlignEscapedNewlinesLeft: true
|
||||||
AlignTrailingComments: true
|
AlignTrailingComments: true
|
||||||
AllowAllParametersOfDeclarationOnNextLine: true
|
AllowAllArgumentsOnNextLine: false
|
||||||
AllowShortBlocksOnASingleLine: false
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
AllowShortCaseLabelsOnASingleLine: true
|
AllowShortBlocksOnASingleLine: Empty
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortEnumsOnASingleLine: false
|
||||||
AllowShortFunctionsOnASingleLine: All
|
AllowShortFunctionsOnASingleLine: All
|
||||||
AllowShortIfStatementsOnASingleLine: true
|
AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||||
AllowShortLoopsOnASingleLine: false
|
AllowShortLoopsOnASingleLine: false
|
||||||
AlwaysBreakBeforeMultilineStrings: false
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
AlwaysBreakTemplateDeclarations: true
|
AlwaysBreakTemplateDeclarations: true
|
||||||
BinPackArguments: true
|
BinPackArguments: true
|
||||||
BinPackParameters: false
|
BinPackParameters: false
|
||||||
BreakBeforeBinaryOperators: false
|
BreakBeforeBinaryOperators: None
|
||||||
BreakBeforeBraces: Custom
|
BreakBeforeBraces: Custom
|
||||||
BraceWrapping:
|
BraceWrapping:
|
||||||
AfterClass: true
|
AfterClass: true
|
||||||
@ -21,14 +23,14 @@ BraceWrapping:
|
|||||||
BreakBeforeTernaryOperators: true
|
BreakBeforeTernaryOperators: true
|
||||||
BreakConstructorInitializersBeforeComma: false
|
BreakConstructorInitializersBeforeComma: false
|
||||||
BreakConstructorInitializers: AfterColon
|
BreakConstructorInitializers: AfterColon
|
||||||
ColumnLimit: 0
|
ColumnLimit: 120
|
||||||
CommentPragmas: '^ IWYU pragma:'
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
|
||||||
ConstructorInitializerIndentWidth: 4
|
ConstructorInitializerIndentWidth: 4
|
||||||
ContinuationIndentWidth: 4
|
ContinuationIndentWidth: 4
|
||||||
Cpp11BracedListStyle: true
|
Cpp11BracedListStyle: true
|
||||||
DerivePointerAlignment: false
|
DerivePointerAlignment: false
|
||||||
DisableFormat: false
|
DisableFormat: false
|
||||||
|
FixNamespaceComments: true
|
||||||
IndentCaseLabels: false
|
IndentCaseLabels: false
|
||||||
IndentFunctionDeclarationAfterType: false
|
IndentFunctionDeclarationAfterType: false
|
||||||
IndentWidth: 4
|
IndentWidth: 4
|
||||||
@ -37,7 +39,9 @@ MaxEmptyLinesToKeep: 2
|
|||||||
NamespaceIndentation: None
|
NamespaceIndentation: None
|
||||||
ObjCSpaceAfterProperty: false
|
ObjCSpaceAfterProperty: false
|
||||||
ObjCSpaceBeforeProtocolList: false
|
ObjCSpaceBeforeProtocolList: false
|
||||||
PenaltyBreakBeforeFirstCallParameter: 1
|
PackConstructorInitializers: Never
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 100
|
||||||
|
PenaltyBreakAssignment: 100
|
||||||
PenaltyBreakComment: 300
|
PenaltyBreakComment: 300
|
||||||
PenaltyBreakFirstLessLess: 120
|
PenaltyBreakFirstLessLess: 120
|
||||||
PenaltyBreakString: 100
|
PenaltyBreakString: 100
|
||||||
@ -52,6 +56,6 @@ SpacesInAngles: false
|
|||||||
SpacesInContainerLiterals: true
|
SpacesInContainerLiterals: true
|
||||||
SpacesInCStyleCastParentheses: false
|
SpacesInCStyleCastParentheses: false
|
||||||
SpacesInParentheses: false
|
SpacesInParentheses: false
|
||||||
Standard: Cpp11
|
Standard: c++20
|
||||||
TabWidth: 8
|
TabWidth: 8
|
||||||
UseTab: Never
|
UseTab: Never
|
||||||
|
@ -60,10 +60,9 @@ SecureString CMnemonic::FromData(const SecureVector& data, int len)
|
|||||||
int mlen = len * 3 / 4;
|
int mlen = len * 3 / 4;
|
||||||
SecureString mnemonic;
|
SecureString mnemonic;
|
||||||
|
|
||||||
int i, j, idx;
|
for (int i = 0; i < mlen; i++) {
|
||||||
for (i = 0; i < mlen; i++) {
|
int idx = 0;
|
||||||
idx = 0;
|
for (int j = 0; j < 11; j++) {
|
||||||
for (j = 0; j < 11; j++) {
|
|
||||||
idx <<= 1;
|
idx <<= 1;
|
||||||
idx += (bits[(i * 11 + j) / 8] & (1 << (7 - ((i * 11 + j) % 8)))) > 0;
|
idx += (bits[(i * 11 + j) / 8] & (1 << (7 - ((i * 11 + j) % 8)))) > 0;
|
||||||
}
|
}
|
||||||
@ -76,7 +75,7 @@ SecureString CMnemonic::FromData(const SecureVector& data, int len)
|
|||||||
return mnemonic;
|
return mnemonic;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMnemonic::Check(SecureString mnemonic)
|
bool CMnemonic::Check(const SecureString& mnemonic)
|
||||||
{
|
{
|
||||||
if (mnemonic.empty()) {
|
if (mnemonic.empty()) {
|
||||||
return false;
|
return false;
|
||||||
@ -98,7 +97,7 @@ bool CMnemonic::Check(SecureString mnemonic)
|
|||||||
SecureString ssCurrentWord;
|
SecureString ssCurrentWord;
|
||||||
SecureVector bits(32 + 1);
|
SecureVector bits(32 + 1);
|
||||||
|
|
||||||
uint32_t nWordIndex, ki, nBitsCount{};
|
uint32_t ki, nBitsCount{};
|
||||||
|
|
||||||
for (size_t i = 0; i < mnemonic.size(); ++i)
|
for (size_t i = 0; i < mnemonic.size(); ++i)
|
||||||
{
|
{
|
||||||
@ -110,7 +109,7 @@ bool CMnemonic::Check(SecureString mnemonic)
|
|||||||
ssCurrentWord += mnemonic[i + ssCurrentWord.size()];
|
ssCurrentWord += mnemonic[i + ssCurrentWord.size()];
|
||||||
}
|
}
|
||||||
i += ssCurrentWord.size();
|
i += ssCurrentWord.size();
|
||||||
nWordIndex = 0;
|
uint32_t nWordIndex = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (!wordlist[nWordIndex]) { // word not found
|
if (!wordlist[nWordIndex]) { // word not found
|
||||||
return false;
|
return false;
|
||||||
@ -140,8 +139,9 @@ bool CMnemonic::Check(SecureString mnemonic)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// passphrase must be at most 256 characters otherwise it would be truncated
|
// passphrase must be at most 256 characters otherwise it would be truncated
|
||||||
void CMnemonic::ToSeed(SecureString mnemonic, SecureString passphrase, SecureVector& seedRet)
|
void CMnemonic::ToSeed(const SecureString& mnemonic, const SecureString& passphrase, SecureVector& seedRet)
|
||||||
{
|
{
|
||||||
|
|
||||||
SecureString ssSalt = SecureString("mnemonic") + passphrase;
|
SecureString ssSalt = SecureString("mnemonic") + passphrase;
|
||||||
SecureVector vchSalt(ssSalt.begin(), ssSalt.begin() + strnlen(ssSalt.data(), 256));
|
SecureVector vchSalt(ssSalt.begin(), ssSalt.begin() + strnlen(ssSalt.data(), 256));
|
||||||
seedRet.resize(64);
|
seedRet.resize(64);
|
||||||
|
@ -31,9 +31,9 @@ class CMnemonic
|
|||||||
public:
|
public:
|
||||||
static SecureString Generate(int strength); // strength in bits
|
static SecureString Generate(int strength); // strength in bits
|
||||||
static SecureString FromData(const SecureVector& data, int len);
|
static SecureString FromData(const SecureVector& data, int len);
|
||||||
static bool Check(SecureString mnemonic);
|
static bool Check(const SecureString& mnemonic);
|
||||||
// passphrase must be at most 256 characters otherwise it would be truncated
|
// passphrase must be at most 256 characters otherwise it would be truncated
|
||||||
static void ToSeed(SecureString mnemonic, SecureString passphrase, SecureVector& seedRet);
|
static void ToSeed(const SecureString& mnemonic, const SecureString& passphrase, SecureVector& seedRet);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BITCOIN_WALLET_BIP39_H
|
#endif // BITCOIN_WALLET_BIP39_H
|
||||||
|
@ -33,6 +33,8 @@ IGNORED_WARNINGS=(
|
|||||||
"src/llmq/commitment.cpp.* warning: Consider using std::all_of or std::none_of algorithm instead of a raw loop. \[useStlAlgorithm\]"
|
"src/llmq/commitment.cpp.* warning: Consider using std::all_of or std::none_of algorithm instead of a raw loop. \[useStlAlgorithm\]"
|
||||||
"src/rpc/.*cpp:.*: note: Function pointer used here."
|
"src/rpc/.*cpp:.*: note: Function pointer used here."
|
||||||
"src/masternode/sync.cpp:.*: warning: Variable 'pnode' can be declared as pointer to const \[constVariableReference\]"
|
"src/masternode/sync.cpp:.*: warning: Variable 'pnode' can be declared as pointer to const \[constVariableReference\]"
|
||||||
|
"src/wallet/bip39.cpp.*: warning: The scope of the variable 'ssCurrentWord' can be reduced. \[variableScope\]"
|
||||||
|
|
||||||
|
|
||||||
"src/stacktraces.cpp:.*: .*: Parameter 'info' can be declared as pointer to const"
|
"src/stacktraces.cpp:.*: .*: Parameter 'info' can be declared as pointer to const"
|
||||||
"src/stacktraces.cpp:.*: note: You might need to cast the function pointer here"
|
"src/stacktraces.cpp:.*: note: You might need to cast the function pointer here"
|
||||||
@ -59,48 +61,7 @@ IGNORED_WARNINGS=(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# We should attempt to update this with all dash specific code
|
# We should attempt to update this with all dash specific code
|
||||||
FILES=$(git ls-files -- "src/batchedlogger.*" \
|
FILES=$(git ls-files -- $(cat test/util/data/non-backported.txt))
|
||||||
"src/bench/bls*.cpp" \
|
|
||||||
"src/bls/*.cpp" \
|
|
||||||
"src/bls/*.h" \
|
|
||||||
"src/cachemap.h" \
|
|
||||||
"src/cachemultimap.h" \
|
|
||||||
"src/coinjoin/*.cpp" \
|
|
||||||
"src/coinjoin/*.h" \
|
|
||||||
"src/ctpl_stl.h" \
|
|
||||||
"src/cxxtimer.hpp" \
|
|
||||||
"src/dsnotificationinterface.*" \
|
|
||||||
"src/evo/*.cpp" \
|
|
||||||
"src/evo/*.h" \
|
|
||||||
"src/governance/*.cpp" \
|
|
||||||
"src/governance/*.h" \
|
|
||||||
"src/keepass.*" \
|
|
||||||
"src/llmq/*.cpp" \
|
|
||||||
"src/llmq/*.h" \
|
|
||||||
"src/masternode/*.cpp" \
|
|
||||||
"src/masternode/*.h" \
|
|
||||||
"src/messagesigner.*" \
|
|
||||||
"src/netfulfilledman.*" \
|
|
||||||
"src/qt/governancelist.*" \
|
|
||||||
"src/qt/masternodelist.*" \
|
|
||||||
"src/rpc/coinjoin.cpp" \
|
|
||||||
"src/rpc/evo.cpp" \
|
|
||||||
"src/rpc/governance.cpp" \
|
|
||||||
"src/rpc/masternode.cpp" \
|
|
||||||
"src/rpc/quorums.cpp" \
|
|
||||||
"src/saltedhasher.*" \
|
|
||||||
"src/spork.*" \
|
|
||||||
"src/stacktraces.*" \
|
|
||||||
"src/statsd_client.*" \
|
|
||||||
"src/test/block_reward_reallocation_tests.cpp" \
|
|
||||||
"src/test/bls_tests.cpp" \
|
|
||||||
"src/test/dip0020opcodes_tests.cpp" \
|
|
||||||
"src/test/dynamic_activation*.cpp" \
|
|
||||||
"src/test/evo*.cpp" \
|
|
||||||
"src/test/governance*.cpp" \
|
|
||||||
"src/wallet/hdchain.*" \
|
|
||||||
"src/unordered_lru_cache.h" \
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if ! command -v cppcheck > /dev/null; then
|
if ! command -v cppcheck > /dev/null; then
|
||||||
|
41
test/util/data/non-backported.txt
Normal file
41
test/util/data/non-backported.txt
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
src/batchedlogger.*
|
||||||
|
src/bench/bls*.cpp
|
||||||
|
src/bls/*.cpp
|
||||||
|
src/bls/*.h
|
||||||
|
src/cachemap.h
|
||||||
|
src/cachemultimap.h
|
||||||
|
src/coinjoin/*.cpp
|
||||||
|
src/coinjoin/*.h
|
||||||
|
src/ctpl_stl.h
|
||||||
|
src/cxxtimer.hpp
|
||||||
|
src/dsnotificationinterface.*
|
||||||
|
src/evo/*.cpp
|
||||||
|
src/evo/*.h
|
||||||
|
src/governance/*.cpp
|
||||||
|
src/governance/*.h
|
||||||
|
src/llmq/*.cpp
|
||||||
|
src/llmq/*.h
|
||||||
|
src/masternode/*.cpp
|
||||||
|
src/masternode/*.h
|
||||||
|
src/messagesigner.*
|
||||||
|
src/netfulfilledman.*
|
||||||
|
src/qt/governancelist.*
|
||||||
|
src/qt/masternodelist.*
|
||||||
|
src/rpc/coinjoin.cpp
|
||||||
|
src/rpc/evo.cpp
|
||||||
|
src/rpc/governance.cpp
|
||||||
|
src/rpc/masternode.cpp
|
||||||
|
src/rpc/quorums.cpp
|
||||||
|
src/saltedhasher.*
|
||||||
|
src/spork.*
|
||||||
|
src/stacktraces.*
|
||||||
|
src/statsd_client.*
|
||||||
|
src/test/block_reward_reallocation_tests.cpp
|
||||||
|
src/test/bls_tests.cpp
|
||||||
|
src/test/dip0020opcodes_tests.cpp
|
||||||
|
src/test/dynamic_activation*.cpp
|
||||||
|
src/test/evo*.cpp
|
||||||
|
src/test/governance*.cpp
|
||||||
|
src/unordered_lru_cache.h
|
||||||
|
src/wallet/bip39*
|
||||||
|
src/wallet/hdchain.*
|
Loading…
Reference in New Issue
Block a user