-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
qa: address PMD GuardLogStatement warnings #5209
Conversation
This might take a while to review (92 files changed) but at a cursory glance there's a few questions that occurred to me about this:
|
true. methods still would be called. depending which method it is the impact varies. not calling the method when not logging has, contrary, a clear and predictable impact: no code executed. which is good.
i changed it only where a method is called as log parameter and pmd warned.
we could turn on pmd again, it warns or blocks depending how we set it. there is no problem to use original logger methods, at least imo. there are other opinionated approaches, like using google flogger, which would convert everything, but that might be too much for terasology. personally i would not enforce it, but rely on peoples working brains on code review. as well as local |
you find it easier to chunk it? |
80f9aba
to
c4f4400
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: only reviewed roughly half the files so far. Need to get back to the rest.
Feel free to already apply the requested changes meanwhile.
General assumption: cases in which we want to disable logging completely are extremely rare, so we mainly want to avoid method evaluation in debug logs considering that the typical default log level will be info resulting in error, warning, and info logs being written.
Cases where we want to ignore the PMD warnings instead of using Fluent API to avoid additional verbosity leading to code being harder to read:
- logs in catch clauses -> limited method evaluation
- logs in dedicated warning/error/log methods -> intention of these methods is to write logs; if at all, calling these methods should be guarded
- logs with simple getter methods
engine/src/main/java/org/terasology/engine/audio/openAL/OpenALManager.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/audio/openAL/OpenALManager.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/audio/openAL/staticSound/OpenALSound.java
Outdated
Show resolved
Hide resolved
...ne/src/main/java/org/terasology/engine/audio/openAL/streamingSound/OpenALStreamingSound.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/config/flexible/AutoConfigManager.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/persistence/internal/GlobalStoreLoader.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/logic/characters/CharacterSoundSystem.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/entitySystem/metadata/EventMetadata.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/core/subsystem/common/ConfigurationSubsystem.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/core/module/ModuleInstaller.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more review comments along the same lines as the previous
engine/src/main/java/org/terasology/engine/audio/openAL/OpenALManager.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/audio/openAL/OpenALManager.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/world/block/internal/BlockManagerImpl.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/world/block/internal/BlockManagerImpl.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/world/block/internal/BlockManagerImpl.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/particles/updating/ParticleUpdaterImpl.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/persistence/serializers/EventSerializer.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/persistence/serializers/PrefabSerializer.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/physics/bullet/BulletPhysics.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/physics/bullet/BulletPhysics.java
Outdated
Show resolved
Hide resolved
7cf5139
to
d203bc6
Compare
d203bc6
to
ea2c2b0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally done with all files. Please re-request a review once you implemented all requested changes 🙂
engine/src/main/java/org/terasology/engine/audio/openAL/OpenALManager.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/entitySystem/event/internal/EventSystemImpl.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/entitySystem/event/internal/EventSystemImpl.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/entitySystem/event/internal/EventSystemImpl.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/entitySystem/event/internal/EventSystemImpl.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/rendering/dag/RenderGraph.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/rendering/dag/RenderGraph.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/rendering/dag/RenderTaskListGenerator.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/rendering/dag/RenderTaskListGenerator.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/engine/rendering/dag/RenderTaskListGenerator.java
Outdated
Show resolved
Hide resolved
656055c
to
5c7fa2c
Compare
e5e0e41
to
b34da80
Compare
b34da80
to
07dac47
Compare
07dac47
to
f70c45b
Compare
introduce local varaible where necessary, otherwise ignore warning for the sake of shorter log message line.
Co-authored-by: jdrueckert <[email protected]>
…enGLTexture.java Co-authored-by: jdrueckert <[email protected]>
aa488bc
to
cf50c8e
Compare
addressed most of the stuff. a couple were requesting a functional code change which is not part of a pull request writing log statements different.
- removed line break or switched back to fluent API (using less verbose variant though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@soloturn I went through all files again, applied the requested changes that you resolved without actually applying them. I also refactored your changes to use the less verbose variant of the fluent API that was discussed a while ago in our group sync.
From my pov this is good to go now, so I'm approving it.
For future reference two comments:
- Please try avoid force pushes as they can remove review comments. Force pushes are rarely necessary, usually merging upstream changes or the most recent main branch state in should be sufficient.
- Code refactorings (please don't confuse them with functional changes: introducing a local variable and referencing it does not modify the code's functionality) are fine when addressing code scanner findings.
While writing this second point and remembering your last comment on this PR, I also want to share an observation:
Based on the discussions we had during the work on our last milestone, I expected this PR to be about addressing code scanner findings (in particular PMD GuardLogStatement warnings).
According to your comment, in which you state that this PR is about "writing log statements different", you seem to have a different intent here, though. An intent I didn't suspect, especially in the light of the group discussions where everybody except yourself voiced concerns about the verbosity of the fluent API variant you wanted to switch to...
Maybe this was our main misunderstanding here.
Anyway, this PR is approved now, so feel free to merge it.
using fluent logger avoids evaluating methods, and fixes the PMD warning: log not surrounded by "if". this is in case the argument to a parameterized logger is a method call, like here:
Edit by niruandaleth/jdrueckert:
PMD warnings were fixed in different ways, among others the following variant of the fluent API which is less verbose than the one originally proposed (see above):