aibolit icon indicating copy to clipboard operation
aibolit copied to clipboard

P20_7 Var declaration distance: count statemtnts instead of lines

Open g4s8 opened this issue 4 years ago • 2 comments

I think P20_7 pattern may be more useful if it counts statements instead of lines, e.g. this code:

final CompletableFuture<Boolean> exists = new CompletableFuture<>();
object.asyncCall(() -> {
  // few lines of code here
  exists.complete(result);
});
return exists;

Has only one statement between returning the variable and declaration, but it has multiple lines, so it's a candidate for P20_7. I think amount of lines doesn't really make readability worse, but amount of statements does.

g4s8 avatar May 28 '20 11:05 g4s8

@acheshkov/z please, pay attention to this issue

0crat avatar May 28 '20 11:05 0crat

seems we count ncss, not lines of code. But idea is good.

@acheshkov @aravij Is it worth implementing it?

lyriccoder avatar Jun 09 '20 12:06 lyriccoder