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:
pasta 2024-04-02 09:40:25 -05:00
commit 85caf8aa34
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984
6 changed files with 68 additions and 62 deletions

View File

@ -14,7 +14,7 @@ jobs:
run: git fetch
- name: Run Clang-Format-Diff.py
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
echo "Clang format differences found:"
cat diff_output.txt

View File

@ -3,17 +3,19 @@ AccessModifierOffset: -4
AlignAfterOpenBracket: true
AlignEscapedNewlinesLeft: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: false
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: false
BreakBeforeBinaryOperators: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
@ -21,14 +23,14 @@ BraceWrapping:
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: AfterColon
ColumnLimit: 0
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
FixNamespaceComments: true
IndentCaseLabels: false
IndentFunctionDeclarationAfterType: false
IndentWidth: 4
@ -37,7 +39,9 @@ MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakBeforeFirstCallParameter: 1
PackConstructorInitializers: Never
PenaltyBreakBeforeFirstCallParameter: 100
PenaltyBreakAssignment: 100
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 100
@ -52,6 +56,6 @@ SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
Standard: Cpp11
Standard: c++20
TabWidth: 8
UseTab: Never

View File

@ -60,10 +60,9 @@ SecureString CMnemonic::FromData(const SecureVector& data, int len)
int mlen = len * 3 / 4;
SecureString mnemonic;
int i, j, idx;
for (i = 0; i < mlen; i++) {
idx = 0;
for (j = 0; j < 11; j++) {
for (int i = 0; i < mlen; i++) {
int idx = 0;
for (int j = 0; j < 11; j++) {
idx <<= 1;
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;
}
bool CMnemonic::Check(SecureString mnemonic)
bool CMnemonic::Check(const SecureString& mnemonic)
{
if (mnemonic.empty()) {
return false;
@ -98,7 +97,7 @@ bool CMnemonic::Check(SecureString mnemonic)
SecureString ssCurrentWord;
SecureVector bits(32 + 1);
uint32_t nWordIndex, ki, nBitsCount{};
uint32_t ki, nBitsCount{};
for (size_t i = 0; i < mnemonic.size(); ++i)
{
@ -110,7 +109,7 @@ bool CMnemonic::Check(SecureString mnemonic)
ssCurrentWord += mnemonic[i + ssCurrentWord.size()];
}
i += ssCurrentWord.size();
nWordIndex = 0;
uint32_t nWordIndex = 0;
for (;;) {
if (!wordlist[nWordIndex]) { // word not found
return false;
@ -140,8 +139,9 @@ bool CMnemonic::Check(SecureString mnemonic)
}
// 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;
SecureVector vchSalt(ssSalt.begin(), ssSalt.begin() + strnlen(ssSalt.data(), 256));
seedRet.resize(64);

View File

@ -31,9 +31,9 @@ class CMnemonic
public:
static SecureString Generate(int strength); // strength in bits
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
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

View File

@ -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/rpc/.*cpp:.*: note: Function pointer used here."
"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:.*: 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
FILES=$(git ls-files -- "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/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" \
)
FILES=$(git ls-files -- $(cat test/util/data/non-backported.txt))
if ! command -v cppcheck > /dev/null; then

View 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.*