From: <chr...@us...> - 2006-12-10 14:13:43
|
Revision: 1009 http://svn.sourceforge.net/gridarta/?rev=1009&view=rev Author: christianhujer Date: 2006-12-10 06:13:43 -0800 (Sun, 10 Dec 2006) Log Message: ----------- Hardened error policy. Strengthened constructor visibility. Removed redundant final declarations. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CPickmapPanel.java trunk/crossfire/src/cfeditor/gui/CloseableTabbedPane.java trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java trunk/crossfire/src/cfeditor/menu/AggregateMenuLocation.java trunk/crossfire/src/cfeditor/parameter/DoubleParameterView.java trunk/crossfire/src/cfeditor/parameter/IntegerParameterView.java trunk/daimonin/src/daieditor/CPickmapPanel.java trunk/daimonin/src/daieditor/gameobject/face/FaceFacade.java trunk/gridarta.ipr trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java trunk/src/app/net/sf/gridarta/gameobject/RecursiveGameObjectIterator.java trunk/src/doc/dev/codeStyle.xhtml Modified: trunk/crossfire/src/cfeditor/CPickmapPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CPickmapPanel.java 2006-12-10 13:54:10 UTC (rev 1008) +++ trunk/crossfire/src/cfeditor/CPickmapPanel.java 2006-12-10 14:13:43 UTC (rev 1009) @@ -326,7 +326,7 @@ private final String activePickmap; // file-name of active pickmap - public PickmapSelectionListener(final JTabbedPane pane) { + private PickmapSelectionListener(final JTabbedPane pane) { tabpane = pane; activePickmap = null; } @@ -359,7 +359,7 @@ * @param mainView the main view * @param pane the JTabbedPane containing both archlist and pickmaps */ - public ArchNPickChangeListener(final CMainView mainView, final JTabbedPane pane) { + private ArchNPickChangeListener(final CMainView mainView, final JTabbedPane pane) { this.mainView = mainView; tabpane = pane; selectedIndex = tabpane.getSelectedIndex(); Modified: trunk/crossfire/src/cfeditor/gui/CloseableTabbedPane.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/CloseableTabbedPane.java 2006-12-10 13:54:10 UTC (rev 1008) +++ trunk/crossfire/src/cfeditor/gui/CloseableTabbedPane.java 2006-12-10 14:13:43 UTC (rev 1009) @@ -140,7 +140,7 @@ //--- Constructor(s) --- - public ClosingIcon(final ImageIcon icon) { + protected ClosingIcon(final ImageIcon icon) { this.icon = icon; if (icon != null) { Modified: trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java 2006-12-10 13:54:10 UTC (rev 1008) +++ trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java 2006-12-10 14:13:43 UTC (rev 1009) @@ -32,7 +32,6 @@ import static java.util.Arrays.binarySearch; import static java.util.Arrays.sort; import java.util.Locale; -import java.util.prefs.Preferences; import javax.swing.Box; import static javax.swing.Box.createHorizontalBox; import static javax.swing.Box.createVerticalBox; @@ -74,6 +73,7 @@ /** * Create a GUIPrefs pane. + * @param mainControl MainControl (used for accessing settings). */ public GUIPrefs(final CMainControl mainControl) { this.mainControl = mainControl; Modified: trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java 2006-12-10 13:54:10 UTC (rev 1008) +++ trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java 2006-12-10 14:13:43 UTC (rev 1009) @@ -31,7 +31,6 @@ import java.awt.Container; import java.awt.FlowLayout; import static java.util.Arrays.sort; -import java.util.prefs.Preferences; import javax.swing.Box; import static javax.swing.Box.createHorizontalBox; import static javax.swing.Box.createVerticalBox; @@ -152,7 +151,6 @@ /** * Toggle action method for loading arches from collection. * @param loadArchColl whether to load arches from collection - * @used */ public void setOptionsLoadArchColl(final boolean loadArchColl) { archField.setEnabled(!loadArchColl); @@ -161,7 +159,6 @@ /** * Toggle action method for loading arches from collection. * @return whether arches are loaded from collection - * @used */ public boolean isOptionsLoadArchColl() { return !archField.isEnabled(); Modified: trunk/crossfire/src/cfeditor/menu/AggregateMenuLocation.java =================================================================== --- trunk/crossfire/src/cfeditor/menu/AggregateMenuLocation.java 2006-12-10 13:54:10 UTC (rev 1008) +++ trunk/crossfire/src/cfeditor/menu/AggregateMenuLocation.java 2006-12-10 14:13:43 UTC (rev 1009) @@ -21,7 +21,7 @@ private final MenuLocation location; - public WrappedMenuLocation(final MenuLocation location, final String parentName) { + private WrappedMenuLocation(final MenuLocation location, final String parentName) { this.location = location; name = parentName + "." + location.getName(); } Modified: trunk/crossfire/src/cfeditor/parameter/DoubleParameterView.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/DoubleParameterView.java 2006-12-10 13:54:10 UTC (rev 1008) +++ trunk/crossfire/src/cfeditor/parameter/DoubleParameterView.java 2006-12-10 14:13:43 UTC (rev 1009) @@ -35,11 +35,11 @@ private static final long serialVersionUID = 1L; - public TooltipSpinner() { + private TooltipSpinner() { super(); } - public TooltipSpinner(final SpinnerModel model) { + private TooltipSpinner(final SpinnerModel model) { super(model); } Modified: trunk/crossfire/src/cfeditor/parameter/IntegerParameterView.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/IntegerParameterView.java 2006-12-10 13:54:10 UTC (rev 1008) +++ trunk/crossfire/src/cfeditor/parameter/IntegerParameterView.java 2006-12-10 14:13:43 UTC (rev 1009) @@ -35,11 +35,11 @@ private static final long serialVersionUID = -797350272052837471L; - public TooltipSpinner() { + private TooltipSpinner() { super(); } - public TooltipSpinner(final SpinnerModel model) { + private TooltipSpinner(final SpinnerModel model) { super(model); } Modified: trunk/daimonin/src/daieditor/CPickmapPanel.java =================================================================== --- trunk/daimonin/src/daieditor/CPickmapPanel.java 2006-12-10 13:54:10 UTC (rev 1008) +++ trunk/daimonin/src/daieditor/CPickmapPanel.java 2006-12-10 14:13:43 UTC (rev 1009) @@ -359,7 +359,7 @@ private final String activePickmap; // file-name of active pickmap - public PickmapSelectionListener(final JTabbedPane pane) { + private PickmapSelectionListener(final JTabbedPane pane) { tabpane = pane; activePickmap = null; } @@ -394,7 +394,7 @@ * @param mainView the main view * @param pane the JTabbedPane containing both archlist and pickmaps */ - public ArchNPickChangeListener(final CMainView mainView, final JTabbedPane pane) { + private ArchNPickChangeListener(final CMainView mainView, final JTabbedPane pane) { this.mainView = mainView; tabpane = pane; selectedIndex = tabpane.getSelectedIndex(); Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceFacade.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceFacade.java 2006-12-10 13:54:10 UTC (rev 1008) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceFacade.java 2006-12-10 14:13:43 UTC (rev 1009) @@ -54,7 +54,7 @@ * Converts a pixel by increasing the transparency. * {@inheritDoc} */ - @Override public final int filterRGB(final int x, final int y, final int rgb) { + @Override public int filterRGB(final int x, final int y, final int rgb) { // This is sufficient since alpha channel isn't used in the graphics this is required for. return rgb >>> 24 == 0 ? rgb : rgb & 0x00FFFFFF | 0x80000000; } @@ -68,7 +68,7 @@ * Converts every second pixel by making it transparent. * {@inheritDoc} */ - @Override public final int filterRGB(final int x, final int y, final int rgb) { + @Override public int filterRGB(final int x, final int y, final int rgb) { return (x + y) % 2 == 1 ? rgb : rgb & 0x00FFFFFF; } Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2006-12-10 13:54:10 UTC (rev 1008) +++ trunk/gridarta.ipr 2006-12-10 14:13:43 UTC (rev 1009) @@ -567,7 +567,6 @@ </inspection_tool> <inspection_tool class="CheckJsfComponentUnderViewTag" level="INFO" enabled="false" /> <inspection_tool class="UnnecessarySemicolon" level="WARNING" enabled="false" /> - <inspection_tool class="ShiftOutOfRange" level="WARNING" enabled="false" /> <inspection_tool class="DefaultFileTemplate" level="WARNING" enabled="false"> <option name="CHECK_FILE_HEADER" value="true" /> <option name="CHECK_TRY_CATCH_SECTION" value="true" /> @@ -609,8 +608,6 @@ </inspection_tool> <inspection_tool class="UnnecessaryUnboxing" level="WARNING" enabled="false" /> <inspection_tool class="SameParameterValue" level="WARNING" enabled="false" /> - <inspection_tool class="NoExplicitFinalizeCalls" level="WARNING" enabled="false" /> - <inspection_tool class="FinalPrivateMethod" level="WARNING" enabled="false" /> <inspection_tool class="AnalyzingRedundantFieldInitialization" level="WARNING" enabled="false" /> <inspection_tool class="ReservedWordUsedAsNameJS" level="WARNING" enabled="false" /> <inspection_tool class="ExtendsAnnotation" level="WARNING" enabled="false" /> @@ -673,7 +670,6 @@ <option name="m_includeComments" value="true" /> <option name="m_ignoreTestCases" value="true" /> </inspection_tool> - <inspection_tool class="Dependency" level="ERROR" enabled="false" /> <inspection_tool class="UnnecessaryLocalVariable" level="WARNING" enabled="false"> <option name="m_ignoreImmediatelyReturnedVariables" value="false" /> <option name="m_ignoreAnnotatedVariables" value="false" /> @@ -694,13 +690,9 @@ <group names="x,width,left,right" /> <group names="y,height,top,bottom" /> </inspection_tool> - <inspection_tool class="FinalizeCallsSuperFinalize" level="WARNING" enabled="false"> - <option name="m_ignoreForObjectSubclasses" value="false" /> - </inspection_tool> <inspection_tool class="MalformedRegex" level="WARNING" enabled="false" /> <inspection_tool class="TrivialIfJS" level="WARNING" enabled="false" /> <inspection_tool class="SimplifiableConditionalExpression" level="WARNING" enabled="false" /> - <inspection_tool class="IncompatibleMask" level="WARNING" enabled="false" /> <inspection_tool class="UNUSED_IMPORT" level="WARNING" enabled="false" /> <inspection_tool class="DuplicateCaseLabelJS" level="WARNING" enabled="false" /> <inspection_tool class="PersistenceModelWarningInspection" level="WARNING" enabled="false" /> @@ -752,9 +744,6 @@ <inspection_tool class="BadExpressionStatementJS" level="WARNING" enabled="false" /> <inspection_tool class="PrimitiveArrayArgumentToVariableArgMethod" level="WARNING" enabled="false" /> <inspection_tool class="InfiniteRecursionJS" level="WARNING" enabled="false" /> - <inspection_tool class="PointlessBitwiseExpression" level="WARNING" enabled="false"> - <option name="m_ignoreExpressionsContainingConstants" value="false" /> - </inspection_tool> <inspection_tool class="StrutsValidatorInspection" level="ERROR" enabled="false" /> <inspection_tool class="ContinueOrBreakFromFinallyBlock" level="WARNING" enabled="false" /> <inspection_tool class="DuplicatePropertyOnObjectJS" level="WARNING" enabled="false" /> @@ -799,8 +788,34 @@ <option name="IGNORE_JAVADOC_PERIOD" value="false" /> <option name="myAdditionalJavadocTags" value="todo,note,todo,xxx,note,todo,fixme,fixme,warning,invariant,retval,pre" /> </inspection_tool> - <inspection_tool class="MissingOverrideAnnotation" level="WARNING" enabled="true" /> + <inspection_tool class="MissingOverrideAnnotation" level="ERROR" enabled="true" /> <inspection_tool class="AbstractMethodWithMissingImplementations" level="WARNING" enabled="true" /> + <inspection_tool class="EqualsAndHashcode" level="ERROR" enabled="true" /> + <inspection_tool class="Dependency" level="ERROR" enabled="false" /> + <inspection_tool class="FinalizeNotProtected" level="ERROR" enabled="true" /> + <inspection_tool class="NoExplicitFinalizeCalls" level="ERROR" enabled="true" /> + <inspection_tool class="FinalizeCallsSuperFinalize" level="ERROR" enabled="true"> + <option name="m_ignoreForObjectSubclasses" value="false" /> + </inspection_tool> + <inspection_tool class="OnDemandImport" level="ERROR" enabled="true" /> + <inspection_tool class="JavaLangImport" level="ERROR" enabled="true" /> + <inspection_tool class="SamePackageImport" level="ERROR" enabled="true" /> + <inspection_tool class="RedundantImport" level="ERROR" enabled="true" /> + <inspection_tool class="InstanceofThis" level="ERROR" enabled="true" /> + <inspection_tool class="ReplaceAssignmentWithOperatorAssignment" level="ERROR" enabled="true"> + <option name="ignoreLazyOperators" value="true" /> + <option name="ignoreObscureOperators" value="false" /> + </inspection_tool> + <inspection_tool class="AssignmentToCatchBlockParameter" level="ERROR" enabled="true" /> + <inspection_tool class="ShiftOutOfRange" level="ERROR" enabled="true" /> + <inspection_tool class="PointlessBitwiseExpression" level="ERROR" enabled="true"> + <option name="m_ignoreExpressionsContainingConstants" value="false" /> + </inspection_tool> + <inspection_tool class="IncompatibleMask" level="ERROR" enabled="true" /> + <inspection_tool class="FinalMethodInFinalClass" level="ERROR" enabled="true" /> + <inspection_tool class="FinalPrivateMethod" level="ERROR" enabled="true" /> + <inspection_tool class="ProtectedMemberInFinalClass" level="ERROR" enabled="true" /> + <inspection_tool class="PublicConstructorInNonPublicClass" level="ERROR" enabled="true" /> </profile> <profile version="1.0" is_locked="false"> <option name="myName" value="Project Default" /> Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java 2006-12-10 13:54:10 UTC (rev 1008) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java 2006-12-10 14:13:43 UTC (rev 1009) @@ -409,7 +409,7 @@ * Create a reverse iterator. * @param list to iterate over in reverse order */ - public ReverseIterator(final List<T> list) { + private ReverseIterator(final List<T> list) { delegate = list.listIterator(list.size()); } Modified: trunk/src/app/net/sf/gridarta/gameobject/RecursiveGameObjectIterator.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/RecursiveGameObjectIterator.java 2006-12-10 13:54:10 UTC (rev 1008) +++ trunk/src/app/net/sf/gridarta/gameobject/RecursiveGameObjectIterator.java 2006-12-10 14:13:43 UTC (rev 1009) @@ -20,7 +20,7 @@ * Create a recursive GameObject Iterator. * @param container GameObjectContainer to start with */ - public RecursiveGameObjectIterator(final GameObjectContainer container) { + RecursiveGameObjectIterator(final GameObjectContainer container) { current = container.iterator(); } Modified: trunk/src/doc/dev/codeStyle.xhtml =================================================================== --- trunk/src/doc/dev/codeStyle.xhtml 2006-12-10 13:54:10 UTC (rev 1008) +++ trunk/src/doc/dev/codeStyle.xhtml 2006-12-10 14:13:43 UTC (rev 1009) @@ -77,8 +77,58 @@ Inspections <ul> <li> + Abstraction issues + <dl> + <dt>'instanceof' check for 'this'</dt> + <dd> + This most likely is a failure to understand object oriented programming. + Such constructs must be replaced by proper polymorphism. + </dd> + </dl> + </li> + <li> + Assignment issues + <dl> + <dt>Assignment replaceable with operator assignment</dt> + <dd> + Operator assignments should be used wherever applicable because they are easier to read: It's faster to see and understand that the new variable value is based on a modification of the original value, not a completely new value. + <br /> + Conditional operators are currently ignored because <code>foo |= bar();</code> is not the same as <code>foo = foo || bar();</code> because the behaviour regarding side-effects in <code>bar()</code> is changed. + </dd> + <dt>Assignment to catch block parameter</dt> + <dd> + This reports things like <code>catch (FooException e) { e = ...; }</code> as they are either errors or, if not, at least very confusing. + </dd> + </dl> + </li> + <li> + Bitwise operation issues + <dl> + <dt>Incompatible bitwise mask operation</dt> + <dd> + Bitwise mask expressions which are guaranteed to always evaluate to true or false most likely are logical errors. + Example: <code>(var & constant1) == constant2</code>. + </dd> + <dt>Pointless bitwise expression</dt> + <dd> + Pointless expressions that and with zero, or with zero or shift with zero most likely are logical errors. + </dd> + <dt>Shift operation by inappropriate constant</dt> + <dd> + Shifts with shift values out of range (0..31 for int, 0..63 for long) most likely are logical errors. + </dd> + </dl> + </li> + <li> Class structure <dl> + <dt>'final' method in 'final' class</dt> + <dd> + This is unneccessary and may be confusing. + Methods in final classes are always implicitely final. + A method should only be explicitely declared final if the context is "the class might be subclasses, but this method is not designed to be overridden". + Thus if a method in a final class is explicitely declared final, it may lead to the conclusion that the class was declared final by mistake. + </dd> <dt>Missing @Deprecated annotation</dt> <dd> Makes sure that deprecated members that are documented as deprecated in Javadoc (<code>@deprecated</code> javadoc tag) are also annotated as <code>@Deprecated</code> in the source code. @@ -99,9 +149,36 @@ That is useful for finding typos when wanting to override a method. E.g. if you override <code>toString()</code> using <code>@Override public String tostring()</code> (not the typo), the compiler will be able to report this as an error. </dd> + <dt>'private' method declared 'final'</dt> + <dd> + Private methods are implicitely final. + Explicitely declaring them final looks like the method should be public or protected instead. + </dd> + <dt>'protected' member in 'final' class</dt> + <dd> + Final classes cannot be subclassed. + Protected members are explicitely visible for subclasses. + Because of that, protected members in final classes are an oxymoron that indicates an error. + </dd> + <dt>'public' constructor in non-public class</dt> + <dd> + If the class is not visible, the constructor isn't either. + Declaring the constructor of higher accessibility than its class is pointless and most likely an error. + </dd> </dl> </li> <li> + Finalization issues + <dl> + <dt>'finalize()' called explicitely</dt> + <dd>finalize() must only be called by the garbage collector, but not application software.</dd> + <dt>'finalize()' does not call 'super.finalize()'</dt> + <dd>This always is an error as this prevents the superclass from performing its own finalization code.</dd> + <dt>'finalize()' not declared 'protected'</dt> + <dd>This is an error because 'finalize()' must not be public because it never needs to be called directly.</dd> + </dl> + </li> + <li> General <dl> <dt>Declaration has javadoc problems</dt> @@ -118,9 +195,29 @@ <dd> Makes sure that references in javadoc comments (<code>{@link ...}</code> and eventually <code>@see ...</code>) can be resolved. </dd> + <dt>equals() and hashCode() not paired</dt> + <dd> + Due to their contract, equals() and hashCode() must always be paired. + If one of them is overridden, so must be the other. + </dd> </dl> </li> <li> + Imports + <dl> + <dt>* import</dt> + <dd> + * imports are forbidden in Gridarta. + </dd> + <dt>Import from same package</dt> + <dt>java.lang import</dt> + <dt>Redundant import</dt> + <dd> + Redundant or pointless imports are forbidden in Gridarta. + </dd> + </dl> + </li> + <li> Inheritance issues <dl> <dt>Abstract method with missing implementations</dt> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |