Repository: FreeCAD/FreeCAD
File: src/Mod/PartDesign/App/FeatureExtrude.cpp (C++)

Code before:
void FeatureExtrude::onChanged(const App::Property* prop)
{
    if (!isRestoring() && prop == &Midplane) {
        // Deprecation notice: Midplane property is deprecated and has been replaced by SideType in
        // FreeCAD 1.1 when FeatureExtrude was refactored.
        App::DocumentObject* obj = Profile.getValue();
        auto baseName = obj ? obj->getNameInDocument() : "";
        Base::Console().warning(
            "The 'Midplane' property being set for the extrusion of %s is deprecated and has "
            "been replaced by the 'SideType' property in FeatureExtrude. Please update your script,"
            " this property will be removed in a future version.\n",
            baseName
        );
        if (Midplane.getValue()) {
            SideType.setValue("Symmetric");
        }
        else {
            Base::Console()
                .warning("Deprecated Midplane property was explicitly set to False: assuming SideType='One side'\n");
            SideType.setValue("One side");
        }
    }
    ProfileBased::onChanged(prop);
}

TopoShape FeatureExtrude::makeShellFromUpToShape(TopoShape shape, TopoShape sketchshape, gp_Dir& dir)
{

    // Find nearest/furthest face
    std::vector<Part::cutTopoShapeFaces> cfaces = Part::findAllFacesCutBy(shape, sketchshape, dir);
    if (cfaces.empty()) {
        dir = -dir;
        cfaces = Part::findAllFacesCutBy(shape, sketchshape, dir);
    }

    if (cfaces.empty()) {
        return shape;
    }

    struct Part::cutTopoShapeFaces* nearFace {};
    struct Part::cutTopoShapeFaces* farFace {};
    nearFace = farFace = &cfaces.front();
    for (auto& face : cfaces) {
        if (face.distsq > farFace->distsq) {
            farFace = &face;
        }
        else if (face.distsq < nearFace->distsq) {
            nearFace = &face;
        }
    }


Review comment (suggestion):
Is the change that makes it reference still required? References are code smell in general as functions that modify their arguments (that are not `out` arguments specifically) are much harder to reason about.

Code after:
void FeatureExtrude::onChanged(const App::Property* prop)
{
    if (!isRestoring() && prop == &Midplane) {
        // Deprecation notice: Midplane property is deprecated and has been replaced by SideType in
        // FreeCAD 1.1 when FeatureExtrude was refactored.
        App::DocumentObject* obj = Profile.getValue();
        auto baseName = obj ? obj->getNameInDocument() : "";
        Base::Console().warning(
            "The 'Midplane' property being set for the extrusion of %s is deprecated and has "
            "been replaced by the 'SideType' property in FeatureExtrude. Please update your script,"
            " this property will be removed in a future version.\n",
            baseName
        );
        if (Midplane.getValue()) {
            SideType.setValue("Symmetric");
        }
        else {
            Base::Console()
                .warning("Deprecated Midplane property was explicitly set to False: assuming SideType='One side'\n");
            SideType.setValue("One side");
        }
    }
    ProfileBased::onChanged(prop);
}

TopoShape FeatureExtrude::makeShellFromUpToShape(TopoShape shape, TopoShape sketchshape, gp_Dir dir)
{

    // Find nearest/furthest face
    std::vector<Part::cutTopoShapeFaces> cfaces = Part::findAllFacesCutBy(shape, sketchshape, dir);
    if (cfaces.empty()) {
        dir = -dir;
        cfaces = Part::findAllFacesCutBy(shape, sketchshape, dir);
    }

    if (cfaces.empty()) {
        return shape;
    }

    struct Part::cutTopoShapeFaces* nearFace {};
    struct Part::cutTopoShapeFaces* farFace {};
    nearFace = farFace = &cfaces.front();
    for (auto& face : cfaces) {
        if (face.distsq > farFace->distsq) {
            farFace = &face;
        }
        else if (face.distsq < nearFace->distsq) {
            nearFace = &face;
        }
    }