You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class Test {
public void demo() {
try {
throw new RuntimeException("test");
} catch (RuntimeException exception) {
log.error("test", exception);
throw new RuntimeException("test", exception);
}
}
}
The rule violation in Test.java is not reported.
I expect that checkstyle doesn't recognise the logger as he gets declared as class field at compile time by lombok.
Interestingly adding the static final log field by hand to any class of the projects helps checkstle enough too then find EitherLogOrThrowCheck violations in the project.
PS: I really tried building a working cli example but was unable to do so.
The text was updated successfully, but these errors were encountered:
Since lombok modifies the bytecode in the JVM, we have so far been against making special overrides just for it. We deal with the source code as it is.
How about, instead of extending the check to recognise lombok / one liberty the EitherLogOrThrowCheck could have a parameter to tread all class fields with name X as loggers.
PS: I really tried building a working cli example but was unable to do so.
please share problems that run into, we do want to ease issue creation process, we appreciate feedback.
Did you fail to download jars ?
checkstyle is sourcecode analyzer (not a bitecode), so it works badly with bycode generation tools. Lombok is inly one of them, if we allow lombok there will another issue to allow something else.
Lombok can probably change/extend behavior of annotation and we will have to deal with different versions and .... .
As this is not a main checkstyle project, we have more freedom to experiments.
What if we will just create new Check based on EitherLogOrThrowCheck and name it EitherLogOrThrowLombokCheck and let it validate code as you suggested. So you will use new Check and all other users will not be affected.
/var/tmp $ cat YOUR_FILE.java
/var/tmp $ cat config.xml
The rule violation in Test.java is not reported.
I expect that checkstyle doesn't recognise the logger as he gets declared as class field at compile time by lombok.
Interestingly adding the static final log field by hand to any class of the projects helps checkstle enough too then find
EitherLogOrThrowCheck
violations in the project.PS: I really tried building a working cli example but was unable to do so.
The text was updated successfully, but these errors were encountered: