Skip to content

Commit

Permalink
GRIDEDIT-1310 Fixed some sonar cloud warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
BillSenior committed Aug 8, 2024
1 parent 5dbd215 commit c5d507c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace meshkernelapi
/// @brief Constructor.
///
/// Keeps a reference to the active MeshKernelState and copies its pointers
MKStateUndoAction(MeshKernelState& mkState);
explicit MKStateUndoAction(MeshKernelState& mkState);

private:
/// @brief Swap the pointer in the active state (referred to by m_mkStateReference) with the copies of the pointers.
Expand Down
27 changes: 27 additions & 0 deletions libs/MeshKernelApi/src/MKStateUndoAction.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
//---- GPL ---------------------------------------------------------------------
//
// Copyright (C) Stichting Deltares, 2011-2024.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation version 3.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// contact: [email protected]
// Stichting Deltares
// P.O. Box 177
// 2600 MH Delft, The Netherlands
//
// All indications and logos of, and references to, "Delft3D" and "Deltares"
// are registered trademarks of Stichting Deltares, and remain the property of
// Stichting Deltares. All rights reserved.
//
//------------------------------------------------------------------------------

#include "MeshKernelApi/MKStateUndoAction.hpp"

std::unique_ptr<meshkernelapi::MKStateUndoAction> meshkernelapi::MKStateUndoAction::Create(MeshKernelState& mkState)
Expand Down
3 changes: 0 additions & 3 deletions libs/MeshKernelApi/src/MeshKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,9 +738,6 @@ namespace meshkernelapi
throw meshkernel::MeshKernelError("The selected mesh kernel id does not exist.");
}

auto mk = meshKernelState[meshKernelId];

// TODO should it be an error if the this is not true, the mesh probably does not exist.
if (meshKernelState[meshKernelId].m_mesh2d->GetNumNodes() > 0)
{
meshKernelState[meshKernelId].m_mesh2d->Administrate();
Expand Down
12 changes: 2 additions & 10 deletions libs/MeshKernelApi/tests/src/UndoTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,7 @@ bool CheckUndoStateCount(const int meshKernelId, const int expectedCommitted, co
int restoredCount;
int errorCode = mkapi::mkernel_undo_state_count_for_id(meshKernelId, committedCount, restoredCount);

if (errorCode != mk::ExitCode::Success)
{
return false;
}

return committedCount == expectedCommitted && restoredCount == expectedRestored;
return errorCode == mk::ExitCode::Success && committedCount == expectedCommitted && restoredCount == expectedRestored;
}

TEST(UndoTests, BasicAllocationDeallocationTest)
Expand Down Expand Up @@ -911,10 +906,7 @@ TEST(UndoTests, UnstructuredGridConnection)
6.0, 6.0, 6.0, 7.0, 7.0, 7.0, 8.0, 8.0, 8.0};

// Shift the nodes of subdomain 1 slightly to match the generated mesh
for (size_t i = 0; i < expectedNodesDisconnectedX.size(); ++i)
{
expectedNodesDisconnectedX[i] += fraction * clg2DeltaX;
}
std::ranges::for_each (expectedNodesDisconnectedX, [fraction, clg2DeltaX](double& value){value += fraction * clg2DeltaX;});

for (size_t i = 0; i < static_cast<size_t>(mesh2d.num_nodes); ++i)
{
Expand Down

0 comments on commit c5d507c

Please sign in to comment.