vscode-checkstyle icon indicating copy to clipboard operation
vscode-checkstyle copied to clipboard

Provide an automatic fix for NeedBraces

Open EliteMasterEric opened this issue 2 years ago • 0 comments

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;
    }
  }

EliteMasterEric avatar Aug 24 '21 00:08 EliteMasterEric