Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Fix some minor linter complaints #2517

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
- wallet: simplify nTimeSmart calculation #2144 (@div72)
- gui: Refresh checkbox and radio button styles #2170 (@cyrossignol)
- build: Bump libevent to 2.1.11 #2172 (@barton2526)
- build: Update native_mac_alias, Remove big sur patch file in qt recipe #2173 (@barton2526)
- build: Update native_mac_alias, Remove Big Sur patch file in qt recipe #2173 (@barton2526)
- docs: Misc Grammar #2176 (@barton2526)
- build: miniupnpc 2.2.2 #2179 (@barton2526)
- rpc: Refresh rainbymagnitude #2163 (@jamescowens)
Expand Down
10 changes: 5 additions & 5 deletions contrib/devtools/symbol-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ def read_symbols(executable, imports=True) -> List[Tuple[str, str, str]]:
raise IOError('Could not read symbols for {}: {}'.format(executable, stderr.strip()))
syms = []
for line in stdout.splitlines():
line = line.split()
splitline = line.split()
if 'Machine:' in line:
arch = line[-1]
if len(line)>7 and re.match('[0-9]+:$', line[0]):
(sym, _, version) = line[7].partition('@')
is_import = line[6] == 'UND'
arch = splitline[-1]
if len(splitline)>7 and re.match('[0-9]+:$', splitline[0]):
(sym, _, version) = splitline[7].partition('@')
is_import = splitline[6] == 'UND'
if version.startswith('@'):
version = version[1:]
if is_import == imports:
Expand Down
9 changes: 6 additions & 3 deletions src/rpc/dataacq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ UniValue rpc_getblockstats(const UniValue& params, bool fHelp)
throw runtime_error("getblockstats: failed to read block");
}

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

unsigned txcountinblock = 0;

Expand Down Expand Up @@ -604,9 +604,12 @@ UniValue rpc_getrecentblocks(const UniValue& params, bool fHelp)
if( (detail<100 && detail>=20) || (detail>=120) )
{
CBlock block;
if(!ReadBlockFromDisk(block, cur->nFile, cur->nBlockPos, Params().GetConsensus()))
if (!ReadBlockFromDisk(block, cur->nFile, cur->nBlockPos, Params().GetConsensus())) {
throw runtime_error("failed to read block");
//assert(block.vtx.size() > 0);
}

if (!block.vtx.size()) throw runtime_error("getblockstats: block has zero transactions");

const Claim& claim = block.GetClaim();

if(detail<100)
Expand Down
5 changes: 4 additions & 1 deletion src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ UniValue MRCToJson(const GRC::MRC& mrc);

std::vector<std::pair<std::string, std::string>> GetTxStakeBoincHashInfo(const CMerkleTx& mtx)
{
assert(mtx.IsCoinStake() || mtx.IsCoinBase());
if (!(mtx.IsCoinStake() || mtx.IsCoinBase())) {
throw runtime_error("GetTxStakeBoincHashInfo: transaction is not a coinstake or coinbase");
}

std::vector<std::pair<std::string, std::string>> res;

// Fetch BlockIndex for tx block
Expand Down
3 changes: 0 additions & 3 deletions test/lint/lint-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ LINTALL=$(basename "${BASH_SOURCE[0]}")
EXIT_CODE=0

IGNORE_EXIT=(
"lint-assertions.sh"
"lint-circular-dependencies.sh"
"lint-python-dead-code.sh"
"lint-python.sh"
)

for f in "${SCRIPTDIR}"/lint-*.sh; do
Expand Down
1 change: 1 addition & 0 deletions test/lint/lint-python-dead-code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ fi
# Any value below 100 introduces the risk of false positives, which would create an unacceptable maintenance burden.
if ! vulture \
--min-confidence 100 \
--exclude "src/crc32c/.ycm_extra_conf.py" \
$(git ls-files -- "*.py"); then
echo "Python dead code detection found some issues"
exit 1
Expand Down
1 change: 1 addition & 0 deletions test/lint/lint-spelling.ignore-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ dout
nin
inout
smoe
sur