Ameba::Formatter::JSONFormatter - ameba 1.6.4

# class Ameba::Formatter::JSONFormatter

- Ameba::Formatter::JSONFormatter
- Ameba::Formatter::BaseFormatter
- Reference
- Object

##
Overview

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,
      }
    }

##
Defined in:

ameba/formatter/json_formatter.cr

##
Instance Method Summary

- #finished(sources) : Nil

  Callback that indicates when inspection is finished.

- #source_finished(source : Source) : Nil

  Callback that indicates when source inspection is finished.

- #started(sources) : Nil

  Callback that indicates when inspecting is started.

### Instance methods inherited from class `Ameba::Formatter::BaseFormatter`

config : Hash(Symbol, Bool | String) config, finished(sources) : Nil finished, output : IO::FileDescriptor | IO::Memory output, source_finished(source : Source) : Nil source_finished, source_started(source : Source) : Nil source_started, started(sources) : Nil started

### Constructor methods inherited from class `Ameba::Formatter::BaseFormatter`

new(output : IO = STDOUT) new

##
Instance Method Detail

def finished(sources) : Nil #
Description copied from class Ameba::Formatter::BaseFormatter

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

def source_finished(source : Source) : Nil #
Description copied from class Ameba::Formatter::BaseFormatter

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

WARNING This method needs to be MT safe

def started(sources) : Nil #
Description copied from class Ameba::Formatter::BaseFormatter

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