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

Cppcheck 2.15 #5282

Merged
merged 11 commits into from
Oct 31, 2024
Merged

Cppcheck 2.15 #5282

merged 11 commits into from
Oct 31, 2024

Conversation

jmarrec
Copy link
Collaborator

@jmarrec jmarrec commented Oct 29, 2024

Pull request overview

Prompted by recent failures in our cppcheck workflow, use the latest version, and fix more issues that are being caught.

Pull Request Author

  • Model API Changes / Additions
  • Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
  • Model API methods are tested (in src/model/test)
  • EnergyPlus ForwardTranslator Tests (in src/energyplus/Test)
  • If a new object or method, added a test in NREL/OpenStudio-resources: Add Link
  • If needed, added VersionTranslation rules for the objects (src/osversion/VersionTranslator.cpp)
  • Verified that C# bindings built fine on Windows, partial classes used as needed, etc.
  • All new and existing tests passes
  • If methods have been deprecated, update rest of code to use the new methods

Labels:

  • If change to an IDD file, add the label IDDChange
  • If breaking existing API, add the label APIChange
  • If deemed ready, add label Pull Request - Ready for CI so that CI builds your PR

Review Checklist

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • Code Style, strip trailing whitespace, etc.
  • All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App
  • Labeling is ok
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified

@jmarrec jmarrec added Developer Issue Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. labels Oct 29, 2024
@jmarrec jmarrec self-assigned this Oct 29, 2024
Comment on lines +63 to +67
-i src/cli/test/ \
-i src/airflow/contam/ \
-i src/polypartition/ \
-i src/nano/ \
. \
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This effectively adds the root directories "python" and "ruby" to cppcheck

@@ -100,7 +100,7 @@ namespace alfalfa {
/**
* Get a vector of all points currently exported to the Alfalfa API
*/
std::vector<AlfalfaPoint> points();
std::vector<AlfalfaPoint> points() const;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cppcheck 2.13 already complains about this one on develop right now

@@ -48,7 +48,7 @@ namespace model {
/** @name Constructors and Destructors */
//@{

virtual ~Building() = default;
virtual ~Building() override = default;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lots of this.

@@ -48,22 +48,16 @@ namespace model {
/** @name Getters */
//@{

std::string controlVariable() const;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of duplInheritedMembers fixes

Comment on lines 55 to 58
*
* Reimplemented from HVACComponent.
*/
boost::optional<AirLoopHVAC> airLoopHVAC() const; // cppcheck-suppress [duplInheritedMember] for documentation purposes
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some I keep, for documentation purposes mostly, because the docstring is helpful versus the base class one.

@@ -95,7 +95,7 @@ void Surface3dEdge::resetEdgeMatching() {
m_conflictedOrientation = false;
}

bool Surface3dEdge::containsPoint(const Point3d& testVertex) {
bool Surface3dEdge::containsPoint(const Point3d& testVertex) const {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const correctness

@@ -396,7 +396,7 @@ std::vector<Surface3dEdge> Polyhedron::edgesNotTwo(bool includeCreatedEdges) con
}
}
}
for (auto& edge : edgesNotTwo) {
for (const auto& edge : edgesNotTwo) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const correctness

@@ -184,7 +184,7 @@ std::ostream& IddFieldProperties::print(std::ostream& os) const {
os << " \\reference " << reference << '\n';
}
}
if (!references.empty()) {
if (!referenceClassNames.empty()) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was a mistake to begin with (copy paste)

string propertiesText;
if (boost::regex_search(text, matches, iddRegex::line())) {
objectName = string(matches[1].first, matches[1].second);
std::string objectName = string(matches[1].first, matches[1].second);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reducing scope

Comment on lines +179 to 180
// cppcheck-suppress [duplInheritedMember] because PlanarSurface is dumb and returns a vector
boost::optional<SurfacePropertyConvectionCoefficients> surfacePropertyConvectionCoefficients() const;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to break API, but this is clearly wrong.

This is wrong:

/// Returns any SurfacePropertyConvectionCoefficients associated with this surface, does not return SurfacePropertyConvectionCoefficientsMultipleSurface.
std::vector<SurfacePropertyConvectionCoefficients> surfacePropertyConvectionCoefficients() const;

#include "ruby.h"
#include "./RubyException.hpp"
#include <ruby.h>
#include "RubyException.hpp"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curios , why are using relative path above but keeps the hpp name here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand the question, could you rephrase please?

@wenyikuang wenyikuang merged commit ed4415f into develop Oct 31, 2024
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Developer Issue Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants