← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1538518] Re: Avoid using `len(x)` to check if x is empty

 

Reviewed:  https://review.openstack.org/276886
Committed: https://git.openstack.org/cgit/openstack/rally/commit/?id=efd641caf0ad0bba0c6ad0993a5b65d08078966d
Submitter: Jenkins
Branch:    master

commit efd641caf0ad0bba0c6ad0993a5b65d08078966d
Author: Steve Wilkerson <sw5822@xxxxxxx>
Date:   Fri Feb 5 13:38:51 2016 -0600

    Use booleans to check for empty lists
    
    Changed from checking for empty collections with
    len(list) to checking the boolean value of the list
    instead
    
    Closes-Bug: #1538518
    Change-Id: Ib601a83b8b6e19ab78690f8ca2834e7ef622cb9b


** Changed in: rally
       Status: In Progress => Fix Released

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1538518

Title:
  Avoid using `len(x)` to check if x is empty

Status in Glance:
  In Progress
Status in OpenStack Compute (nova):
  In Progress
Status in Rally:
  Fix Released
Status in OpenStack Object Storage (swift):
  In Progress

Bug description:
  `len()` is used to check if collection (e.g., a dict, list, set, etc.)
  has items. As collections have a boolean representation too, it is
  better to directly check for true / false.

  rally/common/utils.py
  rally/task/utils.py
  rally/task/validation.py
  tests/unit/doc/test_specs.py

  This change will be more obvious and more readable, and is probably
  cheaper than computing a set intersection, too.

To manage notifications about this bug go to:
https://bugs.launchpad.net/glance/+bug/1538518/+subscriptions