Skip to content

Instantly share code, notes, and snippets.

@mrVanboy
Last active January 10, 2024 11:58
Show Gist options
  • Save mrVanboy/4472ead613102b382691b3b28ae03ae4 to your computer and use it in GitHub Desktop.
Save mrVanboy/4472ead613102b382691b3b28ae03ae4 to your computer and use it in GitHub Desktop.
Markdown table from code-climate.json with jq

Example of the creating markdown table from the gl-code-quality-report.json Gitlab's code quality report with codeclimate SPEC.

  1. Install jq
  2. Run the next command to convert gl-code-quality-report.json to markdown:
    jq -r '. | sort_by((.location.path | explode | map(-.)), .location.lines.begin) | .[] | @text "| [\(.location.path):\(.location.lines.begin)](../blob/BRANCH-NAME/\(.location.path)#L\(.location.lines.begin)) | \(.description)"' gl-code-quality-report.json
  3. Add table header to the beggigning of the output:
    | Path | Description |
    | --- | --- |
Click to expand the output example
Path Description
app/app_test.go:8 goimports: File is not goimports-ed
app/app_test.go:87 golint: should drop = 0 from declaration of var counter; it is the zero value
@rbelfils
Copy link

rbelfils commented Jan 7, 2021

My codeclimat's json report, write at start some notice:

[
  {
    "name": "java.parse.succeeded",
    "type": "measurement",
    "value": 2,
    "engine_name": "structure"
  },
  {
    "type": "issue",
    "check_name": "squid:S00107",
    "severity": "major",
    "description": "Constructor has 11 parameters, which is greater than 7 authorized.",
    "content": {

Exclude any elemnt doesn't contains 'type = issue'
jq -r '. | map(select(.type | test("issue"; "i"))) | sort_by((.location.path | explode | map(-.)), .location.lines.begin) | .[] | @text "| (.location.path):(.location.lines.begin)#L(.location.lines.begin)) | (.description)"' gl-code-quality-report.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment