Skip to content

Instantly share code, notes, and snippets.

@dblandin
Created April 14, 2017 17:34
Show Gist options
  • Save dblandin/e01b914afbe73da4a69982fcf71e821c to your computer and use it in GitHub Desktop.
Save dblandin/e01b914afbe73da4a69982fcf71e821c to your computer and use it in GitHub Desktop.
jq examples | Code Climate Lunch & Learn 4.14.2017
codeclimate analyze -f json -e rubocop > issues.json
cat issues.json | jq
cat issues.json | jq '. | length'
cat issues.json | jq '.[0] | keys'
cat issues.json | jq '.[0].fingerprint'
cat issues.json | jq '.[0] | .check_name, .fingerprint'
cat issues.json | jq '.[] | select(.severity == "minor")'
cat issues.json | jq '.[] | { check: .check_name, fingerprint: .fingerprint }'
cat issues.json | jq '.[0].remediation_points | . * 2'
cat issues.json | jq '.[0] | .remediation_points = .remediation_points * 2'
cat issues.json | jq '[.[].remediation_points]'
cat issues.json | jq '[.[].remediation_points] | add'
cat issues.json | jq 'sort_by(.remediation_points) | reverse | .[0]'
cat issues.json | jq 'max_by(.remediation_points)'
cat issues.json | jq 'unique_by(.check_name) | .[].check_name'kjo
cat issues.json | jq 'group_by(.check_name) | max_by(length) | .[0].check_name'
cat issues.json | jq 'group_by(.check_name) | max_by(length) | .[0].check_name'
cat issues.json | jq 'group_by(.check_name) | max_by(length) | { check_name: .[0].check_name, count: length }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment