class

Ameba::Formatter::JSONFormatter

Inherits Ameba::Formatter::BaseFormatter < Reference < Object

A formatter that produces the result in a json format.

Example:

{
  "metadata": {
    "ameba_version": "x.x.x",
    "crystal_version": "x.x.x",
  },
  "sources": [
    {
      "issues": [
        {
          "location": {
            "column": 7,
            "line": 17,
          },
          "end_location": {
            "column": 20,
            "line": 17,
          },
          "message": "Useless assignment to variable `a`",
          "rule_name": "UselessAssign",
          "severity": "Convention",
        },
        {
          "location": {
            "column": 7,
            "line": 18,
          },
          "end_location": {
            "column": 8,
            "line": 18,
          },
          "message": "Useless assignment to variable `a`",
          "rule_name": "UselessAssign",
        },
        {
          "location": {
            "column": 7,
            "line": 19,
          },
          "end_location": {
            "column": 9,
            "line": 19,
          },
          "message": "Useless assignment to variable `a`",
          "rule_name": "UselessAssign",
          "severity": "Convention",
        },
      ],
      "path": "src/ameba/formatter/json_formatter.cr",
    },
  ],
  "summary": {
    "issues_count": 3,
    "target_sources_count": 1,
  }
}

Instance methods

finished(sources) : Nil

Callback that indicates when inspection is finished. A list of inspected sources is passed as an argument.

Source
source_finished(source : Source) : Nil

Callback that indicates when source inspection is finished. A corresponding source is passed as an argument.

WARNING: This method needs to be MT safe

Source
started(sources) : Nil

Callback that indicates when inspecting is started. A list of sources to inspect is passed as an argument.

Source