vscode-checkstyle
vscode-checkstyle copied to clipboard
Provide an automatic fix for NeedBraces
Config example:
{
"type": "NeedBraces",
"props": {
"allowSingleLineStatement": true,
"tokens": [
"FOR",
"IF",
"ELSE_IF",
"WHILE",
"DO_WHILE"
],
"severity": "INFO"
}
}
Code example:
function testFunction(input:String):Int {
// valid, one line.
if (input == "one") return 1;
// valid, uses braces.
if (input == "seven") {
return 7;
}
// Invalid, triggers check style NeedsBraces.
/*
if (input == "nine")
return 9;
*/
// Automatic fix applied.
if (input == "nine") {
return 9;
}
}