Skip to content
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

Extending ruleset with default off skips rule #2133

Closed
daniellehanks opened this issue Apr 21, 2022 · 2 comments · Fixed by #2138
Closed

Extending ruleset with default off skips rule #2133

daniellehanks opened this issue Apr 21, 2022 · 2 comments · Fixed by #2138
Assignees
Labels
released t/bug Something isn't working

Comments

@daniellehanks
Copy link

Describe the bug
I had a ruleset that worked exactly how I wanted it to in 5.7.1. In upgrading to the latest 6.3.0, I noticed at least one of my rules isn't evaluating properly when running the cli. I am extending a ruleset that I have default to off. I extend a particular rule to modify it. In 5.7.1, the rule fails appropriately. In 6.3.0 it does not. Possibly a bug, possibly some sort of change in how I need to set up .spectral.yaml?

To Reproduce
openapi.yaml:

openapi: 3.0.0
info:
  title: test
  version: 1.0.0
  description: test
servers:
  - url: 'http://localhost:5000'
paths:
  '/test':
    get:
      operationId: test
      summary: A summary.
      description: |
        A description
      tags:
        - test
      responses:
        '200':
          description: OK

tags:
  - name: test

.spectral.yaml:

formats:
  - oas3
extends:
  -
    - https://raw.githubusercontent.com/openapi-contrib/style-guides/15d28d5/openapi.yml
    - 'off'
rules:
  operation-short-summary:
    description:
      Operation summary should be short and sweet, no full stops, and less than
      40 characters.
    severity: error
    recommended: true
    type: "style"
    given:
      $.paths.*[?(
      @property === 'get' ||
      @property === 'put' ||
      @property === 'post' ||
      @property === 'delete' ||
      @property === 'options' ||
      @property === 'head' ||
      @property === 'patch' ||
      @property === 'trace'
      )]
    then:
      - field: summary
        function: pattern
        functionOptions:
          notMatch: "\\."
      - field: summary
        function: length
        functionOptions:
          max: 40

Running spectral lint openapi.yaml with 5.7.1:

openapi.yaml
 12:16  error  operation-short-summary  Operation summary should be short and sweet, no full stops, and less than 40 characters.  paths./test.get.summary

With 6.3.0:

No results with a severity of 'error' or higher found!

If I remove the off part, 6.3.0 fails like 5.7.1.

Expected behavior
The rule to properly work and be evaluated as expected in 6.3.0 as it is in 5.7.1.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (remove any that are not applicable):

  • Library version: 5.7.1/6.3.0
  • OS: MacOS
  • Browser: N/A
@P0lip
Copy link
Contributor

P0lip commented Apr 26, 2022

Hi @daniellehanks!
This appears to be an issue in the Spectral itself. There is nothing wrong with your ruleset.
I'll mark this as a bug.

The issue here is that both your ruleset and the extended one have the same rule called operation-short-summary and that causes an unexpected behavior.

@P0lip P0lip added the t/bug Something isn't working label Apr 26, 2022
@P0lip P0lip self-assigned this Apr 26, 2022
@stoplight-spectral-bot
Copy link
Collaborator

🎉 This issue has been resolved in version @stoplight/spectral-core-v1.12.1 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants