Skip to content

Commit 50b19ae

Browse files
authored
Merge pull request #2517 from jamescowens/fix_lint_asserts
refactor: Fix some minor linter complaints
2 parents 19a0bdb + 7b34bdf commit 50b19ae

File tree

7 files changed

+18
-13
lines changed

7 files changed

+18
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
208208
- wallet: simplify nTimeSmart calculation #2144 (@div72)
209209
- gui: Refresh checkbox and radio button styles #2170 (@cyrossignol)
210210
- build: Bump libevent to 2.1.11 #2172 (@barton2526)
211-
- build: Update native_mac_alias, Remove big sur patch file in qt recipe #2173 (@barton2526)
211+
- build: Update native_mac_alias, Remove Big Sur patch file in qt recipe #2173 (@barton2526)
212212
- docs: Misc Grammar #2176 (@barton2526)
213213
- build: miniupnpc 2.2.2 #2179 (@barton2526)
214214
- rpc: Refresh rainbymagnitude #2163 (@jamescowens)

contrib/devtools/symbol-check.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,12 @@ def read_symbols(executable, imports=True) -> List[Tuple[str, str, str]]:
165165
raise IOError('Could not read symbols for {}: {}'.format(executable, stderr.strip()))
166166
syms = []
167167
for line in stdout.splitlines():
168-
line = line.split()
168+
splitline = line.split()
169169
if 'Machine:' in line:
170-
arch = line[-1]
171-
if len(line)>7 and re.match('[0-9]+:$', line[0]):
172-
(sym, _, version) = line[7].partition('@')
173-
is_import = line[6] == 'UND'
170+
arch = splitline[-1]
171+
if len(splitline)>7 and re.match('[0-9]+:$', splitline[0]):
172+
(sym, _, version) = splitline[7].partition('@')
173+
is_import = splitline[6] == 'UND'
174174
if version.startswith('@'):
175175
version = version[1:]
176176
if is_import == imports:

src/rpc/dataacq.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ UniValue rpc_getblockstats(const UniValue& params, bool fHelp)
147147
throw runtime_error("getblockstats: failed to read block");
148148
}
149149

150-
assert(block.vtx.size() > 0);
150+
if (!block.vtx.size()) throw runtime_error("getblockstats: block has zero transactions");
151151

152152
unsigned txcountinblock = 0;
153153

@@ -602,9 +602,12 @@ UniValue rpc_getrecentblocks(const UniValue& params, bool fHelp)
602602
if( (detail<100 && detail>=20) || (detail>=120) )
603603
{
604604
CBlock block;
605-
if(!ReadBlockFromDisk(block, cur->nFile, cur->nBlockPos, Params().GetConsensus()))
605+
if (!ReadBlockFromDisk(block, cur->nFile, cur->nBlockPos, Params().GetConsensus())) {
606606
throw runtime_error("failed to read block");
607-
//assert(block.vtx.size() > 0);
607+
}
608+
609+
if (!block.vtx.size()) throw runtime_error("getblockstats: block has zero transactions");
610+
608611
const Claim& claim = block.GetClaim();
609612

610613
if(detail<100)

src/rpc/rawtransaction.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ UniValue MRCToJson(const GRC::MRC& mrc);
3939

4040
std::vector<std::pair<std::string, std::string>> GetTxStakeBoincHashInfo(const CMerkleTx& mtx)
4141
{
42-
assert(mtx.IsCoinStake() || mtx.IsCoinBase());
42+
if (!(mtx.IsCoinStake() || mtx.IsCoinBase())) {
43+
throw runtime_error("GetTxStakeBoincHashInfo: transaction is not a coinstake or coinbase");
44+
}
45+
4346
std::vector<std::pair<std::string, std::string>> res;
4447

4548
// Fetch BlockIndex for tx block

test/lint/lint-all.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ LINTALL=$(basename "${BASH_SOURCE[0]}")
1919
EXIT_CODE=0
2020

2121
IGNORE_EXIT=(
22-
"lint-assertions.sh"
2322
"lint-circular-dependencies.sh"
24-
"lint-python-dead-code.sh"
25-
"lint-python.sh"
2623
)
2724

2825
for f in "${SCRIPTDIR}"/lint-*.sh; do

test/lint/lint-python-dead-code.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ fi
1717
# Any value below 100 introduces the risk of false positives, which would create an unacceptable maintenance burden.
1818
if ! vulture \
1919
--min-confidence 100 \
20+
--exclude "src/crc32c/.ycm_extra_conf.py" \
2021
$(git ls-files -- "*.py"); then
2122
echo "Python dead code detection found some issues"
2223
exit 1

test/lint/lint-spelling.ignore-words.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ dout
2323
nin
2424
inout
2525
smoe
26+
sur

0 commit comments

Comments
 (0)