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

Fluid cleanup and performance improvements #3581

Merged
merged 10 commits into from Jul 4, 2018

Conversation

Projects
None yet
3 participants
@fscan
Member

fscan commented Jun 30, 2018

Always use our dummy fluid item to represent fluids in slots.
Cache the fluid when possible to reduce nbt operations.

fscan added some commits Jun 30, 2018

@yueh yueh added this to the rv6.alpha - 1.12 milestone Jul 1, 2018

@@ -120,15 +115,10 @@ protected TickRateModulation doBusWork()
{
for( int i = 0; i < this.getConfig().getSlots(); i++ )

This comment has been minimized.

@orod-org

orod-org Jul 1, 2018

CRITICAL Refactor this code to not nest more than 3 if/for/while/switch/try statements. rule

private void drawTooltip( ITooltip tooltip, int mouseX, int mouseY )
{
final int x = tooltip.xPos(); // ((GuiImgButton) c).x;

This comment has been minimized.

@orod-org

orod-org Jul 1, 2018

MAJOR This block of commented-out lines of code should be removed. rule

@@ -101,6 +101,7 @@
private Stopwatch dbl_clickTimer = Stopwatch.createStarted();
private ItemStack dbl_whichItem = ItemStack.EMPTY;

This comment has been minimized.

@orod-org

orod-org Jul 1, 2018

MINOR Rename this field "dbl_whichItem" to match the regular expression '^[a-z][a-zA-Z0-9]*$'. rule

@@ -73,7 +73,6 @@
private final ContainerFluidTerminal container;
private final int offsetX = 9;

This comment has been minimized.

@orod-org

orod-org Jul 1, 2018

MINOR Make this final field static too. rule

private final int srcX;
private final int srcY;
public GuiOptionalFluidSlot( IAEFluidTank fluids, final IOptionalSlotHost containerBus, int slot, int id, int groupNum, int x, int y, int xoffs, int yoffs )

This comment has been minimized.

@orod-org

orod-org Jul 1, 2018

MAJOR Constructor has 9 parameters, which is greater than 7 authorized. rule

this.getProxy().getStorage().postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ), change, this.source );
this.getProxy()
.getStorage()
.postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ), change, this.source );
}
}
catch( final GridAccessException e )

This comment has been minimized.

@orod-org

orod-org Jul 1, 2018

MAJOR Either log or rethrow this exception. rule

