From ada356208e153e088c729c102d5d79c9c9d66f1a Mon Sep 17 00:00:00 2001 From: practicalswift Date: Tue, 14 Aug 2018 09:27:30 +0200 Subject: [PATCH 1/2] Fix typos reported by codespell --- contrib/debian/copyright | 2 +- contrib/gitian-build.py | 2 +- src/dbwrapper.cpp | 2 +- src/qt/test/util.h | 2 +- src/rpc/rawtransaction.cpp | 2 +- src/scheduler.h | 2 +- src/script/descriptor.cpp | 4 ++-- src/streams.h | 2 +- src/support/lockedpool.cpp | 4 ++-- src/wallet/db.cpp | 2 +- test/functional/example_test.py | 2 +- test/functional/feature_block.py | 2 +- test/functional/mining_getblocktemplate_longpoll.py | 12 ++++++------ test/functional/p2p_invalid_tx.py | 2 +- test/functional/p2p_node_network_limited.py | 2 +- test/functional/p2p_segwit.py | 2 +- test/functional/rpc_psbt.py | 2 +- test/functional/test_framework/blocktools.py | 2 +- test/lint/lint-spelling.ignore-words.txt | 5 +++++ 19 files changed, 30 insertions(+), 25 deletions(-) create mode 100644 test/lint/lint-spelling.ignore-words.txt diff --git a/contrib/debian/copyright b/contrib/debian/copyright index 21cca7d9a..e5b9cbaa4 100644 --- a/contrib/debian/copyright +++ b/contrib/debian/copyright @@ -96,7 +96,7 @@ Comment: Site: https://bitcointalk.org/?topic=1756.0 Files: src/qt/res/icons/proxy.png src/qt/res/src/proxy.svg Copyright: Cristian Mircea Messel -Licese: public-domain +License: public-domain License: Expat diff --git a/contrib/gitian-build.py b/contrib/gitian-build.py index 0e53c3dfd..14a2cf698 100755 --- a/contrib/gitian-build.py +++ b/contrib/gitian-build.py @@ -170,7 +170,7 @@ def main(): args.sign_prog = 'true' if args.detach_sign else 'gpg --detach-sign' - # Set enviroment variable USE_LXC or USE_DOCKER, let gitian-builder know that we use lxc or docker + # Set environment variable USE_LXC or USE_DOCKER, let gitian-builder know that we use lxc or docker if args.docker: os.environ['USE_DOCKER'] = '1' elif not args.kvm: diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp index f5fb71580..58d8cc2c9 100644 --- a/src/dbwrapper.cpp +++ b/src/dbwrapper.cpp @@ -78,7 +78,7 @@ static void SetMaxOpenFiles(leveldb::Options *options) { // do not interfere with select() loops. On 64-bit Unix hosts this value is // also OK, because up to that amount LevelDB will use an mmap // implementation that does not use extra file descriptors (the fds are - // closed after being mmaped). + // closed after being mmap'ed). // // Increasing the value beyond the default is dangerous because LevelDB will // fall back to a non-mmap implementation when the file count is too large. diff --git a/src/qt/test/util.h b/src/qt/test/util.h index 324386c13..5363c9454 100644 --- a/src/qt/test/util.h +++ b/src/qt/test/util.h @@ -5,7 +5,7 @@ * Press "Ok" button in message box dialog. * * @param text - Optionally store dialog text. - * @param msec - Number of miliseconds to pause before triggering the callback. + * @param msec - Number of milliseconds to pause before triggering the callback. */ void ConfirmMessage(QString* text = nullptr, int msec = 0); diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 248b963c0..19109f60e 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -1740,7 +1740,7 @@ UniValue converttopsbt(const JSONRPCRequest& request) " will continue. If false, RPC will fail if any signatures are present.\n" "3. iswitness (boolean, optional) Whether the transaction hex is a serialized witness transaction.\n" " If iswitness is not present, heuristic tests will be used in decoding. If true, only witness deserializaion\n" - " will be tried. If false, only non-witness deserialization wil be tried. Only has an effect if\n" + " will be tried. If false, only non-witness deserialization will be tried. Only has an effect if\n" " permitsigdata is true.\n" "\nResult:\n" " \"psbt\" (string) The resulting raw transaction (base64-encoded string)\n" diff --git a/src/scheduler.h b/src/scheduler.h index 0c2551cf4..953d6c37d 100644 --- a/src/scheduler.h +++ b/src/scheduler.h @@ -111,7 +111,7 @@ public: /** * Add a callback to be executed. Callbacks are executed serially * and memory is release-acquire consistent between callback executions. - * Practially, this means that callbacks can behave as if they are executed + * Practically, this means that callbacks can behave as if they are executed * in order by a single thread. */ void AddToProcessQueue(std::function func); diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index f366b99ec..45b097dde 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -373,7 +373,7 @@ enum class ParseScriptContext { P2WSH, }; -/** Parse a constant. If succesful, sp is updated to skip the constant and return true. */ +/** Parse a constant. If successful, sp is updated to skip the constant and return true. */ bool Const(const std::string& str, Span& sp) { if ((size_t)sp.size() >= str.size() && std::equal(str.begin(), str.end(), sp.begin())) { @@ -383,7 +383,7 @@ bool Const(const std::string& str, Span& sp) return false; } -/** Parse a function call. If succesful, sp is updated to be the function's argument(s). */ +/** Parse a function call. If successful, sp is updated to be the function's argument(s). */ bool Func(const std::string& str, Span& sp) { if ((size_t)sp.size() >= str.size() + 2 && sp[str.size()] == '(' && sp[sp.size() - 1] == ')' && std::equal(str.begin(), str.end(), sp.begin())) { diff --git a/src/streams.h b/src/streams.h index d4a309be3..dc20f7a9d 100644 --- a/src/streams.h +++ b/src/streams.h @@ -529,7 +529,7 @@ public: explicit BitStreamReader(IStream& istream) : m_istream(istream) {} /** Read the specified number of bits from the stream. The data is returned - * in the nbits least signficant bits of a 64-bit uint. + * in the nbits least significant bits of a 64-bit uint. */ uint64_t Read(int nbits) { if (nbits < 0 || nbits > 64) { diff --git a/src/support/lockedpool.cpp b/src/support/lockedpool.cpp index 070b3ed80..8d577cf52 100644 --- a/src/support/lockedpool.cpp +++ b/src/support/lockedpool.cpp @@ -75,7 +75,7 @@ void* Arena::alloc(size_t size) // Create the used-chunk, taking its space from the end of the free-chunk const size_t size_remaining = size_ptr_it->first - size; - auto alloced = chunks_used.emplace(size_ptr_it->second + size_remaining, size).first; + auto allocated = chunks_used.emplace(size_ptr_it->second + size_remaining, size).first; chunks_free_end.erase(size_ptr_it->second + size_ptr_it->first); if (size_ptr_it->first == size) { // whole chunk is used up @@ -88,7 +88,7 @@ void* Arena::alloc(size_t size) } size_to_free_chunk.erase(size_ptr_it); - return reinterpret_cast(alloced->first); + return reinterpret_cast(allocated->first); } void Arena::free(void *ptr) diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp index d0fe51801..e9060ce97 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -72,7 +72,7 @@ BerkeleyEnvironment* GetWalletEnv(const fs::path& wallet_path, std::string& data database_filename = "wallet.dat"; } LOCK(cs_db); - // Note: An ununsed temporary BerkeleyEnvironment object may be created inside the + // Note: An unused temporary BerkeleyEnvironment object may be created inside the // emplace function if the key already exists. This is a little inefficient, // but not a big concern since the map will be changed in the future to hold // pointers instead of objects, anyway. diff --git a/test/functional/example_test.py b/test/functional/example_test.py index a8c147487..3edd760b9 100755 --- a/test/functional/example_test.py +++ b/test/functional/example_test.py @@ -76,7 +76,7 @@ class ExampleTest(BitcoinTestFramework): def set_test_params(self): """Override test parameters for your individual test. - This method must be overridden and num_nodes must be exlicitly set.""" + This method must be overridden and num_nodes must be explicitly set.""" self.setup_clean_chain = True self.num_nodes = 3 # Use self.extra_args to change command-line arguments for the nodes diff --git a/test/functional/feature_block.py b/test/functional/feature_block.py index e81ea12d0..450cef37c 100755 --- a/test/functional/feature_block.py +++ b/test/functional/feature_block.py @@ -989,7 +989,7 @@ class FullBlockTest(BitcoinTestFramework): assert_equal(get_legacy_sigopcount_block(b73), MAX_BLOCK_SIGOPS + 1) self.sync_blocks([b73], success=False, reject_code=16, reject_reason=b'bad-blk-sigops', reconnect=True) - # b74/75 - if we push an invalid script element, all prevous sigops are counted, + # b74/75 - if we push an invalid script element, all previous sigops are counted, # but sigops after the element are not counted. # # The invalid script element is that the push_data indicates that diff --git a/test/functional/mining_getblocktemplate_longpoll.py b/test/functional/mining_getblocktemplate_longpoll.py index 2bcbe8db7..1259754c5 100755 --- a/test/functional/mining_getblocktemplate_longpoll.py +++ b/test/functional/mining_getblocktemplate_longpoll.py @@ -15,8 +15,8 @@ class LongpollThread(threading.Thread): def __init__(self, node): threading.Thread.__init__(self) # query current longpollid - templat = node.getblocktemplate() - self.longpollid = templat['longpollid'] + template = node.getblocktemplate() + self.longpollid = template['longpollid'] # create a new connection to the node, we can't use the same # connection from two threads self.node = get_rpc_proxy(node.url, 1, timeout=600, coveragedir=node.coverage_dir) @@ -31,11 +31,11 @@ class GetBlockTemplateLPTest(BitcoinTestFramework): def run_test(self): self.log.info("Warning: this test will take about 70 seconds in the best case. Be patient.") self.nodes[0].generate(10) - templat = self.nodes[0].getblocktemplate() - longpollid = templat['longpollid'] + template = self.nodes[0].getblocktemplate() + longpollid = template['longpollid'] # longpollid should not change between successive invocations if nothing else happens - templat2 = self.nodes[0].getblocktemplate() - assert(templat2['longpollid'] == longpollid) + template2 = self.nodes[0].getblocktemplate() + assert(template2['longpollid'] == longpollid) # Test 1: test that the longpolling wait if we do nothing thr = LongpollThread(self.nodes[0]) diff --git a/test/functional/p2p_invalid_tx.py b/test/functional/p2p_invalid_tx.py index 12bc62131..40373689d 100755 --- a/test/functional/p2p_invalid_tx.py +++ b/test/functional/p2p_invalid_tx.py @@ -76,7 +76,7 @@ class InvalidTxRequestTest(BitcoinTestFramework): self.reconnect_p2p(num_connections=2) self.log.info('Test orphan transaction handling ... ') - # Create a root transaction that we withhold until all dependend transactions + # Create a root transaction that we withhold until all dependent transactions # are sent out and in the orphan cache SCRIPT_PUB_KEY_OP_TRUE = b'\x51\x75' * 15 + b'\x51' tx_withhold = CTransaction() diff --git a/test/functional/p2p_node_network_limited.py b/test/functional/p2p_node_network_limited.py index c987bf4b0..4740740d4 100755 --- a/test/functional/p2p_node_network_limited.py +++ b/test/functional/p2p_node_network_limited.py @@ -89,7 +89,7 @@ class NodeNetworkLimitedTest(BitcoinTestFramework): sync_blocks([self.nodes[0], self.nodes[2]], timeout=5) except: pass - # node2 must remain at heigh 0 + # node2 must remain at height 0 assert_equal(self.nodes[2].getblockheader(self.nodes[2].getbestblockhash())['height'], 0) # now connect also to node 1 (non pruned) diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py index 45dc2928d..161efcf2e 100755 --- a/test/functional/p2p_segwit.py +++ b/test/functional/p2p_segwit.py @@ -471,7 +471,7 @@ class SegWitTest(BitcoinTestFramework): blocks are permitted to contain witnesses).""" # node2 doesn't need to be connected for this test. - # (If it's connected, node0 may propogate an invalid block to it over + # (If it's connected, node0 may propagate an invalid block to it over # compact blocks and the nodes would have inconsistent tips.) disconnect_nodes(self.nodes[0], 2) diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py index d558de5fe..a693b7e4b 100755 --- a/test/functional/rpc_psbt.py +++ b/test/functional/rpc_psbt.py @@ -105,7 +105,7 @@ class PSBTTest(BitcoinTestFramework): signedtx = self.nodes[0].signrawtransactionwithwallet(rawtx['hex']) assert_raises_rpc_error(-22, "TX decode failed", self.nodes[0].converttopsbt, signedtx['hex']) - # Explicilty allow converting non-empty txs + # Explicitly allow converting non-empty txs new_psbt = self.nodes[0].converttopsbt(rawtx['hex']) self.nodes[0].decodepsbt(new_psbt) diff --git a/test/functional/test_framework/blocktools.py b/test/functional/test_framework/blocktools.py index 987ade404..35004fb58 100644 --- a/test/functional/test_framework/blocktools.py +++ b/test/functional/test_framework/blocktools.py @@ -122,7 +122,7 @@ def create_tx_with_script(prevtx, n, script_sig=b"", *, amount, script_pub_key=C """Return one-input, one-output transaction object spending the prevtx's n-th output with the given amount. - Can optionally pass scriptPubKey and scriptSig, default is anyone-can-spend ouput. + Can optionally pass scriptPubKey and scriptSig, default is anyone-can-spend output. """ tx = CTransaction() assert(n < len(prevtx.vout)) diff --git a/test/lint/lint-spelling.ignore-words.txt b/test/lint/lint-spelling.ignore-words.txt new file mode 100644 index 000000000..67b83b5d4 --- /dev/null +++ b/test/lint/lint-spelling.ignore-words.txt @@ -0,0 +1,5 @@ +cas +hights +mor +objext +useable From f8a81f73ac4fee82488806c2b384b36e8ee2acdf Mon Sep 17 00:00:00 2001 From: practicalswift Date: Mon, 13 Aug 2018 15:19:33 +0200 Subject: [PATCH 2/2] lint: Add spell check linter (codespell) --- .travis/lint_04_install.sh | 1 + test/lint/lint-spelling.ignore-words.txt | 1 + test/lint/lint-spelling.sh | 15 +++++++++++++++ 3 files changed, 17 insertions(+) create mode 100755 test/lint/lint-spelling.sh diff --git a/.travis/lint_04_install.sh b/.travis/lint_04_install.sh index 34118a57c..3a6ff73d7 100755 --- a/.travis/lint_04_install.sh +++ b/.travis/lint_04_install.sh @@ -6,4 +6,5 @@ export LC_ALL=C +travis_retry pip install codespell travis_retry pip install flake8 diff --git a/test/lint/lint-spelling.ignore-words.txt b/test/lint/lint-spelling.ignore-words.txt index 67b83b5d4..9a49f3227 100644 --- a/test/lint/lint-spelling.ignore-words.txt +++ b/test/lint/lint-spelling.ignore-words.txt @@ -2,4 +2,5 @@ cas hights mor objext +unselect useable diff --git a/test/lint/lint-spelling.sh b/test/lint/lint-spelling.sh new file mode 100755 index 000000000..5d672698a --- /dev/null +++ b/test/lint/lint-spelling.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2018 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# +# Warn in case of spelling errors. +# Note: Will exit successfully regardless of spelling errors. + +export LC_ALL=C + +IGNORE_WORDS_FILE=test/lint/lint-spelling.ignore-words.txt +if ! codespell --check-filenames --disable-colors --quiet-level=7 --ignore-words=${IGNORE_WORDS_FILE} $(git ls-files -- ":(exclude)build-aux/m4/" ":(exclude)contrib/seeds/*.txt" ":(exclude)depends/" ":(exclude)doc/release-notes/" ":(exclude)src/leveldb/" ":(exclude)src/qt/locale/" ":(exclude)src/secp256k1/" ":(exclude)src/univalue/"); then + echo "^ Warning: codespell identified likely spelling errors. Any false positives? Add them to the list of ignored words in ${IGNORE_WORDS_FILE}" +fi