Refactored AEConfig #2633

Merged
merged 7 commits into from Nov 26, 2016

Projects

None yet

2 participants

@yueh
Member
yueh commented Nov 17, 2016

Tentative

yueh added some commits Nov 17, 2016
@yueh yueh Refactored AEConfig
Added a singleton getter instead the public field.
Reduced all fields to private.
Replaced field access with getters.
Added setters where necessary (Dimension/Biome Registration)
c9788a7
@yueh yueh Added more config options to disable more features.
36b4e84
@@ -72,12 +72,12 @@ public void generate( final Random r, final int chunkX, final int chunkZ, final
return;
}
- final double oreDepthMultiplier = AEConfig.instance.quartzOresClusterAmount * seaLevel / 64;
+ final double oreDepthMultiplier = AEConfig.instance().getQuartzOresClusterAmount() * seaLevel / 64;
@orod-org
orod-org Nov 17, 2016

MINOR Cast one of the operands of this division operation to a "double". rule

@@ -62,7 +62,7 @@ public GridConnection( final IGridNode aNode, final IGridNode bNode, final AEPar
if( Platform.securityCheck( a, b ) )
@orod-org
orod-org Nov 17, 2016

MAJOR Nullcheck of aNode at line 77 of value previously dereferenced in new appeng.me.GridConnection(IGridNode, IGridNode, AEPartLocation) rule
MAJOR Nullcheck of bNode at line 77 of value previously dereferenced in new appeng.me.GridConnection(IGridNode, IGridNode, AEPartLocation) rule

@@ -186,7 +186,7 @@ public static String formatPowerLong( final long n, final boolean isRate )
{
double p = ( (double) n ) / 100;
- final PowerUnits displayUnits = AEConfig.instance.selectedPowerUnit();
+ final PowerUnits displayUnits = AEConfig.instance().selectedPowerUnit();
p = PowerUnits.AE.convertTo( displayUnits, p );
final String[] preFixes = { "k", "M", "G", "T", "P", "T", "P", "E", "Z", "Y" };
@orod-org
orod-org Nov 17, 2016

MAJOR Method appeng.util.Platform.formatPowerLong(long, boolean) creates array using constants rule

@yueh yueh Removed redundant getter
7320ea7
@@ -183,11 +183,11 @@ protected void actionPerformed( final GuiButton btn )
if( btn == this.terminalStyleBox )
{
- AEConfig.instance.settings.putSetting( iBtn.getSetting(), next );
+ AEConfig.instance().getConfigManager().putSetting( iBtn.getSetting(), next );
@orod-org
orod-org Nov 17, 2016

MAJOR Method appeng.client.gui.implementations.GuiMEMonitorable.actionPerformed(GuiButton) appears to call the same method on the same object redundantly rule

yueh added some commits Nov 17, 2016
@yueh yueh Fixed formatting
efd8ae5
@yueh yueh Splitted Enum name from the config key
439eb8a
@@ -89,24 +89,24 @@ private void registerDescriptions( IDefinitions definitions, IModRegistry regist
}
addDescription( registry, materials.certusQuartzCrystalCharged(), message );
- if( AEConfig.instance.isFeatureEnabled( AEFeature.MeteoriteWorldGen ) )
+ if( AEConfig.instance().isFeatureEnabled( AEFeature.METEORITE_WORLD_GEN ) )
{
addDescription( registry, materials.logicProcessorPress(), GuiText.inWorldCraftingPresses.getLocal() );
addDescription( registry, materials.calcProcessorPress(), GuiText.inWorldCraftingPresses.getLocal() );
@orod-org
orod-org Nov 17, 2016

MAJOR Method appeng.integration.modules.jei.JEIPlugin.registerDescriptions(IDefinitions, IModRegistry) appears to call the same method on the same object redundantly rule

@yueh yueh Changed FacadeConfig and Networkhandler similar to AEConfig.init()
c262b11
@@ -183,7 +183,7 @@ public ItemStack createFacadeForItem( final ItemStack l, final boolean returnIte
}
final boolean defaultValue = ( b.isFullyOpaque( blockState ) && hasSimpleModel( blockState ) && !b.getTickRandomly() && !hasTile && !disableOre ) || enableGlass;
@orod-org
orod-org Nov 17, 2016

MAJOR Method appeng.items.parts.ItemFacade.createFacadeForItem(ItemStack, boolean) orders expressions in a conditional in a sub optimal way rule

@@ -71,9 +71,9 @@ public FMLProxyPacket getProxy()
throw new IllegalArgumentException( "Sorry AE2 made a " + this.p.array().length + " byte packet by accident!" );
@orod-org
orod-org Nov 17, 2016

MAJOR Method appeng.core.sync.AppEngPacket.getProxy() appears to call the same method on the same object redundantly rule

@yueh yueh Fixup
3dbba31
@orod-org

SonarQube analysis reported 114 issues

  • MAJOR 74 major
  • MINOR 29 minor
  • INFO 11 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. MAJOR BlockQuartzFixture.java#L65: Method new appeng.block.misc.BlockQuartzFixture() needlessly boxes a boolean constant rule
  2. MAJOR BlockQuartzGrowthAccelerator.java#L56: Method new appeng.block.misc.BlockQuartzGrowthAccelerator() needlessly boxes a boolean constant rule
  3. MAJOR BlockQuartzGrowthAccelerator.java#L139: Null passed for non-null parameter of net.minecraft.world.World.getBlockState(BlockPos) in appeng.block.misc.BlockQuartzGrowthAccelerator.randomDisplayTick(IBlockState, World, BlockPos, Random) rule
  4. MAJOR BlockVibrationChamber.java#L58: Method new appeng.block.misc.BlockVibrationChamber() needlessly boxes a boolean constant rule
  5. MAJOR ClientHelper.java#L85: Method appeng.client.ClientHelper.preinit() orders expressions in a conditional in a sub optimal way rule
  6. MAJOR AEBaseGui.java#L525: Method appeng.client.gui.AEBaseGui.handleMouseClick(Slot, int, int, ClickType) orders expressions in a conditional in a sub optimal way rule
  7. MAJOR AEBaseGui.java#L749: Remove this silly call to "Math.floor" rule
  8. MAJOR GuiCellWorkbench.java#L88: Method appeng.client.gui.implementations.GuiCellWorkbench.drawBG(int, int, int, int) appears to call the same method on the same object redundantly rule
  9. MAJOR GuiCellWorkbench.java#L96: Method appeng.client.gui.implementations.GuiCellWorkbench.drawBG(int, int, int, int) appears to call the same method on the same object redundantly rule
  10. MAJOR GuiCellWorkbench.java#L145: Method appeng.client.gui.implementations.GuiCellWorkbench.handleButtonVisibility() appears to call the same method on the same object redundantly rule
@yueh yueh merged commit a665200 into master Nov 26, 2016

4 checks passed

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
sonarqube SonarQube reported 114 issues, no criticals or blockers
@yueh yueh deleted the refactor-config branch Nov 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment