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

🌟 Let's talk about output formats options #5364

Open
ldez opened this issue Jan 31, 2025 · 0 comments
Open

🌟 Let's talk about output formats options #5364

ldez opened this issue Jan 31, 2025 · 0 comments
Assignees
Labels
area: output Related to issue output proposal
Milestone

Comments

@ldez
Copy link
Member

ldez commented Jan 31, 2025

Important

This is a proposal: I don't know if it is possible and what the impact could be inside the code.
The proposal may evolve.


The current configuration
# colored-line-number
# line-number
# json
# colored-tab
# tab
# html
# checkstyle
# code-climate
# junit-xml
# junit-xml-extended
# github-actions
# teamcity
# sarif

output:
  print-issued-lines: false
  print-linter-name: false
  formats:
    - format: json
      path: stderr
    - format: checkstyle
      path: report.xml
    - format: colored-line-number
--out-format=checkstyle:report.xml,json:stdout,line-number-colored
--print-issued-lines=false
--print-linter-name=false

⛑️ The Problems

Global Options but Only For Some Formats

output:
  print-issued-lines: false
  print-linter-name: false
  formats:
    - format: json
      path: stderr
    - format: checkstyle
      path: report.xml
    - format: colored-line-number
  • The option output.print-issued-lines is for line-number, colored-line-number formats.
  • The option output.print-linter-name is for line-number, colored-line-number, tab, colored-tab formats.

Format Names

The names of the colored variants have an unexpected style:

  • line-number, colored-line-number
  • tab, colored-tab

I think tab, tab-colored are more natural.

Slice of Formats

output:
  formats:
    - format: json
      path: stderr
    - format: checkstyle
      path: report.xml
    - format: colored-line-number

Currently, the formats are represented into a slice, this type has been introduced mainly for compatibility reasons with the initial format option (a simple string)

A side effect of a slice is the possibility of defining the same format several times but with different output paths.
But I think this is not a real use case.

Another side effect is the flag parsing complexity because the flag --out-format value is a simple string.

Non-User friendly CLI flag

The current syntax can be used only if you know the syntax and there is no suggestion/completion.

--out-format=checkstyle:report.xml,json:stdout,line-number-colored

💭 Proposal

Configuration

output:
  formats:
    text: # (line-number)
      path: stdout
      print-linter-name: true
      print-issued-line: true
      colors: true
    json:
      path: ./path/to/output.json
    tab:
      path: stdout
      print-linter-name: true
      colors: true
    html:
      path: ./path/to/output.html
    checkstyle:
      path: ./path/to/output.xml
    code-climate:
      path: ./path/to/output.json
    junit-xml:
      path: ./path/to/output.xml
      extended: true
    teamcity:
      path: ./path/to/output.txt
    sarif:
      path: ./path/to/output.json

CLI flags

--output.text.path=stdout
--output.text.print-linter-name=false
--output.text.print-issued-line=false
--output.text.colors=false
--output.json.path=./path/to/output.json
--output.tab.path=stdout
--output.tab.print-linter-name=false
--output.tab.colors=false
--output.html.path=./path/to/output.html
--output.checkstyle.path=./path/to/output.xml
--output.code-climate.path=./path/to/output.json
--output.junit-xml.path=./path/to/output.xml
--output.junit-xml.extended=true
--output.teamcity.path=./path/to/output.txt
--output.sarif.path=./path/to/output.json
example

Before:

--out-format=checkstyle:report.xml,json:stdout,line-number-colored

After:

--output.checkstyle.path=report.xml
--output.json.path=stdout
--output.text.path=stdout
@ldez ldez added area: output Related to issue output proposal labels Jan 31, 2025
@ldez ldez added this to the v2 milestone Jan 31, 2025
@ldez ldez self-assigned this Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: output Related to issue output proposal
Projects
None yet
Development

No branches or pull requests

1 participant