Esc

single_case_switch

Finds a switch with a single case, which is an if.

Category style, warn by default.

Example
#import "Basic";

Mode :: enum {
    QUIET;
    VERBOSE;
    DEBUG;
}

announce :: (mode: Mode) {
    if mode == {
        case .VERBOSE;
            print("loud\n");
    }
}

main :: () {
    announce(.VERBOSE);
}
Diagnostic
warning[single_case_switch]: this `switch` has a single case
  --> example.jai:10:5
   |
10 |     if mode == {
   |     ^^^^^^^^^^^^
   |
help: write an `if` instead
   |
10 -     if mode == {
11 -         case .VERBOSE;
12 -             print("loud\n");
10 +     if mode == .VERBOSE {
11 +         print("loud\n");
   |
   = note: `single_case_switch` is `warn` by default
Fixed
#import "Basic";

Mode :: enum {
    QUIET;
    VERBOSE;
    DEBUG;
}

announce :: (mode: Mode) {
    if mode == .VERBOSE print("loud\n");
}

main :: () {
    announce(.VERBOSE);
}

One case of one value, plus at most a default case.