stoplightio / spectral

A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI (v3.1, v3.0, and v2.0), Arazzo v1.0, as well as AsyncAPI v2.x.
https://stoplight.io/spectral
Apache License 2.0
2.46k stars 233 forks source link

Reduce number of "Using tabs can lead to unpredictable results" messages to 1 per file #2416

Closed pavelkornev closed 11 months ago

pavelkornev commented 1 year ago

User story. In our org we have lots of legacy APIs which are using tabs as indentation. In this case Spectral produces lots of Warnings from the parser with a message Using tabs can lead to unpredictable results.

When I say "lots of", I mean it's really abnormally massive number... for the attached real-world OpenAPI file Spectral generates 21931 parser Warnings (22 THOUSANDS for a single file).

  ...
  630:1   warning  parser  Using tabs can lead to unpredictable results
  630:2   warning  parser  Using tabs can lead to unpredictable results
  630:3   warning  parser  Using tabs can lead to unpredictable results
  630:4   warning  parser  Using tabs can lead to unpredictable results
  631:1   warning  parser  Using tabs can lead to unpredictable results
  631:2   warning  parser  Using tabs can lead to unpredictable results
  631:3   warning  parser  Using tabs can lead to unpredictable results
  631:4   warning  parser  Using tabs can lead to unpredictable results
  632:1   warning  parser  Using tabs can lead to unpredictable results
  632:2   warning  parser  Using tabs can lead to unpredictable results
  632:3   warning  parser  Using tabs can lead to unpredictable results
  632:4   warning  parser  Using tabs can lead to unpredictable results
  632:5   warning  parser  Using tabs can lead to unpredictable results
  633:1   warning  parser  Using tabs can lead to unpredictable results
  633:2   warning  parser  Using tabs can lead to unpredictable results
  633:3   warning  parser  Using tabs can lead to unpredictable results
  ...

The problem with this is that other more serious issues simply invisible in this massive spam from this Warning...

Related issues: https://github.com/stoplightio/spectral/issues/1550

Describe the solution you'd like Return a single Warning of this kind per file. Normally, the file is using either tabs, or spaces. In case of tabs, it doesn't make sense to spam the output with the same issue for each occurrence. If developer decides to change indentation in the file, most likely (s)he will use IDE feature for that which will change it for the whole file anyway, not just in one single occurrence.

BTW, Could you please give us some guidance on what kind of unpredictable results the users may face if they use tabs in their OpenAPI files? This is the most frequently asked question when they see this issue from the tooling.

Thank you.

pavelkornev commented 11 months ago

This issue was caused mainly by our misuse of the YAML parser. We used YAML parser for both — YAML & JSON files. Due to some other differences in YAML parser behaviour with working with JSON files, we decided to differentiate explicitly these file types and use a proper parser for each.

So, this issue is no longer relevant -> closing.

David-Kyrat commented 7 months ago

Hi i am still getting the same issue, could provide explaination on how it was resolved (since this issue is closed)

githorse commented 7 months ago

Yeah not sure why it's closed ... I don't get thousands of errors but I do get one error per line, which is enough to totally obscure any real problems.

bpottier commented 7 months ago

Adding that we are also still seeing this issue. Seems like its not actually resolved?