Skip to content
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

refactor: address IntelliJ QAPlug plugin findings #5149

Merged
merged 35 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
aa6ca30
qa: make final fields static
jdrueckert Oct 22, 2023
1a53322
qa: remove unnecessary local before return
jdrueckert Oct 22, 2023
db4f626
qa: avoid instanceof checks in catch clause
jdrueckert Oct 22, 2023
e3d80fb
qa: method/constructor should not throw java.lang.Exception
jdrueckert Oct 22, 2023
f22c1fa
qa: instanceof check covers null check
jdrueckert Oct 22, 2023
9d7204b
qa: avoid toString on String objects
jdrueckert Oct 22, 2023
993b370
qa: remove overrides that only call their super
jdrueckert Oct 22, 2023
315ef35
qa: remove unused private methods
jdrueckert Oct 22, 2023
3c5d507
qa: if statement nesting not necessary
jdrueckert Oct 22, 2023
df3539a
qa: remove unused local variable
jdrueckert Oct 22, 2023
b0ec929
qa: close resources after use
jdrueckert Oct 22, 2023
06c5fcf
qa: use equals() to compare object references
jdrueckert Oct 22, 2023
3428369
Merge branch 'develop' into chore/qaplug-findings
jdrueckert Oct 27, 2023
a3f8fbc
fix: reintroduce override, needed to elevate access modifier
jdrueckert Oct 27, 2023
760a174
fix: exception type in override
jdrueckert Oct 27, 2023
f067ba2
chore: replace invalid javadoc character with unicode representation
jdrueckert Oct 27, 2023
077d488
javadoc: fix broken references
jdrueckert Oct 28, 2023
6a816ed
javadoc: fix disallowed self-closing and empty elements
jdrueckert Oct 28, 2023
a27bd8e
javadoc: fix invalid uses of @param and @return
jdrueckert Oct 28, 2023
c93ad63
javadoc: fix bad use of symbols
jdrueckert Oct 28, 2023
ad27ad0
javadoc: fix disallowed list item tag without surrounding list
jdrueckert Oct 28, 2023
cce1a8b
javadoc: fix erroneous tags
jdrueckert Oct 28, 2023
45e6571
javadoc: fix more references
jdrueckert Oct 28, 2023
35c2bc3
javadoc: fix emphasize tags
jdrueckert Oct 28, 2023
60a41a5
chore: fix missing javadoc errors
jdrueckert Oct 28, 2023
3d13e1f
javadoc: fix @see
jdrueckert Oct 29, 2023
848947e
checkstyle: remove illegal throws
jdrueckert Oct 30, 2023
f585450
checkstyle: remove unused imports
jdrueckert Oct 30, 2023
01e8edd
refactor: replace explicit close with try-with-resources
jdrueckert Oct 30, 2023
b841271
revert: removal of unused param from AbstractFamily constructor
jdrueckert Oct 30, 2023
2aad50f
revert: close zip Filesystem
jdrueckert Oct 30, 2023
49725fa
revert: removing required zip.close
jdrueckert Oct 30, 2023
bf26781
Merge branch 'develop' into chore/qaplug-findings
jdrueckert Oct 31, 2023
971c853
Merge branch 'develop' into chore/qaplug-findings
jdrueckert Nov 6, 2023
08bd7ea
Merge branch 'develop' into chore/qaplug-findings
jdrueckert Nov 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,14 @@
Environment(Name... moduleNames) {
try {
reset(Sets.newHashSet(moduleNames));
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else {
throw new RuntimeException(e);
}
throw new RuntimeException(e);
}
}