@@ -342,23 +328,17 @@ public void postChange( final IBaseMonitor<IAEFluidStack> monitor, final Iterabl
final int slotsToUse = 18 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 9;
for( int x = 0; x < this.config.getSlots() && x < slotsToUse; x++ )
{
final IAEItemStack is = this.config.getAEStackInSlot( x );
final IAEFluidStack is = this.config.getFluidInSlot( x );
if( is != null )

This comment has been minimized.

@orod-org

orod-org Jul 1, 2018

CRITICAL Refactor this code to not nest more than 3 if/for/while/switch/try statements. rule

@FunctionalInterface
public interface IAEFluidInventory
{
void onFluidInventoryChanged( IFluidHandler inventory );
void onFluidInventoryChanged( final IAEFluidTank inv, final int slot );

This comment has been minimized.

@orod-org

orod-org Jul 1, 2018

MINOR Redundant 'final' modifier. rule
MINOR Redundant 'final' modifier. rule

@@ -27,7 +27,12 @@
* @version rv6
* @since rv6
*/
public interface IMEFluidSlot extends IFluidSlot
public interface IMEFluidSlot

This comment has been minimized.

@orod-org

orod-org Jul 1, 2018

CRITICAL Annotate the "IMEFluidSlot" interface with the @FunctionalInterface annotation rule

target.setTag( "#" + x, c );
}
catch( final Exception ignored )

This comment has been minimized.

@orod-org

orod-org Jul 1, 2018

MAJOR Either log or rethrow this exception. rule

target.setTag( "#" + x, c );
}
catch( final Exception ignored )
{

This comment has been minimized.

@orod-org

orod-org Jul 1, 2018

MAJOR Either remove or fill this block of code. rule

{
}
public abstract void drawContent( final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks );

This comment has been minimized.

@orod-org

orod-org Jul 1, 2018

MINOR Redundant 'final' modifier. rule
MINOR Redundant 'final' modifier. rule
MINOR Redundant 'final' modifier. rule
MINOR Redundant 'final' modifier. rule

return id;
}
public boolean canClick( final EntityPlayer player )

This comment has been minimized.

@orod-org

orod-org Jul 1, 2018

MAJOR Remove this unused method parameter "player". rule

import appeng.api.storage.data.IAEFluidStack;
public interface IFluidSyncContainer

This comment has been minimized.

@orod-org

orod-org Jul 1, 2018

CRITICAL Annotate the "IFluidSyncContainer" interface with the @FunctionalInterface annotation rule

public interface IFluidSyncContainer
{
void receiveFluidSlots( final Map<Integer, IAEFluidStack> fluids );

This comment has been minimized.

@orod-org

orod-org Jul 1, 2018

MINOR Redundant 'final' modifier. rule

{
this.gridProxy.getTick().alertDevice( this.gridProxy.getNode() );
if( now )

This comment has been minimized.

@orod-org

orod-org Jul 1, 2018

CRITICAL Refactor this code to not nest more than 3 if/for/while/switch/try statements. rule

}
else
catch( final GridAccessException e )

This comment has been minimized.

@orod-org

orod-org Jul 1, 2018

MAJOR Either log or rethrow this exception. rule

public interface IAEFluidTank extends IFluidHandler
{
void setFluidInSlot( final int slot, final IAEFluidStack fluid );

This comment has been minimized.

@orod-org

orod-org Jul 2, 2018

MINOR Redundant 'final' modifier. rule
MINOR Redundant 'final' modifier. rule

{
void setFluidInSlot( final int slot, final IAEFluidStack fluid );
IAEFluidStack getFluidInSlot( final int slot );

This comment has been minimized.

@orod-org

orod-org Jul 2, 2018

MINOR Redundant 'final' modifier. rule

{
private final int slot;
public FluidTankPropertiesWrapper( final int slot )

This comment has been minimized.

@orod-org

orod-org Jul 2, 2018

MINOR Redundant 'public' modifier. rule

FluidStack drain = this.drain( slot, resource, doDrain );
if( drain != null )
{
if( totalDrained == null )

This comment has been minimized.

@orod-org

orod-org Jul 2, 2018

MINOR Missing curly brace. rule

@Override
public FluidStack drain( final int maxDrain, final boolean doDrain )
{
if( maxDrain == 0 )

This comment has been minimized.

@orod-org

orod-org Jul 2, 2018

MINOR Missing curly brace. rule

@Override
public int fill( final FluidStack fluid, final boolean doFill )
{
if( fluid == null || fluid.amount <= 0 )

This comment has been minimized.

@orod-org

orod-org Jul 2, 2018

MINOR Missing curly brace. rule

{
if( totalDrained == null )
totalDrained = drain;
else

This comment has been minimized.

@orod-org

orod-org Jul 2, 2018

MINOR Missing curly brace. rule

@Override
public FluidStack drain( final FluidStack fluid, final boolean doDrain )
{
if( fluid == null || fluid.amount <= 0 )

This comment has been minimized.

@orod-org

orod-org Jul 2, 2018

MINOR Missing curly brace. rule

totalDrained.amount += drain.amount;
resource.amount -= drain.amount;
if( resource.amount <= 0 )

This comment has been minimized.

@orod-org

orod-org Jul 2, 2018

MINOR Missing curly brace. rule

int fillAmount = this.fill( slot, insert, doFill );
totalFillAmount += fillAmount;
insert.amount -= fillAmount;
if( insert.amount <= 0 )

This comment has been minimized.

@orod-org

orod-org Jul 2, 2018

MINOR Missing curly brace. rule

}
}
if( toDrain <= 0 )

This comment has been minimized.

@orod-org

orod-org Jul 2, 2018

MINOR Missing curly brace. rule

{
private final IAEFluidInventory host;
public AEFluidTank( IAEFluidInventory host, int capacity )
{
super( capacity );
this.host = host;
if (host instanceof TileEntity)

This comment has been minimized.

@orod-org

orod-org Jul 2, 2018

MINOR '(' is not followed by whitespace. rule
MINOR ')' is not preceded with whitespace. rule

@@ -377,7 +335,6 @@ else if( req.getFluid().equals( stored.getFluid() ) ) // same type ( qty differe
private boolean usePlan( final int slot )

This comment has been minimized.

@orod-org

orod-org Jul 2, 2018

CRITICAL The Cyclomatic Complexity of this method "usePlan" is 13 which is greater than 10 authorized. rule

@@ -401,7 +358,7 @@ private boolean usePlan( final int slot )
if( acquired != null )

This comment has been minimized.

@orod-org

orod-org Jul 2, 2018

CRITICAL Refactor this code to not nest more than 3 if/for/while/switch/try statements. rule

}
}
private final Map<Integer, IAEFluidStack> createDiffMap( final boolean full )

This comment has been minimized.

@orod-org

orod-org Jul 2, 2018

MINOR Redundant 'final' modifier. rule

return ret;
}
private final boolean equalsSlot( int slot )

This comment has been minimized.

@orod-org

orod-org Jul 2, 2018

MINOR Redundant 'final' modifier. rule

public class GuiFluidInterface extends AEBaseGui
public class GuiFluidInterface extends GuiUpgradeable
{
public final static int ID_BUTTON_TANK = 222;

This comment has been minimized.

@orod-org

orod-org Jul 3, 2018

MINOR Reorder the modifiers to comply with the Java Language Specification. rule

}
this.priority = new GuiTabButton( this.getGuiLeft() + 154, this.getGuiTop(), 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender );
this.buttonList.add( this.priority );
}
@Override
protected void addButtons()

This comment has been minimized.

@orod-org

orod-org Jul 3, 2018

CRITICAL Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation. rule

}
if( this.iHost instanceof IUpgradeableHost )
{
return (IUpgradeableHost) this.iHost;

This comment has been minimized.

@orod-org

orod-org Jul 3, 2018

MINOR Remove this unnecessary cast to "IUpgradeableHost". rule

}
@Override
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )

This comment has been minimized.

@orod-org

orod-org Jul 3, 2018

CRITICAL Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation. rule

{
if( this.iHost instanceof IUpgradeableHost )
{
return (IUpgradeableHost) this.iHost;

This comment has been minimized.

@orod-org

orod-org Jul 3, 2018

MINOR Remove this unnecessary cast to "IUpgradeableHost". rule

if( !( cs.isPlayerSide() ) && !( cs instanceof SlotFake ) && !( cs instanceof SlotCraftingMatrix ) )
// target slots in the container...
for( final Object inventorySlot : this.inventorySlots )

This comment has been minimized.

@orod-org

orod-org Jul 3, 2018

CRITICAL Refactor this code to not nest more than 3 if/for/while/switch/try statements. rule

}
private void sendTankUpdate( final IContainerListener l, final HashMap<Integer, NBTTagCompound> updateMap )
@Override
protected void loadSettingsFromHost( final IConfigManager cm )

This comment has been minimized.

@orod-org

orod-org Jul 3, 2018

CRITICAL Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation. rule

this.tankSync.readPacket( fluids );
}
protected boolean supportCapacity()

This comment has been minimized.

@orod-org

orod-org Jul 3, 2018

MAJOR Add the "@override" annotation above this method signature rule

}
public void receiveTankInfo( final Map<Integer, NBTTagCompound> tankTags )
public int availableUpgrades()

This comment has been minimized.

@orod-org

orod-org Jul 3, 2018

MAJOR Add the "@override" annotation above this method signature rule

}
super.detectAndSendChanges();
}
@Override
public void addListener( IContainerListener listener )
protected void setupConfig()

This comment has been minimized.

@orod-org

orod-org Jul 3, 2018

CRITICAL Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation. rule

return input;
}
protected boolean isValidForConfig( int slot, IAEFluidStack fs )

