Skip to content

WrapExpensiveLogStatementsInConditionals not to offer wrapping lines which just retrieve some properties #232

@greg-at-moderne

Description

@greg-at-moderne

What problem are you trying to solve?

Avoid noise. Currently WrapExpensiveLogStatementsInConditionals tends to offer excessive changes in some cases. I know it's hard to come up with good rules on what constitutes a heavy operation worth wrapping in an if and what doesn't.
But I still think the logic could be tuned a bit better with some heuristics.

E.g. this is an excessive change:

-  project.getLogger().info("Creating build directory: {}", buildDir.getAbsolutePath());
+  if (project.getLogger().isInfoEnabled()) {
+     project.getLogger().info("Creating build directory: {}", buildDir.getAbsolutePath());
+  }

And there's plenty of similar ones.

Describe the solution you'd like

Maybe skip wrapping if all method calls in the expression are getters?
(which I know they could be expensive operations, but in most of the cases they are not)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions