Repository: Redocly/redocly-cli
Pull request #1192 (2023-07-26 15:11:13)

fix: remove assertions severity from default rulesets
## What/Why/How?

We expose default severity levels for `assertions` in our predefined rulesets what doesn't make too much sense as we don't have any default assertions. And once someone adds an assertion to their **redocly.yaml**, we use `error` as a default severity regardless of the defined in the ruleset. 

Also it contradicts with our current types as we expect the `assertions` field to be of type `Assertion[]`: https://github.com/Redocly/redocly-cli/blob/2e02eda23ba173633db8820fd6d38d65967856b9/packages/core/src/rules/common/assertions/index.ts#L28



## Reference

## Testing

- [x] Locally
- [x] Portal

## Screenshots (optional)

## Check yourself

- [x] Code is linted
- [ ] Tested with redoc/reference-docs/workflows
- [ ] All new/updated code is covered with tests

## Security

- [x] Security impact of change has been considered
- [x] Code follows company security practices and guidelines


github-actions[bot]: | Command | Mean [s] | Min [s] | Max [s] | Relative |
|:---|---:|---:|---:|---:|
| `redocly lint packages/core/src/benchmark/benches/rebilly.yaml` | 1.275 ± 0.036 | 1.207 | 1.315 | 1.00 |
| `redocly-next lint packages/core/src/benchmark/benches/rebilly.yaml` | 1.284 ± 0.038 | 1.224 | 1.347 | 1.01 ± 0.04 |

<!-- thollander/actions-comment-pull-request "hyperfine-comparison" -->
github-actions[bot]: <!-- jest coverage report action for options with hash 3339ae53a38c44382c0fb4491bdb282d -->

## Coverage report 