This comment has been minimized.

@orod-org

orod-org Jul 3, 2018

MAJOR Remove this unused method parameter "fs". rule

@orod-org

This comment has been minimized.

orod-org commented Jul 3, 2018

SonarQube analysis reported 131 issues

  • BLOCKER 16 blocker
  • CRITICAL 29 critical
  • MAJOR 50 major
  • MINOR 35 minor
  • INFO 1 info

Watch the comments in this conversation to review them.

Top 10 extra issues

Note: The following issues were found on lines that were not modified in the pull request. Because these issues can't be reported as line comments, they are summarized here:

  1. BLOCKER GuiCustomSlot.java#: Add or update the header of this file. rule
  2. BLOCKER SlotFluidME.java#: Add or update the header of this file. rule
  3. BLOCKER GuiFluidStorageBus.java#: Add or update the header of this file. rule
  4. BLOCKER GuiFluidTerminal.java#: Add or update the header of this file. rule
  5. BLOCKER GuiFluidSlot.java#: Add or update the header of this file. rule
  6. BLOCKER GuiOptionalFluidSlot.java#: Add or update the header of this file. rule
  7. BLOCKER ContainerFluidConfigurable.java#: Add or update the header of this file. rule
  8. BLOCKER ContainerFluidStorageBus.java#: Add or update the header of this file. rule
  9. BLOCKER IFluidSyncContainer.java#: Add or update the header of this file. rule
  10. BLOCKER FluidSyncHelper.java#: Add or update the header of this file. rule

@fscan fscan merged commit 5d26b98 into rv6-1.12 Jul 4, 2018

3 of 4 checks passed

sonarqube SonarQube reported 131 issues, with 29 critical and 16 blocker
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
jenkins Success
Details

@fscan fscan deleted the cleanup-fluid-slot branch Jul 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment