consolidate duplicate conditions in TextReader #4530
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I started exploring
cppcheck
, a static analyzer for C++ projects, tonight.This PR proposes fixing one of the warnings raised by that tool. It caught some cases where two consecutive code blocks were guarded by identical
if()
conditions. Consolidating those blocks removes two unnecessary checks.how I ran 'cppcheck' (click me)
On my Mac, I installed it with homebrew.
Then ran the command from the root of the repo, with the following command.
--force
says "test all combinations of#ifdef
s" (by default,cppcheck
will only check 12 combinations).--enable=all
says "show all types of warnings"NOTE: I only checked
R-package/src
in this example because I wanted to start by checking that relatively limited piece of LightGBM. Checking everything innsrc/
(from the package root) returns a ton of notes. More opportunities for improvements in the future!