❌ An unexpected error occurred. For more details, [check console](https://github.com/Redocly/redocly-cli/actions/runs/5670539057) 
```
Error: The process '/opt/hostedtoolcache/node/18.17.0/x64/bin/npm' failed with exit code 1
```

| <div title="Status of coverage:&#10; 🟢 - ok&#10; 🟡 - slightly more than threshold&#10; 🔴 - under the threshold">St.<sup>:grey_question:</sup></div> | Category   | Percentage | Covered / Total |
| :----------------------------------------------------------------------------------------------------------------------------------------------------: | :--------- | :--------- | :-------------: |
|                                                                           🟡                                                                           | Statements | 74.45%     |    3727/5006    |
|                                                                           🟡                                                                           | Branches   | 65.38%     |    2062/3154    |
|                                                                           🟡                                                                           | Functions  | 66.7%      |     619/928     |
|                                                                           🟡                                                                           | Lines      | 74.53%     |    3477/4665    |


<details><summary>Show files with reduced coverage 🔻</summary>
<br/>

| <div title="Status of coverage:&#10; 🟢 - ok&#10; 🟡 - slightly more than threshold&#10; 🔴 - under the threshold">St.<sup>:grey_question:</sup></div> | File                                                         | Statements                                                     | Branches                                                      | Functions | Lines                                                        |
| :----------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------- | :------------------------------------------------------------- | :------------------------------------------------------------ | :-------- | :----------------------------------------------------------- |
|                                                                           🟢                                                                           | <div title="core/src/config/rules.ts">`...` / rules.ts</div> | <div title="Base coverage is: 93.33%">86.67% (-6.67% 🔻)</div> | <div title="Base coverage is: 100%">83.33% (-16.67% 🔻)</div> | 80%       | <div title="Base coverage is: 100%">92.86% (-7.14% 🔻)</div> |

</details>

## Test suite run failed

<details><summary>Failed tests: 1/618. Failed suites: 1/90.</summary>
<br/>

```
  ● resolveConfig › should ignore minimal from the root and read local file

    expect(received).toMatchSnapshot()

    Snapshot name: `resolveConfig should ignore minimal from the root and read local file 1`

    - Snapshot  - 1
    + Received  + 0

    @@ -31,11 +31,10 @@
          "spec-components-invalid-map-name": "error",
        },
        "preprocessors": Object {},
        "recommendedFallback": false,
        "rules": Object {
    -     "assertions": "warn",
          "boolean-parameter-prefixes": "error",
          "component-name-unique": "off",
          "info-contact": "off",
          "info-license": "warn",
          "info-license-url": "warn",

      462 |     delete apis['petstore'].styleguide.extendPaths;
      463 |     delete apis['petstore'].styleguide.pluginPaths;
    > 464 |     expect(apis['petstore'].styleguide).toMatchSnapshot();
          |                                         ^
      465 |   });
      466 |
      467 |   it('should default to the extends from the main config if no extends defined', async () => {

      at packages/core/src/config/__tests__/config-resolvers.test.ts:464:41
      at fulfilled (packages/core/src/config/__tests__/config-resolvers.test.ts:5:58)

```

</details>


<p align="right">Report generated by <a href="https://github.com/ArtiomTr/jest-coverage-report-action">🧪jest coverage report action</a> from 21a462f57491dfefbf990aed49d4b7fd19090ed8</p>

changeset-bot[bot]: ###  🦋  Changeset detected

Latest commit: fa42e9969b66b87f53524fc4836864ebd0355e57

**The changes in this PR will be included in the next version bump.**

<details><summary>This PR includes changesets to release 2 packages</summary>

  | Name                  | Type  |
| --------------------- | ----- |
| @redocly/openapi-core | Patch |
| @redocly/cli          | Patch |

</details>

Not sure what this means? [Click here  to learn what changesets are](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add another changeset to this PR](https://github.com/Redocly/redocly-cli/new/fix/remove-assertions-severity-in-rulesets?filename=.changeset/lazy-planes-kiss.md&value=---%0A%22%40redocly%2Fopenapi-core%22%3A%20patch%0A---%0A%0Afix%3A%20remove%20assertions%20severity%20from%20default%20rulesets%0A)



Patch:
diff --git a/.changeset/great-impalas-explain.md b/.changeset/great-impalas-explain.md
new file mode 100644
index 00000000..a357951b
--- /dev/null
+++ b/.changeset/great-impalas-explain.md
@@ -0,0 +1,5 @@
+---
+'@redocly/openapi-core': patch
+---
+
+Fixed empty custom rules having severity in default rulesets.
diff --git a/packages/core/src/config/all.ts b/packages/core/src/config/all.ts
index 3bb3e471..6bce7180 100644
--- a/packages/core/src/config/all.ts
+++ b/packages/core/src/config/all.ts
@@ -18,7 +18,6 @@ export default {
     'operation-description': 'error',
     'operation-2xx-response': 'error',
     'operation-4xx-response': 'error',
-    assertions: 'error',
     'operation-operationId': 'error',
     'operation-summary': 'error',
     'operation-operationId-unique': 'error',
diff --git a/packages/core/src/config/minimal.ts b/packages/core/src/config/minimal.ts
index df194c68..487c374d 100644
--- a/packages/core/src/config/minimal.ts
+++ b/packages/core/src/config/minimal.ts
@@ -17,7 +17,6 @@ export default {
     'operation-description': 'off',
     'operation-2xx-response': 'warn',
     'operation-4xx-response': 'off',
-    assertions: 'warn',
     'operation-operationId': 'warn',
     'operation-summary': 'warn',
     'operation-operationId-unique': 'warn',
diff --git a/packages/core/src/config/recommended.ts b/packages/core/src/config/recommended.ts
index 3456f8b2..6fabb7e7 100644
--- a/packages/core/src/config/recommended.ts
+++ b/packages/core/src/config/recommended.ts
@@ -16,7 +16,6 @@ export default {
     'path-parameters-defined': 'error',
     'operation-description': 'off',
     'operation-2xx-response': 'warn',
-    assertions: 'warn',
     'operation-4xx-response': 'warn',
     'operation-operationId': 'warn',
     'operation-summary': 'error',


Test patch:
diff --git a/packages/core/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap b/packages/core/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap
index ae0b117a..b64be2cb 100644
--- a/packages/core/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap
+++ b/packages/core/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap
@@ -36,7 +36,6 @@ Object {
   "preprocessors": Object {},
   "recommendedFallback": false,
   "rules": Object {
-    "assertions": "warn",
     "boolean-parameter-prefixes": "error",
     "component-name-unique": "off",
     "info-contact": "off",