Cleanup attribute names

Bug #1239834 reported by Kurt Griffiths
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
zaqar
Fix Released
Low
Griffin Ashe

Bug Description

Lots of __init__ methods assign values to attributes that don't start with an underscore, but should.

Kurt Griffiths (kgriffs)
Changed in marconi:
importance: Medium → Low
tags: added: low-hanging-fruit
Changed in marconi:
assignee: nobody → chandankumar (chandankumar-093047)
Revision history for this message
chandan kumar (chkumar246) wrote :

Hello,

@Kurt and @Flavio, i am not getting what i have to do from the above bug description.
Please explain what actually i have to do solve this bug?

Thanks,
Chandan Kumar

Revision history for this message
Kurt Griffiths (kgriffs) wrote :

Hi Chandan,

Basically, if an attribute is only used within the class, the name should be prefixed with an underscore to designate it as a "private" attribute.

You'll need to just go through all the classes looking for cases where:

  self.should_be_private

can be renamed to:

  self._should_be_private

Changed in marconi:
milestone: none → icehouse-3
milestone: icehouse-3 → icehouse-2
Revision history for this message
Wei Wang (damon-devops) wrote :

Hi,

@Kurt, just like the line 67 in https://github.com/openstack/marconi/blob/master/marconi/queues/bootstrap.py ?

"self.conf" should be "self._conf"?

This maybe take some time.

Revision history for this message
sai krishna (krishna1256) wrote :

Hi,

I could see this bug is there since long. I can start working if no one is working as of now. Please respond with in a day, so that I could start.

Thanks,
--sai krishna.

Revision history for this message
prashanth raghu (p-isprashanth) wrote :

Edited Files:
-----------------

1. Folder: marconi/queues/transport/wsgi/v1_0
    Files: health.py homedoc.py stats.py queues.py claims.py stats.py metadata.py

2. Folder: marconi/queues/transport/wsgi/v1_0
    Files: health.py homedoc.py stats.py queues.py claims.py stats.py metadata.py

Revision history for this message
sai krishna (krishna1256) wrote :

Hi Prashanth,

For submitting a patch, you should follow Gerrit workflow.Please find additional details in the below link:
https://wiki.openstack.org/wiki/Gerrit_Workflow

and before working on a bug, you will need to assign it to yourself(only if it unassigned or its idle for long time.)

coming to this one, I am already working on this bug.

Thanks,
--sai krishna

Revision history for this message
prashanth raghu (p-isprashanth) wrote :

Hi Sai Krishna,

Sorry for the wrong submission. I did submit a patch following the workflow.

It is here: https://review.openstack.org/#/c/80767/

Revision history for this message
sai krishna (krishna1256) wrote :

Hi Prasanth,

Since you have already made code changes and sent for an initial round of review, please assign this bug to your name and continue working. I will update marconi team about the same.

Thanks,
--sai krishna.

Revision history for this message
prashanth raghu (p-isprashanth) wrote :

hi Sai Krishna,

Sure I will do that.

Thanks,
Prashanth

Revision history for this message
Victoria Martinez de la Cruz (vkmc) wrote :

prashanth_ I assumed you were not working anymore in this bug, so a newcomer is taking it.

Changed in zaqar:
assignee: prashanth raghu (p-isprashanth) → nobody
Griffin Ashe (gashe5363)
Changed in zaqar:
assignee: nobody → Griffin (gashe5363)
Changed in zaqar:
status: In Progress → Triaged
Revision history for this message
prashanth raghu (p-isprashanth) wrote :

vkmc: Yes you are right.

Griffin Ashe (gashe5363)
Changed in zaqar:
status: Triaged → In Progress
Revision history for this message
Kurt Griffiths (kgriffs) wrote :

Use your best judgment, with these guidelines in mind:

1. If a member variable is only ever used within the class in which it is defined, it should start with an underscore
2. If a member variable is only ever accessed by one or two "friend" classes, it should still start with an underscore to discourage tight coupling with internal state outside of those friends.
3. If a member variable is part of the public interface, meaning it is envisioned to be used by lots of different classes (conceptually, 3rd parties), the name does not start with an underscore.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to zaqar (master)

Fix proposed to branch: master
Review: https://review.openstack.org/117574

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to zaqar (master)

Reviewed: https://review.openstack.org/117574
Committed: https://git.openstack.org/cgit/openstack/zaqar/commit/?id=d1fd0c2b8920bd34c8800098ac601abec77aacb9
Submitter: Jenkins
Branch: master

commit d1fd0c2b8920bd34c8800098ac601abec77aacb9
Author: earnThis <email address hidden>
Date: Wed Aug 27 18:23:00 2014 -0400

    Add _ prefix to local variables

    A lot of __init__ methods were assigning
    values to attributes that were not prefixed with
    a single underscore, the underscore prefix has been
    added as needed.

    Closes-Bug: 1239834
    Change-Id: Idf7e29b413187f726fb9f8a85959f948db6d669c

Changed in zaqar:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in zaqar:
milestone: none → juno-rc1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in zaqar:
milestone: juno-rc1 → 2014.2
no longer affects: zaqar/icehouse
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.