Push coverage further on master - #222
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
📝 WalkthroughWalkthroughAdds comprehensive unit tests for SDManager, converts TransformOperator tests to a TEST_F fixture with expanded assertions and setup/teardown, and updates TransformOperator::onSelectionChanged to cache and null-check the viewport grid before updating positions. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/TransformOperator_test.cpp (1)
148-181: Clarify the behavioral distinction between node and entity selection handling.These two tests appear to document different behaviors:
- Line 160-163:
onSelectionChanged()restores a node to its explicitly saved initial state- Line 177-180:
onSelectionChanged()normalizes an entity's parent node to identityIf this asymmetry is intentional (nodes preserve initial state, entity parent nodes normalize), a brief comment explaining the distinction would improve test maintainability.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/TransformOperator_test.cpp` around lines 148 - 181, Add a short clarifying comment in the test file near the two tests (TransformOperatorTests::OnSelectionChangedRestoresNodeInitialState and TransformOperatorTests::OnSelectionChangedNormalizesSelectedEntityParentNode) explaining the intentional behavioral difference: when a SceneNode created/selected via createSelectedNode, onSelectionChanged restores the node to its explicitly saved initial state, whereas when an Ogre::Entity is selected via createSelectedEntity, onSelectionChanged normalizes the entity's parent SceneNode to identity; reference the onSelectionChanged method and the use of SceneNode/Entity in the comment so future readers understand this asymmetry.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/SDManager_test.cpp`:
- Around line 23-31: In createModelFile replace
EXPECT_TRUE(file.open(QIODevice::WriteOnly)) with
ASSERT_TRUE(file.open(QIODevice::WriteOnly)) so the test aborts immediately if
the file cannot be created; this prevents subsequent file.write("stub") and
file.close() from operating on an invalid handle and avoids cascading/undefined
failures in SDManager_test.cpp's createModelFile helper.
---
Nitpick comments:
In `@src/TransformOperator_test.cpp`:
- Around line 148-181: Add a short clarifying comment in the test file near the
two tests (TransformOperatorTests::OnSelectionChangedRestoresNodeInitialState
and
TransformOperatorTests::OnSelectionChangedNormalizesSelectedEntityParentNode)
explaining the intentional behavioral difference: when a SceneNode
created/selected via createSelectedNode, onSelectionChanged restores the node to
its explicitly saved initial state, whereas when an Ogre::Entity is selected via
createSelectedEntity, onSelectionChanged normalizes the entity's parent
SceneNode to identity; reference the onSelectionChanged method and the use of
SceneNode/Entity in the comment so future readers understand this asymmetry.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: fdec8798-8959-4525-9862-7b140a423a0d
📒 Files selected for processing (2)
src/SDManager_test.cppsrc/TransformOperator_test.cpp
| QString createModelFile(const QString& directory, const QString& fileName) | ||
| { | ||
| QDir().mkpath(directory); | ||
| QFile file(QDir(directory).filePath(fileName)); | ||
| EXPECT_TRUE(file.open(QIODevice::WriteOnly)); | ||
| file.write("stub"); | ||
| file.close(); | ||
| return file.fileName(); | ||
| } |
There was a problem hiding this comment.
Use ASSERT_TRUE for file operations to fail fast on error.
If file.open() fails, EXPECT_TRUE will record a failure but continue execution. The subsequent file.write("stub") would then operate on an invalid file handle, potentially causing confusing test failures or undefined behavior. Use ASSERT_TRUE to abort early if the file cannot be created.
Proposed fix
QString createModelFile(const QString& directory, const QString& fileName)
{
- QDir().mkpath(directory);
+ EXPECT_TRUE(QDir().mkpath(directory));
QFile file(QDir(directory).filePath(fileName));
- EXPECT_TRUE(file.open(QIODevice::WriteOnly));
+ ASSERT_TRUE(file.open(QIODevice::WriteOnly)) << "Failed to create: " << file.fileName().toStdString();
file.write("stub");
file.close();
return file.fileName();
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/SDManager_test.cpp` around lines 23 - 31, In createModelFile replace
EXPECT_TRUE(file.open(QIODevice::WriteOnly)) with
ASSERT_TRUE(file.open(QIODevice::WriteOnly)) so the test aborts immediately if
the file cannot be created; this prevents subsequent file.write("stub") and
file.close() from operating on an invalid handle and avoids cascading/undefined
failures in SDManager_test.cpp's createModelFile helper.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/SelectionSet.cpp (1)
289-295: Optional: Extract duplicated center-accumulation logic into a helper.Both branches now implement the same finite/non-finite accumulation pattern. A small helper would reduce drift risk and make future center-policy updates easier.
♻️ Optional refactor sketch
+static Ogre::Vector3 bottomCenterOrNodePos( + const Ogre::AxisAlignedBox& boundingBox, + const Ogre::Vector3& fallbackPos) +{ + if (boundingBox.isFinite()) + return boundingBox.getCenter() - Ogre::Vector3(0, boundingBox.getHalfSize().y, 0); + return fallbackPos; +} ... - const Ogre::AxisAlignedBox boundingBox = obj->getWorldBoundingBox(true); - if (boundingBox.isFinite()) - vResult += (boundingBox.getCenter() - Ogre::Vector3(0, boundingBox.getHalfSize().y, 0)); - else - vResult += obj->getParentSceneNode()->getPosition(); + vResult += bottomCenterOrNodePos( + obj->getWorldBoundingBox(true), + obj->getParentSceneNode()->getPosition()); ... - const Ogre::AxisAlignedBox boundingBox = obj->getParent()->getWorldBoundingBox(true); - if (boundingBox.isFinite()) - vResult += (boundingBox.getCenter() - Ogre::Vector3(0, boundingBox.getHalfSize().y, 0)); - else - vResult += obj->getParent()->getParentSceneNode()->getPosition(); + vResult += bottomCenterOrNodePos( + obj->getParent()->getWorldBoundingBox(true), + obj->getParent()->getParentSceneNode()->getPosition());Also applies to: 303-309
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/SelectionSet.cpp` around lines 289 - 295, Extract the duplicated center-accumulation logic into a small helper (e.g., a static/local function getNodeCenter or accumulateCenter) that takes the scene object pointer (obj) and returns the appropriate center Ogre::Vector3 by performing obj->getWorldBoundingBox(true).isFinite() check and returning boundingBox.getCenter() - Ogre::Vector3(0, boundingBox.getHalfSize().y, 0) or obj->getParentSceneNode()->getPosition(); then replace the two duplicated blocks (the one using vResult += (...) at lines shown and the similar block at 303-309) to call vResult += getNodeCenter(obj) so future center-policy changes are applied in one place.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/SelectionSet.cpp`:
- Around line 289-295: Extract the duplicated center-accumulation logic into a
small helper (e.g., a static/local function getNodeCenter or accumulateCenter)
that takes the scene object pointer (obj) and returns the appropriate center
Ogre::Vector3 by performing obj->getWorldBoundingBox(true).isFinite() check and
returning boundingBox.getCenter() - Ogre::Vector3(0,
boundingBox.getHalfSize().y, 0) or obj->getParentSceneNode()->getPosition();
then replace the two duplicated blocks (the one using vResult += (...) at lines
shown and the similar block at 303-309) to call vResult += getNodeCenter(obj) so
future center-policy changes are applied in one place.
|



Summary:
Verification:
Summary by CodeRabbit