Must-share information:
- Sonarqube 6.7.1, 6.7.4
- Using /api/rules API
- I never succeeded in using this API
First of all, it seems that parameters documentation isn’t right, as it’s shown that only the key
is required while finally the ̀template_key` parameter is also requried.
Also, after many try I couldn’t successfully realize a good call (curl). I tried many way and when I fix the request using all required parameters in the request it fails to work, e.g. :
curl -v -su admin:admin -X POST 'localhost:9000/api/rules/create?custom_key="cat"&template_key="dog"'
curl -su admin:admin \
--header "Content-Type: application/json" \
--request POST \
--data '{"custom_key":"checkstyle:Custom_InnerAssignmentCheck","markdown_description":"Checks for assignments in subexpressions, such as in String s = Integer.toString(i = 2);.\n\nThis custom rule inherits from Inner Assignment template.","name":"Custom Inner Assignement","severity":"MAJOR","status":"READY","template_key":"chekstyle:com.puppycrawl.tools.checkstyle.checks.coding.InnerAssignmentCheck","type":"CODE_SMELL"}' \
http://localhost:9000/api/rules/create
curl -v -su admin:admin -X POST 'localhost:9000/api/rules/create?custom_key="checkstyle:Custom_InnerAssignmentCheck"&markdown_description="Checks for assignments in subexpressions, such as in String s = Integer.toString(i = 2);.\n\nThis custom rule inherits from Inner Assignment template."&name="Custom Inner Assignment"&severity="MAJOR"&status="READY"&template_key="checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.InnerAssignmentCheck"&type="CODE_SMELL"'