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

Fixed comparison of `None` with constants #52004

Merged
merged 1 commit into from Mar 6, 2019

Conversation

@chdamianos
Copy link

commented Mar 6, 2019

What does this PR do?

There are comparisons of None with constant values (e.g. 'size' is None) resulting in the comparison always being True or False.
I replaced the constant values with variable names that seemed appropriate.

I work for Semmle and I noticed these issues with out LGTM code analyzer
https://lgtm.com/projects/g/saltstack/salt/alerts/?mode=tree&ruleFocus=3980086

Previous Behavior

The comparison of None with constant will always result in True or False.
For example 'size' is None is always True and 'size' is not None is always False
I don't believe this is the desired behavior. If it is perhaps the comparison can be replaced with the appropriate Boolean.

Tests written?

No

Commits signed with GPG?

No

Please review Salt's Contributing Guide for best practices.

See GitHub's page on GPG signing for more information about signing commits with GPG.

There are comparisons of `None` with constant values (e.g. `'size' is None`) resulting in the comparison always being `True` or `False`.
I replaced the constant values with variable names.

I work for Semmle and I noticed these issues with out LGTM code analyzer
https://lgtm.com/projects/g/saltstack/salt/alerts/?mode=tree&ruleFocus=3980086
@twangboy twangboy merged commit 01bcff0 into saltstack:2019.2 Mar 6, 2019
10 checks passed
10 checks passed
WIP Ready for review
Details
continuous-integration/jenkins/pr-merge This commit looks good
Details
jenkins/pr/docs The docs job has passed
Details
jenkins/pr/lint Python lint test has passed
Details
jenkins/pr/py2-centos-7 The py2-centos-7 job has passed
Details
jenkins/pr/py2-ubuntu-1604 The py2-ubuntu-1604 job has passed
Details
jenkins/pr/py2-windows-2016 The py2-windows-2016 job has passed
Details
jenkins/pr/py3-centos-7 The py3-centos-7 job has passed
Details
jenkins/pr/py3-ubuntu-1604 The py3-ubuntu-1604 job has passed
Details
jenkins/pr/py3-windows-2016 The py3-windows-2016 job has passed
Details
@chdamianos chdamianos deleted the chdamianos:fix-constants-comparison branch Mar 7, 2019
@Ch3LL Ch3LL referenced this pull request Mar 7, 2019
dwoz added a commit that referenced this pull request Mar 7, 2019
Backport #52004 into 2018.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.