nvimtools / none-ls.nvim

null-ls.nvim reloaded / Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.
The Unlicense
2.43k stars 72 forks source link

fix(ansiblelint): Support to the latest output format #70

Closed academo closed 7 months ago

academo commented 7 months ago

I installed ansiblelint and tried to make it work with none-ls but it seems the latest version (v6.22.x) I installed changed the output to the outdated (v5.x)

This code change makes sure it can handle the v6 format and keeps backwards compatibility with the legacy v5 via some simple object detection.

This is the new format you get from ansiblelint v6

[
  {
    "type": "issue",
    "check_name": "syntax-check[specific]",
    "categories": [
      "core"
    ],
    "url": "https://ansible-lint.readthedocs.io/rules/syntax-check/",
    "severity": "blocker",
    "level": "error",
    "description": "'tasks' is not a valid attribute for a PlaybookInclude",
    "fingerprint": "62bced6ef793c4d2c8e8922429b1baf4d75f19a67d2c8cbe4c40967e90157b47",
    "location": {
      "path": "playbook/update-install-pusher.yml",
      "positions": {
        "begin": {
          "line": 7,
          "column": 3
        }
      }
    }
  }
]

The old format (v5)

[
  {
    "type": "issue",
    "check_name": "[syntax-check] 'tasks' is not a valid attribute for a PlaybookInclude",
    "categories": [
      "core",
      "unskippable"
    ],
    "severity": "blocker",
    "description": "...[truncated]...",
    "fingerprint": "575853e16b67ca74e2340f72a4ea1d83ed8c1b47ea351faa4409cb9676ba5716",
    "location": {
      "path": "playbook/update-install-pusher.yml",
      "lines": {
        "begin": {
          "line": 7,
          "column": 3
        }
      }
    },
    "content": {
      "body": "...[truncated]..."
    }
  }
]
mochaaP commented 7 months ago

lgtm, needs more testing

academo commented 7 months ago

@mochaaP I added in the description some examples of the output between versions for clarity in the changes.