Skip to content

Fix MA0094 and MA0096 warnings by implementing IComparable and IEquatable in Property and ParameterInstance#765

Open
berezovskyi wants to merge 2 commits into
mainfrom
fix-ma0094-ma0096-warnings-351332819402286911
Open

Fix MA0094 and MA0096 warnings by implementing IComparable and IEquatable in Property and ParameterInstance#765
berezovskyi wants to merge 2 commits into
mainfrom
fix-ma0094-ma0096-warnings-351332819402286911

Conversation

@berezovskyi
Copy link
Copy Markdown
Member

@berezovskyi berezovskyi commented May 23, 2026

Eliminates compiler warnings MA0094 and MA0096 by implementing missing IComparable<T> and IEquatable<T> interfaces. Also correctly implements Equals and GetHashCode for properties based on their underlying values, safely guarding against potential null references and adhering to equality contract rules. Tested locally to ensure zero side effects.


PR created automatically by Jules for task 351332819402286911 started by @berezovskyi

Summary by CodeRabbit

  • Bug Fixes

    • Improved null-safe comparison and deterministic ordering for resource instances to prevent runtime comparison/errors with uninitialized values.
  • Refactor

    • Standardized equality and hashing for resource objects to ensure consistent behavior and more reliable identity comparisons across the SDK.

Review Change Stack

- Add `IEquatable<Property>` to `Property.cs` and implement `Equals`/`GetHashCode` methods matching existing `CompareTo` logic.
- Ensure `Property.GetHashCode` correctly derives hash codes from escaped absolute URIs.
- Add `IComparable<ParameterInstance>` and `IEquatable<ParameterInstance>` to `ParameterInstance.cs`.
- Introduce null safety to `ParameterInstance.CompareTo` while retaining ordinal string comparison behavior.

Co-authored-by: berezovskyi <64734+berezovskyi@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d5affaff-0dde-4470-9543-9e7e3686fb03

📥 Commits

Reviewing files that changed from the base of the PR and between 841ab71 and acb1943.

📒 Files selected for processing (1)
  • OSLC4Net_SDK/OSLC4Net.Client/Oslc/Resources/ParameterInstance.cs

Walkthrough

ParameterInstance and Property classes now implement IEquatable with null-safe equality and hash code logic; ParameterInstance also changed CompareTo to accept a nullable argument and use ordinal string comparison.

Changes

IEquatable and IComparable for resource types

Layer / File(s) Summary
ParameterInstance comparable and equatable support
OSLC4Net_SDK/OSLC4Net.Client/Oslc/Resources/ParameterInstance.cs
ParameterInstance class declares IComparable<ParameterInstance> and IEquatable<ParameterInstance>. CompareTo is refactored to accept a nullable parameter, use string.Compare with StringComparison.Ordinal, and handle null name deterministically. Equals(ParameterInstance? other) is added alongside overrides for Equals(object? obj) and GetHashCode() (hashing the name field or returning 0 when null).
Property equatable support
OSLC4Net_SDK/OSLC4Net.Core/Model/Property.cs
Property class declares IEquatable<Property>. New Equals(Property? other) uses CompareTo for equality, with overrides for Equals(object? obj) and GetHashCode() that hash both the name field and the absolute URI of propertyDefinition.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Two classes now compare with grace,
No null pointers show their face,
ParameterInstance and Property align,
With equal, comparable design,
Hash codes and equality shine! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: fixing MA0094/MA0096 warnings by implementing IComparable and IEquatable in both Property and ParameterInstance classes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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 fix-ma0094-ma0096-warnings-351332819402286911

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.28%. Comparing base (7516ac0) to head (acb1943).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #765      +/-   ##
==========================================
- Coverage   51.41%   51.28%   -0.13%     
==========================================
  Files         174      174              
  Lines       10401    10427      +26     
  Branches     1057     1069      +12     
==========================================
  Hits         5348     5348              
- Misses       4793     4819      +26     
  Partials      260      260              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@OSLC4Net_SDK/OSLC4Net.Client/Oslc/Resources/ParameterInstance.cs`:
- Around line 141-165: The CompareTo implementation in ParameterInstance (method
CompareTo(ParameterInstance? o)) reverses the comparison arguments causing
inverted sort order; update the final return to compare this instance's name
against the other by calling string.Compare(name, oName,
StringComparison.Ordinal) (using the existing GetName()/name variables) so that
CompareTo honors IComparable<T> semantics.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: df9e8d12-3814-414a-9344-158a7fbb1cb2

📥 Commits

Reviewing files that changed from the base of the PR and between 7516ac0 and 841ab71.

📒 Files selected for processing (2)
  • OSLC4Net_SDK/OSLC4Net.Client/Oslc/Resources/ParameterInstance.cs
  • OSLC4Net_SDK/OSLC4Net.Core/Model/Property.cs

Comment thread OSLC4Net_SDK/OSLC4Net.Client/Oslc/Resources/ParameterInstance.cs
- Fixes inverted sort order in `ParameterInstance.CompareTo` by comparing `name` against `oName` rather than the reverse.
- Preserves standard `IComparable<T>` semantics.

Co-authored-by: berezovskyi <64734+berezovskyi@users.noreply.github.com>
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