Skip to content

Push coverage further on master - #222

Merged
fernandotonon merged 3 commits into
masterfrom
codex/coverage-push-80
Mar 26, 2026
Merged

Push coverage further on master#222
fernandotonon merged 3 commits into
masterfrom
codex/coverage-push-80

Conversation

@fernandotonon

@fernandotonon fernandotonon commented Mar 26, 2026

Copy link
Copy Markdown
Owner

Summary:

  • expand TransformOperator coverage around transform space, node/entity transforms, selection reset, and deletion behavior
  • expand SDManager coverage around model discovery, path resolution, metadata, and settings persistence
  • avoid relying on real AI inference paths in tests and keep focus on CI-safe logic

Verification:

  • targeted local validation is limited because the stable-diffusion-enabled build pulls in a large CUDA stack; GitHub CI will be the authoritative run for this branch

Summary by CodeRabbit

  • Tests
    • Expanded coverage for model management: scanning, filename resolution, metadata detection, and settings persistence.
    • Broadened transform-operation tests: selection/transform behaviors, scene-node/entity updates, selection restore, deletion/undo, and additional quaternion/utility assertions.
  • Bug Fix / Refactor
    • More robust viewport grid updates during selection/transform and safer selection-center calculations with fallbacks for missing or infinite bounds.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Mar 26, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary
SDManager tests
src/SDManager_test.cpp
Adds createModelFile helper, temp-file test scaffolding, and multiple tests for scanning model files (supported extensions, recommended detection), model-file path resolution (direct filenames, dotted basenames, recommended mapping), available-models metadata, and settings persistence.
TransformOperator tests
src/TransformOperator_test.cpp
Reworks tests into a TransformOperatorTests fixture (SetUp/TearDown resetting singletons and initializing Qt/Ogre), adds helpers (node/entity creation, quaternion comparison), and many behavioral tests (transform-space signaling, selection-box color round-trip, ray default, scene-node transform propagation, selection restore/normalization, removal). Original Swap test retained.
TransformOperator runtime change
src/TransformOperator.cpp
onSelectionChanged() now caches viewportGrid once and uses if (viewportGrid) ... guards for all subsequent grid position updates across Node/Entity/SubEntity/no-entity branches.
SelectionSet change
src/SelectionSet.cpp
getSelectionCenter() now computes per-object center from getWorldBoundingBox(true), guards non-finite bounding boxes, and falls back to parent scene-node positions when needed; expanded to block scopes for clarity.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐇 I dug up files and hopped through tests,

Dotted names and grids addressed,
Fixtures set and nodes made right,
Tiny hops that chased the night,
Build be merry, code take flight!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.79% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Push coverage further on master' is vague and generic, using non-descriptive language that doesn't convey the specific nature of the test coverage expansions. Clarify the title to reference specific areas being tested, such as 'Expand test coverage for TransformOperator and SDManager' or 'Add comprehensive tests for transform and model discovery logic'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description effectively summarizes the key changes but does not follow the provided repository template structure with Summary/Technical Details sections and emoji-prefixed categories.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/coverage-push-80

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 identity

If 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

📥 Commits

Reviewing files that changed from the base of the PR and between bf78c18 and e4d5d4d.

📒 Files selected for processing (2)
  • src/SDManager_test.cpp
  • src/TransformOperator_test.cpp

Comment thread src/SDManager_test.cpp
Comment on lines +23 to +31
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();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c117cff8-0898-4289-bd89-595992c039c2

📥 Commits

Reviewing files that changed from the base of the PR and between 26951ad and b6cf50e.

📒 Files selected for processing (1)
  • src/SelectionSet.cpp

@sonarqubecloud

Copy link
Copy Markdown

@fernandotonon
fernandotonon merged commit de0d713 into master Mar 26, 2026
18 checks passed
@fernandotonon
fernandotonon deleted the codex/coverage-push-80 branch March 26, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant