[Arch] Suspicious unused variable

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
chennes
Veteran
Posts: 3876
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

[Arch] Suspicious unused variable

Post by chennes »

In ArchRebar.py, the main execute() function has the following few lines of code:

Code: Select all

428            if obj.OffsetStart.Value:
429                baseoffset = DraftVecUtils.scaleTo(axis,obj.OffsetStart.Value)
430            else:
431                baseoffset = None
That variable, baseoffset, is never used, despite being carefully set to None in the else branch. Should it be getting used someplace? If not, I'll rewrite to:

Code: Select all

            if obj.OffsetStart.Value:
                _ = DraftVecUtils.scaleTo(axis,obj.OffsetStart.Value)
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: [Arch] Suspicious unused variable

Post by carlopav »

I'm not commenting on the code, but may I ask (out of curiosity) why in this particular case you would have renamed the variable to "_" and not have deleted the whole code?
follow my experiments on BIM modelling for architecture design
User avatar
chennes
Veteran
Posts: 3876
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: [Arch] Suspicious unused variable

Post by chennes »

I was just assuming that DraftVecUtils.scaleTo(axis,obj.OffsetStart.Value) had some kind of side effect. I figured it was safer to keep it than to risk not performing some necessary operation.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: [Arch] Suspicious unused variable

Post by carlopav »

Hmmm:
https://github.com/FreeCAD/FreeCAD/blob ... ls.py#L242
The function doesnt seem to manipulate the given object, but just to return a new Vector. Am i right?
follow my experiments on BIM modelling for architecture design
Post Reply