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

Small loop refactor to make Slither happier #90

Merged
merged 2 commits into from
Aug 24, 2020
Merged

Small loop refactor to make Slither happier #90

merged 2 commits into from
Aug 24, 2020

Conversation

pdyraga
Copy link
Member

@pdyraga pdyraga commented Aug 21, 2020

Addressing two issues reported by Slither:

RNG.bitsRequired(uint256) (RNG.sol#137-155) contains a tautology or contradiction:
        - bits >= 0 (RNG.sol#140)
Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#tautology-or-contradiction

Addressed in d7025e2 by refacoring the loop. The loop should work exactly the same as before except that we avoid the
comparison of bits >= 0 which is always true because bits is an uint.

RNG.getIndex(uint256,bytes32).index (RNG.sol#200) is a local variable never initialized
Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#uninitialized-local-variables

Addressed in 5588f31 by initializing the index. It does not change how the function works and, in
fact, index, when not initialized, is initialized to the default - 0 value. We can however make this code a little cleaner and Slither happier.

The loop should work exactly the same as before except that we avoid the
comparison of bits >= 0 which is always true because bits is an uint.
Initializing the index does not change how the function works and, in
fact, index when not initialized is initialized to the default - 0
value. We can however make this code a little cleaner and Slither
happier.
@pdyraga pdyraga requested review from eth-r and Shadowfiend August 21, 2020 13:23
Copy link
Contributor

@Shadowfiend Shadowfiend left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good here, let's do it.

@Shadowfiend Shadowfiend merged commit bb203a2 into master Aug 24, 2020
@Shadowfiend Shadowfiend deleted the slither branch August 24, 2020 17:09
@pdyraga pdyraga added this to the v1.1.1 milestone Aug 28, 2020
nkuba added a commit that referenced this pull request Aug 28, 2020
Bumping up version to 1.1.1 for a new release

The new release will contain no functionality changes but will re-organize the code based on Linter and Slither suggestions:
- Update linting configuration #87
- Small loop refactor to make Slither happier #90
- Renamed input parameters to Leaf.make function to avoid shadowing #91

See https://github.com/keep-network/sortition-pools/milestone/4?closed=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants