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 1 commit
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 @@ -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);
}
}
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
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,20 @@ public String getInstigatorName(EntityRef instigator) {
if (instigator.hasComponent(CharacterComponent.class)) {
EntityRef instigatorClient = instigator.getComponent(CharacterComponent.class).controller;
EntityRef instigatorClientInfo = instigatorClient.getComponent(ClientComponent.class).clientInfo;
DisplayNameComponent displayNameComponent = instigatorClientInfo.getComponent(DisplayNameComponent.class);
return displayNameComponent.name;
return instigatorClientInfo.getComponent(DisplayNameComponent.class).name;
Copy link
Member

Choose a reason for hiding this comment

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

Hm, I'm not sure about this one. Technically it is possible, yes, but I don't like that there are so many .s in that one line.

On the other hand, it is in line with the two statements above, where we also do

someObject.getComponent(MyComponent.calss).someField;

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll leave it as is for now.

} else if (instigator.getParentPrefab() != null) {
//A DisplayName can be specified in the entity prefab
//Otherwise, the game will attempt to generate one from the name of that prefab
Prefab parentPrefab = instigator.getParentPrefab();
if (parentPrefab.hasComponent(DisplayNameComponent.class)) {
DisplayNameComponent displayNameComponent = parentPrefab.getComponent(DisplayNameComponent.class);
return displayNameComponent.name;
return parentPrefab.getComponent(DisplayNameComponent.class).name;
} else {
String instigatorName = parentPrefab.getName();
//getParentPrefab.getName() returns a ResourceUrn String such as "engine:player"
//The following calls change the damage type to be more readable
//For instance, "engine:player" becomes "Player"
instigatorName = instigatorName.replaceAll(".*:(.*)", "$1");
instigatorName = Character.toUpperCase(instigatorName.charAt(0)) + instigatorName.substring(1);
return instigatorName;
return Character.toUpperCase(instigatorName.charAt(0)) + instigatorName.substring(1);
}
} else {
return null;
Expand All @@ -155,8 +152,7 @@ public String getDamageTypeName(Prefab damageType) {
//A DisplayName can be specified in the damage type prefab
//Otherwise, the game will attempt to generate one from the name of that prefab
if (damageType.hasComponent(DisplayNameComponent.class)) {
DisplayNameComponent displayNameComponent = damageType.getComponent(DisplayNameComponent.class);
return displayNameComponent.name;
return damageType.getComponent(DisplayNameComponent.class).name;
} else {
logger.info(String.format("%s is missing a readable DisplayName", damageType.getName()));
String damageTypeName = damageType.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ public void ensureGazeContainerEntitiesCreated(OnActivatedComponent event, Entit

private EntityRef createGazeEntity() {
EntityBuilder gazeContainerBuilder = entityManager.newBuilder("engine:gaze");
EntityRef gazeEntity = gazeContainerBuilder.build();
return gazeEntity;
return gazeContainerBuilder.build();
}

@Priority(EventPriority.PRIORITY_LOW)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,7 @@ public List<String> processParameters(String rawCommand) {
String parameterPart = cleanedCommand.substring(commandEndIndex).trim();

//get the parameters
List<String> params = splitParameters(parameterPart);

return params;
return splitParameters(parameterPart);
}

private static List<String> splitParameters(String paramStr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public Long call() throws IOException {
// root privileges under some operating systems
sock.connect(endpoint, timeout);
Instant end = Instant.now();
long millis = Duration.between(start, end).toMillis();
return millis;
return Duration.between(start, end).toMillis();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ public Event copyEvent(Event toBeCopied) {
return newEvent;
} else if (toBeCopied instanceof AttackEvent) {
AttackEvent originalEvent = (AttackEvent) toBeCopied;
AttackEvent newEvent = new AttackEvent(originalEvent.getInstigator(), originalEvent.getDirectCause());
return newEvent;
return new AttackEvent(originalEvent.getInstigator(), originalEvent.getDirectCause());
} else {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ private Animation(Animator animator, float duration, RepeatMode repeatMode, Time
* @return the animation
*/
public static Animation once(Animator animator, float duration, TimeModifier timeModifier) {
Animation anim = new Animation(animator, duration, RepeatMode.RUN_ONCE, timeModifier);
return anim;
return new Animation(animator, duration, RepeatMode.RUN_ONCE, timeModifier);
}

/**
Expand All @@ -75,8 +74,7 @@ public static Animation once(Animator animator, float duration, TimeModifier tim
* @return the animation
*/
public static Animation infinite(Animator animator, float duration, TimeModifier timeModifier) {
Animation anim = new Animation(animator, duration, RepeatMode.REPEAT_INFINITE, timeModifier);
return anim;
return new Animation(animator, duration, RepeatMode.REPEAT_INFINITE, timeModifier);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ public abstract class BaseInteractionScreen extends CoreScreenLayer {

protected EntityRef getInteractionTarget() {
EntityRef characterEntity = localPlayer.getCharacterEntity();
CharacterComponent characterComponent = characterEntity.getComponent(CharacterComponent.class);

return characterComponent.predictedInteractionTarget;
return characterEntity.getComponent(CharacterComponent.class).predictedInteractionTarget;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ public boolean isLowerLayerVisible() {

private void join(final String address, final int port) {
Callable<JoinStatus> operation = () -> {
JoinStatus joinStatus = networkSystem.join(address, port);
return joinStatus;
return networkSystem.join(address, port);
};

final WaitPopup<JoinStatus> popup = getManager().pushScreen(WaitPopup.ASSET_URI, WaitPopup.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ public class UnorderedListDecorator implements ListDecorator {

@Override
public ParagraphData wrapParagraph(ParagraphData paragraphData) {
DefaultParagraphData defaultParagraphData = new DefaultParagraphData(paragraphData.getParagraphRenderStyle(),
return new DefaultParagraphData(paragraphData.getParagraphRenderStyle(),
new UnorderedListParagraphRenderable(paragraphData));
return defaultParagraphData;
}

private int getMaxIndent(Font font) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ public FacetedWorldConfigurator createConfigurator() {
configurables.add((ConfigurableFacetProvider) facetProvider);
}
}
FacetedWorldConfigurator worldConfigurator = new FacetedWorldConfigurator(configurables);
return worldConfigurator;
return new FacetedWorldConfigurator(configurables);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public int blend(int src, int dst) {
int mg = (a * sg + (0xFF - a) * dg) / 0xFF;
int mr = (a * sr + (0xFF - a) * dr) / 0xFF;

int mix = 0xFF000000 | mb | (mg << 8) | (mr << 16);
return mix;
return 0xFF000000 | mb | (mg << 8) | (mr << 16);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public int blend(int src, int dst) {
int mg = (a * sg + (0xFF - a) * dg) / 0xFF;
int mr = (a * sr + (0xFF - a) * dr) / 0xFF;

int mix = (mb << 8) | (mg << 16) | (mr << 24) | 0xFF;
return mix;
return (mb << 8) | (mg << 16) | (mr << 24) | 0xFF;
}
}