﻿# V7030\. Suspicious code formatting\. The 'else' keyword may be missing\.

The analyzer has detected a code fragment where the if statement is on the same line as the closing brace of the previous if statement\. Perhaps the else keyword is missing here, causing the program to behave differently than developers intended\. 

The example: 

```cpp
function setPermissions(role) {
  let permissions = Permissions.NONE; 
  if (role == ADMIN) {
    permissions = Permissions.ANY; 
  } if (role == USER) {                // <=
    permissions = Permissions.ONLY_READ; 
  } else {
    permissions = Permissions.NONE; 
  }
}
```

This snippet defines the system permissions based on the user's role\. If the role is `ADMIN`, the `rights` variable is set to `Permissions.ANY`\. However, the checks then continue\. The `role == USER` condition is false, and the `permissions` variable is set to `NONE`\. 

The fixed code:

```cpp
function setPermissions(role) {
  let permissions = Permissions.NONE; 
  if (role == ADMIN) {
    permissions = Permissions.ANY; 
  } else if (role == USER) {
    permissions = Permissions.ONLY_READ; 
  } else {
    permissions = Permissions.NONE; 
  }
}
```

If you do not intend to use the `else-if` chain, change the code formatting for clarity:

```cpp
if (x > 10) {
  Do1(); 
}

if (x > 7) {
  Do2(); 
} else {
  Do3(); 
}
```