Skip to content

Conversation

@yelizhenden-mdb
Copy link
Collaborator

Proposed changes

Jira ticket: CLOUDP-306576

If a field or parameter isn't related to a cloud provider, don’t mark the component as adopting the rule

Checklist

  • I have signed the MongoDB CLA
  • I have added tests that prove my fix is effective or that my feature works

Changes to Spectral

  • I have read the README file for Spectral Updates

Further comments

@andreaangiolillo andreaangiolillo requested a review from Copilot April 2, 2025 11:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request refactors the IPA-119 rule function to improve its handling of default values for cloud provider-related fields and updates unit tests for consistency.

  • Refactored error checking by returning a result object with error information and a flag indicating a cloud provider field.
  • Removed redundant parameter checks and updated unit test names for consistency.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tools/spectral/ipa/rulesets/functions/IPA119NoDefaultForCloudProviders.js Refactored default value checks and error handling for properties and parameters
tools/spectral/ipa/tests/IPA119NoDefaultForCloudProviders.test.js Updated test names for consistency in cloud provider field naming
Comments suppressed due to low confidence (2)

tools/spectral/ipa/rulesets/functions/IPA119NoDefaultForCloudProviders.js:81

  • Potential runtime error: 'propertyObject.schema' is accessed without verifying its existence. Consider adding a check to ensure 'propertyObject.schema' is defined before accessing its 'default' property.
if (propertyObject.name === propertyNameToLookFor) {

tools/spectral/ipa/tests/IPA119NoDefaultForCloudProviders.test.js:50

  • [nitpick] Test case name is inconsistent with the other case using 'cloudProvider'. Consider renaming it to 'invalid when cloudProvider field has default value' for clarity and uniformity.
name: 'invalid when provider field has default value',

@yelizhenden-mdb yelizhenden-mdb marked this pull request as ready for review April 2, 2025 11:10
@yelizhenden-mdb yelizhenden-mdb requested a review from a team as a code owner April 2, 2025 11:10
@yelizhenden-mdb yelizhenden-mdb merged commit 5f83dac into main Apr 2, 2025
8 checks passed
@yelizhenden-mdb yelizhenden-mdb deleted the IPA-119-fix branch April 2, 2025 11:21
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.

3 participants