nl_before_if

Add or remove blank line before 'if'.

Possible values are ignore, add, remove and force, default ignore.

Examples

Note in both examples comment line is not a "newline".

Add

Code before:

int x = 10;
int y = 20;

// if with else
if (x<y) {
  std::cout << "Also x is less than " << y << '\n';
}
else {
  std::cout << "Also x is more (or equal) than " << y << '\n';
}

x = 20 * x;
if (x<y) {
  std::cout << "Also x is less than " << y << '\n';
}

Code after:

int x = 10;
int y = 20;

// if with else
if (x<y) {
  std::cout << "Also x is less than " << y << '\n';
}
else {
  std::cout << "Also x is more (or equal) than " << y << '\n';
}

x = 20 * x;

if (x<y) {
  std::cout << "Also x is less than " << y << '\n';
}

remove

Code before:

int x = 10;
int y = 20;

// if with else
if (x<y) {
  std::cout << "Also x is less than " << y << '\n';
}
else {
  std::cout << "Also x is more (or equal) than " << y << '\n';
}

x = 20 * x;

if (x<y) {
  std::cout << "Also x is less than " << y << '\n';
}

Code after:

int x = 10;
int y = 20;
// if with else
if (x<y) {
  std::cout << "Also x is less than " << y << '\n';
}
else {
  std::cout << "Also x is more (or equal) than " << y << '\n';
}

x = 20 * x;
if (x<y) {
  std::cout << "Also x is less than " << y << '\n';
}

See also: