-
Notifications
You must be signed in to change notification settings - Fork 15
CLOUDP-287250: Add rule IPA-113 Singleton must not have ID #341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| "@babel/preset-env": "^7.26.0", | ||
| "@eslint/js": "^9.16.0", | ||
| "@jest/globals": "^29.7.0", | ||
| "@stoplight/types": "^14.1.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added as I noticed this one wasn't in the package.json, though we use it in the test files
| async function createSpectral(ruleName) { | ||
| const rulesetPath = path.join(__dirname, '../../rulesets', ruleName.slice(5, 12) + '.yaml'); | ||
| const s = new Spectral({ resolver: httpAndFileResolver }); | ||
| s.setRuleset(await bundleAndLoadRuleset(rulesetPath, { fs, fetch })); | ||
| const ruleset = Object(await bundleAndLoadRuleset(rulesetPath, { fs, fetch })).toJSON(); | ||
| s.setRuleset(getRulesetForRule(ruleName, ruleset)); | ||
| return s; | ||
| } | ||
|
|
||
| function getErrorsForRule(errors, rule) { | ||
| return errors.filter((e) => e.code === rule); | ||
| /** | ||
| * Takes the passed ruleset and returns a ruleset with only the specified rule. | ||
| * | ||
| * @param ruleName the name of the rule | ||
| * @param ruleset the ruleset containing the rule by ruleName and optionally other rules | ||
| * @returns {Object} a ruleset with only the rule with name ruleName | ||
| */ | ||
| function getRulesetForRule(ruleName, ruleset) { | ||
| const modifiedRuleset = { rules: {} }; | ||
| modifiedRuleset.rules[ruleName] = ruleset.rules[ruleName].definition; | ||
| return modifiedRuleset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by to create a spectral instance with only the specific rule for the test run
gssbzn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Proposed changes
Adds rule for IPA 113: "Singleton resources must not have a user-provided or system-generated ID".
idor_idit returns a validation errorDrive-by:
Current offenders:
Jira ticket: CLOUDP-287250