protected void reset(Set<Name> moduleNames) throws Exception {
protected void reset(Set<Name> moduleNames) throws IOException {
this.context = new ContextImpl();
RecordAndReplayCurrentStatus recordAndReplayCurrentStatus = new RecordAndReplayCurrentStatus();
context.put(RecordAndReplayCurrentStatus.class, recordAndReplayCurrentStatus);
Expand Down Expand Up @@ -99,7 +97,7 @@
PathManager.getInstance();
}

protected void setupModuleManager(Set<Name> moduleNames) throws Exception {
protected void setupModuleManager(Set<Name> moduleNames) throws RuntimeException {

Check warning on line 100 in engine-tests/src/main/java/org/terasology/engine/Environment.java

View check run for this annotation

Terasology Jenkins.io / CheckStyle

IllegalThrowsCheck

NORMAL: Throwing 'RuntimeException' is not allowed.
Raw output
<p>Since Checkstyle 4.0</p><p> This check can be used to ensure that types are not declared to be thrown. Declaring that a method throws java.lang.Error or java.lang.RuntimeException is almost never acceptable. </p>
// empty
}

Expand Down Expand Up @@ -162,7 +160,7 @@
*
* @throws Exception if something goes wrong
*/
public void close() throws Exception {
public void close() throws RuntimeException {

Check warning on line 163 in engine-tests/src/main/java/org/terasology/engine/Environment.java

View check run for this annotation

Terasology Jenkins.io / CheckStyle

IllegalThrowsCheck

NORMAL: Throwing 'RuntimeException' is not allowed.
Raw output
<p>Since Checkstyle 4.0</p><p> This check can be used to ensure that types are not declared to be thrown. Declaring that a method throws java.lang.Error or java.lang.RuntimeException is almost never acceptable. </p>
CoreRegistry.setContext(null);
context = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ protected void setupConfig() {
}

@Override
protected void setupModuleManager(Set<Name> moduleNames) throws Exception {
protected void setupModuleManager(Set<Name> moduleNames) throws RuntimeException {
TypeRegistry.WHITELISTED_CLASSES = ExternalApiWhitelist.CLASSES.stream().map(Class::getName).collect(Collectors.toSet());

ModuleManager moduleManager = ModuleManagerFactory.create();
Expand Down Expand Up @@ -320,7 +320,7 @@ protected void loadPrefabs() {
}

@Override
public void close() throws Exception {
public void close() throws RuntimeException {
// it would be nice, if elements in the context implemented (Auto)Closeable

// The StorageManager creates a thread pool (through TaskMaster)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.terasology.reflection.ModuleTypeRegistry;
import org.terasology.reflection.TypeRegistry;

import java.io.IOException;
import java.nio.file.Path;
import java.util.stream.Collectors;

Expand All @@ -21,7 +22,7 @@ public abstract class ModuleEnvironmentTest {
protected ModuleTypeRegistry typeRegistry;

@BeforeEach
public void before(@TempDir Path tempHome) throws Exception {
public void before(@TempDir Path tempHome) throws IOException {
PathManager.getInstance().useOverrideHomePath(tempHome);

moduleManager = ModuleManagerFactory.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
private ModuleManagerFactory() {
}

public static ModuleManager create() throws Exception {
public static ModuleManager create() throws RuntimeException {

Check warning on line 15 in engine-tests/src/main/java/org/terasology/engine/testUtil/ModuleManagerFactory.java

View check run for this annotation

Terasology Jenkins.io / CheckStyle

IllegalThrowsCheck

NORMAL: Throwing 'RuntimeException' is not allowed.
Raw output
<p>Since Checkstyle 4.0</p><p> This check can be used to ensure that types are not declared to be thrown. Declaring that a method throws java.lang.Error or java.lang.RuntimeException is almost never acceptable. </p>
// Loading screens, among other things, break when NUI classes are not added to engine.
ModuleManager moduleManager = new ModuleManager("", ImmutableList.of(UIWidget.class));
Module unittestModule = moduleManager.registerPackageModule("org.terasology.unittest");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public long skip(long n) throws IOException {
/**
* Initalizes the vorbis stream. Reads the stream until info and comment are read.
*/
private void initVorbis() throws Exception {
private void initVorbis() throws IOException {
// Now we can read pages
syncState.init();

Expand All @@ -283,7 +283,7 @@ private void initVorbis() throws Exception {
return; //break;
}
// error case. Must not be Vorbis data
throw new Exception("Input does not appear to be an Ogg bitstream.");
throw new IOException("Input does not appear to be an Ogg bitstream.");
}

// Get the serial number and set up the rest of decode.
Expand All @@ -302,15 +302,15 @@ private void initVorbis() throws Exception {
comment.init();
if (streamState.pagein(page) < 0) {
// error; stream version mismatch perhaps
throw new Exception("Error reading first page of Ogg bitstream data.");
throw new IOException("Error reading first page of Ogg bitstream data.");
}
if (streamState.packetout(packet) != 1) {
// no page? must not be vorbis
throw new Exception("Error reading initial header packet.");
throw new IOException("Error reading initial header packet.");
}
if (info.synthesis_headerin(comment, packet) < 0) {
// error case; not a vorbis header
throw new Exception("This Ogg bitstream does not contain Vorbis audio data.");
throw new IOException("This Ogg bitstream does not contain Vorbis audio data.");
}

// At this point, we're sure we're Vorbis. We've set up the logical
Expand Down Expand Up @@ -346,7 +346,7 @@ private void initVorbis() throws Exception {
if (result == -1) {
// Uh oh; data at some point was corrupted or missing!
// We can't tolerate that in a header. Die.
throw new Exception("Corrupt secondary header. Exiting.");
throw new IOException("Corrupt secondary header. Exiting.");
}
info.synthesis_headerin(comment, packet);
i++;
Expand All @@ -364,7 +364,7 @@ private void initVorbis() throws Exception {
bytes = 0;
}
if (bytes == 0 && i < 2) {
throw new Exception("End of file before finding all Vorbis headers!");
throw new IOException("End of file before finding all Vorbis headers!");
}
syncState.wrote(bytes);
}
Expand All @@ -386,7 +386,7 @@ private void initVorbis() throws Exception {
*/
private int decodePacket() {
// check the endianes of the computer.
final boolean bigEndian = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN;
final boolean bigEndian = ByteOrder.nativeOrder().equals(ByteOrder.BIG_ENDIAN);

if (block.synthesis(packet) == 0) {
dspState.synthesis_blockin(block);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ public BaseSoundPool() {

public SOURCE getLockedSource() {
for (SOURCE source : soundSources.keySet()) {
if (!isActive(source)) {
if (lock(source)) {
return source;
}
if (!isActive(source) && lock(source)) {
return source;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ private float findClosestIndex(Color color) {

private Color findClosestColor(float findex) {
int index = DoubleMath.roundToInt(findex * (double) (colors.size() - 1), RoundingMode.HALF_UP);
Color color = colors.get(index);
return color;
return colors.get(index);
}
}
10 changes: 5 additions & 5 deletions engine/src/main/java/org/terasology/engine/core/GameThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private GameThread() {
* @return Whether the currentThread is the gameThread.
*/
public static boolean isCurrentThread() {
return Thread.currentThread() == gameThread;
return Thread.currentThread().equals(gameThread);
}

/**
Expand All @@ -41,7 +41,7 @@ public static boolean isCurrentThread() {
* @param process
*/
public static void asynch(Runnable process) {
if (Thread.currentThread() != gameThread) {
if (!Thread.currentThread().equals(gameThread)) {
pendingRunnables.push(process);
} else {
process.run();
Expand All @@ -56,7 +56,7 @@ public static void asynch(Runnable process) {
* @param process
*/
public static void synch(Runnable process) throws InterruptedException {
if (Thread.currentThread() != gameThread) {
if (!Thread.currentThread().equals(gameThread)) {
BlockingProcess blockingProcess = new BlockingProcess(process);
pendingRunnables.push(blockingProcess);
blockingProcess.waitForCompletion();
Expand All @@ -69,7 +69,7 @@ public static void synch(Runnable process) throws InterruptedException {
* Runs all pending processes submitted from other threads
*/
public static void processWaitingProcesses() {
if (Thread.currentThread() == gameThread) {
if (Thread.currentThread().equals(gameThread)) {
List<Runnable> processes = Lists.newArrayList();
pendingRunnables.drainTo(processes);
processes.forEach(Runnable::run);
Expand All @@ -80,7 +80,7 @@ public static void processWaitingProcesses() {
* Removes all pending processes without running them
*/
public static void clearWaitingProcesses() {
if (gameThread == Thread.currentThread()) {
if (gameThread.equals(Thread.currentThread())) {
pendingRunnables.clear();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public AbstractEventSystemDecorator(EventSystem eventSystem) {
}

public boolean currentThreadIsMain() {
return mainThread == Thread.currentThread();
return mainThread.equals(Thread.currentThread());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import com.google.common.base.MoreObjects;
import org.terasology.engine.audio.AudioManager;
import org.terasology.engine.config.Config;

Check warning on line 7 in engine/src/main/java/org/terasology/engine/core/modes/StateMainMenu.java

View check run for this annotation

Terasology Jenkins.io / CheckStyle

UnusedImportsCheck

NORMAL: Unused import - org.terasology.engine.config.Config.
Raw output
<p>Since Checkstyle 3.0</p><p> Checks for unused import statements. Checkstyle uses a simple but very reliable algorithm to report on unused import statements. An import statement is considered unused if: </p><ul><li> It is not referenced in the file. The algorithm does not support wild-card imports like <code>import java.io.*;</code>. Most IDE's provide very sophisticated checks for imports that handle wild-card imports. </li><li> It is a duplicate of another import. This is when a class is imported more than once. </li><li> The class imported is from the <code>java.lang</code> package. For example importing <code>java.lang.String</code>. </li><li> The class imported is from the same package. </li><li><b>Optionally:</b> it is referenced in Javadoc comments. This check is on by default, but it is considered bad practice to introduce a compile time dependency for documentation purposes only. As an example, the import <code>java.util.Date</code> would be considered referenced with the Javadoc comment <code>{@link Date}</code>. The alternative to avoid introducing a compile time dependency would be to write the Javadoc comment as <code>{@link java.util.Date}</code>. </li></ul><p> The main limitation of this check is handling the case where an imported type has the same name as a declaration, such as a member variable. </p><p> For example, in the following case the import <code>java.awt.Component</code> will not be flagged as unused: </p><pre><code> import java.awt.Component; class FooBar { private Object Component; // a bad practice in my opinion ... } </code></pre>
import org.terasology.engine.config.TelemetryConfig;

Check warning on line 8 in engine/src/main/java/org/terasology/engine/core/modes/StateMainMenu.java

View check run for this annotation

Terasology Jenkins.io / CheckStyle

UnusedImportsCheck

NORMAL: Unused import - org.terasology.engine.config.TelemetryConfig.
Raw output
<p>Since Checkstyle 3.0</p><p> Checks for unused import statements. Checkstyle uses a simple but very reliable algorithm to report on unused import statements. An import statement is considered unused if: </p><ul><li> It is not referenced in the file. The algorithm does not support wild-card imports like <code>import java.io.*;</code>. Most IDE's provide very sophisticated checks for imports that handle wild-card imports. </li><li> It is a duplicate of another import. This is when a class is imported more than once. </li><li> The class imported is from the <code>java.lang</code> package. For example importing <code>java.lang.String</code>. </li><li> The class imported is from the same package. </li><li><b>Optionally:</b> it is referenced in Javadoc comments. This check is on by default, but it is considered bad practice to introduce a compile time dependency for documentation purposes only. As an example, the import <code>java.util.Date</code> would be considered referenced with the Javadoc comment <code>{@link Date}</code>. The alternative to avoid introducing a compile time dependency would be to write the Javadoc comment as <code>{@link java.util.Date}</code>. </li></ul><p> The main limitation of this check is handling the case where an imported type has the same name as a declaration, such as a member variable. </p><p> For example, in the following case the import <code>java.awt.Component</code> will not be flagged as unused: </p><pre><code> import java.awt.Component; class FooBar { private Object Component; // a bad practice in my opinion ... } </code></pre>
import org.terasology.engine.core.GameEngine;
import org.terasology.engine.core.LoggingContext;
import org.terasology.engine.core.modes.loadProcesses.RegisterInputSystem;
Expand All @@ -17,11 +17,11 @@
import org.terasology.engine.rendering.nui.NUIManager;
import org.terasology.engine.rendering.nui.editor.systems.NUIEditorSystem;
import org.terasology.engine.rendering.nui.editor.systems.NUISkinEditorSystem;
import org.terasology.engine.rendering.nui.layers.mainMenu.LaunchPopup;

Check warning on line 20 in engine/src/main/java/org/terasology/engine/core/modes/StateMainMenu.java

View check run for this annotation

Terasology Jenkins.io / CheckStyle

UnusedImportsCheck

NORMAL: Unused import - org.terasology.engine.rendering.nui.layers.mainMenu.LaunchPopup.
Raw output
<p>Since Checkstyle 3.0</p><p> Checks for unused import statements. Checkstyle uses a simple but very reliable algorithm to report on unused import statements. An import statement is considered unused if: </p><ul><li> It is not referenced in the file. The algorithm does not support wild-card imports like <code>import java.io.*;</code>. Most IDE's provide very sophisticated checks for imports that handle wild-card imports. </li><li> It is a duplicate of another import. This is when a class is imported more than once. </li><li> The class imported is from the <code>java.lang</code> package. For example importing <code>java.lang.String</code>. </li><li> The class imported is from the same package. </li><li><b>Optionally:</b> it is referenced in Javadoc comments. This check is on by default, but it is considered bad practice to introduce a compile time dependency for documentation purposes only. As an example, the import <code>java.util.Date</code> would be considered referenced with the Javadoc comment <code>{@link Date}</code>. The alternative to avoid introducing a compile time dependency would be to write the Javadoc comment as <code>{@link java.util.Date}</code>. </li></ul><p> The main limitation of this check is handling the case where an imported type has the same name as a declaration, such as a member variable. </p><p> For example, in the following case the import <code>java.awt.Component</code> will not be flagged as unused: </p><pre><code> import java.awt.Component; class FooBar { private Object Component; // a bad practice in my opinion ... } </code></pre>
import org.terasology.engine.rendering.nui.layers.mainMenu.MessagePopup;
import org.terasology.engine.telemetry.TelemetryScreen;

Check warning on line 22 in engine/src/main/java/org/terasology/engine/core/modes/StateMainMenu.java

View check run for this annotation

Terasology Jenkins.io / CheckStyle

UnusedImportsCheck

NORMAL: Unused import - org.terasology.engine.telemetry.TelemetryScreen.
Raw output
<p>Since Checkstyle 3.0</p><p> Checks for unused import statements. Checkstyle uses a simple but very reliable algorithm to report on unused import statements. An import statement is considered unused if: </p><ul><li> It is not referenced in the file. The algorithm does not support wild-card imports like <code>import java.io.*;</code>. Most IDE's provide very sophisticated checks for imports that handle wild-card imports. </li><li> It is a duplicate of another import. This is when a class is imported more than once. </li><li> The class imported is from the <code>java.lang</code> package. For example importing <code>java.lang.String</code>. </li><li> The class imported is from the same package. </li><li><b>Optionally:</b> it is referenced in Javadoc comments. This check is on by default, but it is considered bad practice to introduce a compile time dependency for documentation purposes only. As an example, the import <code>java.util.Date</code> would be considered referenced with the Javadoc comment <code>{@link Date}</code>. The alternative to avoid introducing a compile time dependency would be to write the Javadoc comment as <code>{@link java.util.Date}</code>. </li></ul><p> The main limitation of this check is handling the case where an imported type has the same name as a declaration, such as a member variable. </p><p> For example, in the following case the import <code>java.awt.Component</code> will not be flagged as unused: </p><pre><code> import java.awt.Component; class FooBar { private Object Component; // a bad practice in my opinion ... } </code></pre>
import org.terasology.engine.telemetry.TelemetryUtils;

Check warning on line 23 in engine/src/main/java/org/terasology/engine/core/modes/StateMainMenu.java

View check run for this annotation

Terasology Jenkins.io / CheckStyle

UnusedImportsCheck

NORMAL: Unused import - org.terasology.engine.telemetry.TelemetryUtils.
Raw output
<p>Since Checkstyle 3.0</p><p> Checks for unused import statements. Checkstyle uses a simple but very reliable algorithm to report on unused import statements. An import statement is considered unused if: </p><ul><li> It is not referenced in the file. The algorithm does not support wild-card imports like <code>import java.io.*;</code>. Most IDE's provide very sophisticated checks for imports that handle wild-card imports. </li><li> It is a duplicate of another import. This is when a class is imported more than once. </li><li> The class imported is from the <code>java.lang</code> package. For example importing <code>java.lang.String</code>. </li><li> The class imported is from the same package. </li><li><b>Optionally:</b> it is referenced in Javadoc comments. This check is on by default, but it is considered bad practice to introduce a compile time dependency for documentation purposes only. As an example, the import <code>java.util.Date</code> would be considered referenced with the Javadoc comment <code>{@link Date}</code>. The alternative to avoid introducing a compile time dependency would be to write the Javadoc comment as <code>{@link java.util.Date}</code>. </li></ul><p> The main limitation of this check is handling the case where an imported type has the same name as a declaration, such as a member variable. </p><p> For example, in the following case the import <code>java.awt.Component</code> will not be flagged as unused: </p><pre><code> import java.awt.Component; class FooBar { private Object Component; // a bad practice in my opinion ... } </code></pre>
import org.terasology.engine.telemetry.logstash.TelemetryLogstashAppender;

Check warning on line 24 in engine/src/main/java/org/terasology/engine/core/modes/StateMainMenu.java

View check run for this annotation

Terasology Jenkins.io / CheckStyle

UnusedImportsCheck

NORMAL: Unused import - org.terasology.engine.telemetry.logstash.TelemetryLogstashAppender.
Raw output
<p>Since Checkstyle 3.0</p><p> Checks for unused import statements. Checkstyle uses a simple but very reliable algorithm to report on unused import statements. An import statement is considered unused if: </p><ul><li> It is not referenced in the file. The algorithm does not support wild-card imports like <code>import java.io.*;</code>. Most IDE's provide very sophisticated checks for imports that handle wild-card imports. </li><li> It is a duplicate of another import. This is when a class is imported more than once. </li><li> The class imported is from the <code>java.lang</code> package. For example importing <code>java.lang.String</code>. </li><li> The class imported is from the same package. </li><li><b>Optionally:</b> it is referenced in Javadoc comments. This check is on by default, but it is considered bad practice to introduce a compile time dependency for documentation purposes only. As an example, the import <code>java.util.Date</code> would be considered referenced with the Javadoc comment <code>{@link Date}</code>. The alternative to avoid introducing a compile time dependency would be to write the Javadoc comment as <code>{@link java.util.Date}</code>. </li></ul><p> The main limitation of this check is handling the case where an imported type has the same name as a declaration, such as a member variable. </p><p> For example, in the following case the import <code>java.awt.Component</code> will not be flagged as unused: </p><pre><code> import java.awt.Component; class FooBar { private Object Component; // a bad practice in my opinion ... } </code></pre>
import org.terasology.engine.utilities.Assets;

/**
Expand Down Expand Up @@ -97,35 +97,6 @@
// pushLaunchPopup();
}

private void pushLaunchPopup() {
Config config = context.get(Config.class);
TelemetryConfig telemetryConfig = config.getTelemetryConfig();
TranslationSystem translationSystem = context.get(TranslationSystem.class);
TelemetryLogstashAppender appender = TelemetryUtils.fetchTelemetryLogstashAppender();
if (!telemetryConfig.isLaunchPopupDisabled()) {
String telemetryTitle = translationSystem.translate("${engine:menu#telemetry-launch-popup-title}");
String telemetryMessage = translationSystem.translate("${engine:menu#telemetry-launch-popup-text}");
LaunchPopup telemetryConfirmPopup = nuiManager.pushScreen(LaunchPopup.ASSET_URI, LaunchPopup.class);
telemetryConfirmPopup.setMessage(telemetryTitle, telemetryMessage);
telemetryConfirmPopup.setYesHandler(() -> {
telemetryConfig.setTelemetryAndErrorReportingEnable(true);

// Enable error reporting
appender.start();
});
telemetryConfirmPopup.setNoHandler(() -> {
telemetryConfig.setTelemetryAndErrorReportingEnable(false);

// Disable error reporting
appender.stop();
});
telemetryConfirmPopup.setOptionButtonText(translationSystem.translate("${engine:menu#telemetry-button}"));
telemetryConfirmPopup.setOptionHandler(() -> {
nuiManager.pushScreen(TelemetryScreen.ASSET_URI, TelemetryScreen.class);
});
}
}

@Override
public void dispose(boolean shuttingDown) {
stopBackgroundMusic();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ private BindableAxis registerBindAxis(String id, BindAxisEvent event, BindableBu
}

private BindableAxis registerRealBindAxis(String id, BindAxisEvent event) {
BindableRealAxis axis = new BindableRealAxis(id.toString(), event);
BindableRealAxis axis = new BindableRealAxis(id, event);
axisBinds.add(axis);
axisLookup.put(id, axis);
return axis;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ public boolean isAlwaysRelevant() {

@Override
public void setAlwaysRelevant(boolean alwaysRelevant) {
if (exists()) {
if (alwaysRelevant != isAlwaysRelevant()) {
setScope(alwaysRelevant ? GLOBAL : CHUNK);
}
if (exists() && alwaysRelevant != isAlwaysRelevant()) {
setScope(alwaysRelevant ? GLOBAL : CHUNK);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,13 +605,9 @@

public Optional<EngineEntityPool> getPool(long id) {
Optional<EngineEntityPool> pool = Optional.ofNullable(poolMap.get(id));
if (!pool.isPresent()) {
if (id != NULL_ID) {
// TODO: Entity pools assignment is not needed as of now, can be enabled later on when necessary.
if (!isExistingEntity(id)) {
logger.error("Entity {} doesn't exist", id);
}
}
// TODO: Entity pools assignment is not needed as of now, can be enabled later on when necessary.

Check warning on line 608 in engine/src/main/java/org/terasology/engine/entitySystem/entity/internal/PojoEntityManager.java

View check run for this annotation

Terasology Jenkins.io / Open Tasks Scanner

TODO

NORMAL: Entity pools assignment is not needed as of now, can be enabled later on when necessary.
if (!pool.isPresent() && id != NULL_ID && !isExistingEntity(id)) {
logger.error("Entity {} doesn't exist", id);
}
return pool;
}
Expand Down Expand Up @@ -707,16 +703,6 @@
}
}

/**
* This method gets called when the entity gets reactivated. e.g. after storage an entity needs to be reactivated.
*/
private void notifyReactivation(EntityRef entity, Collection<Component> components) {
for (EntityChangeSubscriber subscriber : subscribers) {
subscriber.onReactivation(entity, components);
}
}


/**
* This method gets called before an entity gets deactivated (e.g. for storage).
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public <T extends Event> void unregisterEventReceiver(EventReceiver<T> eventRece

@Override
public void send(EntityRef entity, Event event) {
if (Thread.currentThread() != mainThread) {
if (!Thread.currentThread().equals(mainThread)) {
pendingEvents.offer(new PendingEvent(entity, event));
} else {
Set<EventHandlerInfo> selectedHandlersSet = selectEventHandlers(event.getClass(), entity);
Expand Down Expand Up @@ -281,7 +281,7 @@ private void sendConsumableEvent(EntityRef entity, Event event, List<EventHandle

@Override
public void send(EntityRef entity, Event event, Component component) {
if (Thread.currentThread() != mainThread) {
if (!Thread.currentThread().equals(mainThread)) {
pendingEvents.offer(new PendingEvent(entity, event, component));
} else {
SetMultimap<Class<? extends Component>, EventHandlerInfo> handlers =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected void doReload(PrefabData data) {
this.persisted = data.isPersisted();
this.alwaysRelevant = data.isAlwaysRelevant();
this.parent = data.getParent();
if (parent != null && parent instanceof PojoPrefab) {
if (parent instanceof PojoPrefab) {
((PojoPrefab) parent).children.add(this);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ public boolean updateTarget(Vector3f pos, Vector3f dir, float maxDist) {
EntityRef newTarget = hitInfo.getEntity();

if (hitInfo.isWorldHit()) {
if (targetBlockPos != null) {
if (targetBlockPos.equals(hitInfo.getBlockPosition())) {
return false;
}
if (targetBlockPos != null && targetBlockPos.equals(hitInfo.getBlockPosition())) {
return false;
}
targetBlockPos = hitInfo.getBlockPosition();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ private void updateGamepadMappings() {
if (!GLFW.glfwUpdateGamepadMappings(gamecontrolleDB)) {
logger.error("Cannot update GLFW's gamepad mapping, gamepads may not work correctly");
}
inputStream.close();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use try with resources instead of manually closing. This hopefully applies to most of the occurrences of this warning.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

} catch (IOException e) {
logger.error("Cannot read resource '/gamecontrollerdb.txt', gamepads may not work correctly", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ public Vector2i getPosition() {

@Override
public Vector2d getDelta() {
Vector2d result = new Vector2d(xposDelta, yposDelta);
return result;
return new Vector2d(xposDelta, yposDelta);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ public class GuardAction extends ConditionAction {
public boolean prune(Actor actor) {

try {
boolean condition = condition(actor);

return !condition;
return !condition(actor);
} catch (ClassNotFoundException e) {
logger.error("Class not found. Does the Component specified exist?", e);
} catch (NoSuchFieldException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ public void setDelta(float delta) {
* @return The component of the actors minion or null if the minion has no such component.
*/
public <T extends Component> T getComponent(Class<T> type) {
T component = entity.getComponent(type);
return component;
return entity.getComponent(type);
}

public Object getComponentField(ComponentFieldUri uri) {
Expand Down
Loading
Loading