Monarch.java

Index Score
net.sf.freecol.common.model
FreeCol

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
EXITSProcedure exits
COMPARISONSNumber of comparison operators
DECL_COMMENTSComments in declarations
SIZESize of the file in bytes
JAVA0076JAVA0076 Use of magic number
OPERATORSNumber of operators
PROGRAM_LENGTHHalstead program length
JAVA0034JAVA0034 Missing braces in if statement
DOC_COMMENTNumber of javadoc comment lines
OPERANDSNumber of operands
BLOCKSNumber of blocks
PROGRAM_VOCABHalstead program vocabulary
UNIQUE_OPERANDSNumber of unique operands
COMMENTSComment lines
CYCLOMATICCyclomatic complexity
LINESNumber of lines in the source file
LOGICAL_LINESNumber of statements
ELOCEffective lines of code
LOCLines of code
UNIQUE_OPERATORSNumber of unique operators
LOOPSNumber of loops
EXEC_COMMENTSComments in executable code
RETURNSNumber of return points from functions
NEST_DEPTHMaximum nesting depth
JAVA0094JAVA0094 Field hides a superclass field
PROGRAM_VOLUMEHalstead program volume
JAVA0032JAVA0032 Switch statement missing default
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
INTERFACE_COMPLEXITYInterface complexity
JAVA0075JAVA0075 Method parameter hides field
JAVA0145JAVA0145 Tab character used in source file
/** * Copyright (C) 2002-2007 The FreeCol Team * * This file is part of FreeCol. * * FreeCol is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * FreeCol is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with FreeCol. If not, see <http://www.gnu.org/licenses/>. */ package net.sf.freecol.common.model; import java.util.ArrayList; import java.util.EnumMap; import java.util.List; import java.util.logging.Logger; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; import net.sf.freecol.FreeCol; import net.sf.freecol.common.model.Player.PlayerType; import net.sf.freecol.common.model.Player.Stance; import net.sf.freecol.common.model.Unit.Role; import net.sf.freecol.common.util.RandomChoice; import org.w3c.dom.Element; /** * This class implements the player's monarch, whose functions prior * to the revolution include raising taxes, declaring war on other * European countries, and occasionally providing military support. */ public final class Monarch extends FreeColGameObject { /** The name of this monarch. */ private String name; /** The player of this monarch. */ private Player player; private static final Logger logger = Logger.getLogger(Monarch.class.getName()); private static final EquipmentType muskets = FreeCol.getSpecification().getEquipmentType("model.equipment.muskets"); private static final EquipmentType horses = FreeCol.getSpecification().getEquipmentType("model.equipment.horses"); /** Constants describing monarch actions. */ public static enum MonarchAction { NO_ACTION, RAISE_TAX, ADD_TO_REF, DECLARE_WAR, SUPPORT_SEA, SUPPORT_LAND, OFFER_MERCENARIES, LOWER_TAX, NUMBER_OF_ACTIONS, WAIVE_TAX, ADD_UNITS } /** The space required to transport all land units. */ int spaceRequired; /** The current naval transport capacity. */ int capacity; /** The number of land units in the REF. */ private List<AbstractUnit> landUnits = new ArrayList<AbstractUnit>(); /** The number of naval units in the REF. */ private List<AbstractUnit> navalUnits = new ArrayList<AbstractUnit>(); /** The minimum price for mercenaries. */ public static final int MINIMUM_PRICE = 100; /** * The maximum possible tax rate (given in percentage). */ public static final int MAXIMUM_TAX_RATE = 75; /** * The minimum tax rate (given in percentage) from where it * can be lowered */ public static final int MINIMUM_TAX_RATE = 20; /** Whether a frigate has been provided. */ private boolean supportSea = false; /** * Constructor. * * @param game The <code>Game</code> this <code>Monarch</code> * should be created in. * @param player The <code>Player</code> to create the * <code>Monarch</code> for. * @param name The name of the <code>Monarch</code>. */ public Monarch(Game game, Player player, String name) { super(game); if (player == null) { throw new IllegalStateException("player == null"); } this.player = player; this.name = name; // TODO: make this work with DifficultyLevel int number = game.getGameOptions().getInteger(GameOptions.DIFFICULTY) * 2 + 3; for (UnitType unitType : FreeCol.getSpecification().getUnitTypeList()) { if (unitType.hasAbility("model.ability.refUnit")) { if (unitType.hasAbility("model.ability.navalUnit")) { navalUnits.add(new AbstractUnit(unitType, Role.DEFAULT, number)); if (unitType.canCarryUnits()) { capacity += unitType.getSpace() * number; } } else if (unitType.hasAbility("model.ability.canBeEquipped")) { landUnits.add(new AbstractUnit(unitType, Role.SOLDIER, number)); landUnits.add(new AbstractUnit(unitType, Role.DRAGOON, number)); spaceRequired += unitType.getSpaceTaken() * 2 * number; } else { landUnits.add(new AbstractUnit(unitType, Role.DEFAULT, number)); spaceRequired += unitType.getSpaceTaken() * number; } } } } /** * Initiates a new <code>Monarch</code> from an <code>Element</code> * and registers this <code>Monarch</code> at the specified game. * * @param game The <code>Game</code> this object belongs to. * @param in The input stream containing the XML. * @throws XMLStreamException if a problem was encountered * during parsing. */ public Monarch(Game game, XMLStreamReader in) throws XMLStreamException { super(game, in); readFromXML(in); } /** * Initiates a new <code>Monarch</code> from an <code>Element</code> * and registers this <code>Monarch</code> at the specified game. * * @param game The <code>Game</code> this object belongs to. * @param e An XML-element that will be used to initialize * this object. */ public Monarch(Game game, Element e) { super(game, e); readFromXMLElement(e); } /** * Initiates a new <code>Monarch</code> * with the given ID. The object should later be * initialized by calling either * {@link #readFromXML(XMLStreamReader)} or * {@link #readFromXMLElement(Element)}. * * @param game The <code>Game</code> in which this object belong. * @param id The unique identifier for this object. */ public Monarch(Game game, String id) { super(game, id); } /** * Returns a monarch action. Not all actions are always * applicable, and their probability depends on the player's * difficulty settings. This method can only be called by the * server. * * @return A monarch action. */ public MonarchAction getAction() { /** * Random numbers can be generated by this method since it is only * invoked by the endTurn method of the server's InGameController. */ List<RandomChoice<MonarchAction>> choices = getActionChoices(); if (choices == null) { return MonarchAction.NO_ACTION; } else { return RandomChoice.getWeightedRandom(getGame().getModelController().getPseudoRandom(), choices); } } public List<RandomChoice<MonarchAction>> getActionChoices() { // TODO: make this work with DifficultyLevel int dx = getGame().getGameOptions().getInteger(GameOptions.DIFFICULTY) + 1; // 1-5 int turn = getGame().getTurn().getNumber(); int grace = (6 - dx) * 10; // 10-50 // nothing happens during the first few turns, nor after the // revolution if (turn < grace || player.getPlayerType() != PlayerType.COLONIAL) { return null; } boolean canDeclareWar = false; boolean atWar = false; // Benjamin Franklin puts an end to the monarch's interference if (!player.hasAbility("model.ability.ignoreEuropeanWars")) { for (Player enemy : getGame().getPlayers()) { if (!enemy.isEuropean() || enemy.isREF()) { continue; } if (player.hasContacted(enemy)) { switch (player.getStance(enemy)) { case WAR: atWar = true; break; case PEACE: case CEASE_FIRE: canDeclareWar = true; break; } } } } /** The probabilities of these actions. */ List<RandomChoice<MonarchAction>> choices = new ArrayList<RandomChoice<MonarchAction>>(); // the more time has passed, the less likely the monarch will // do nothing choices.add(new RandomChoice<MonarchAction>(MonarchAction.NO_ACTION, Math.max(200 - turn, 100))); if (player.getTax() < MAXIMUM_TAX_RATE) { choices.add(new RandomChoice<MonarchAction>(MonarchAction.RAISE_TAX, 10 + dx)); } choices.add(new RandomChoice<MonarchAction>(MonarchAction.ADD_TO_REF, 10 + dx)); if (canDeclareWar) { choices.add(new RandomChoice<MonarchAction>(MonarchAction.DECLARE_WAR, 5 + dx)); } // provide no more than one frigate if (player.hasBeenAttackedByPrivateers() && !supportSea) { choices.add(new RandomChoice<MonarchAction>(MonarchAction.SUPPORT_SEA, 6 - dx)); } if (atWar) { // disable for the moment //MonarchAction.SUPPORT_LAND = 6 - dx; if (player.getGold() > MINIMUM_PRICE) { choices.add(new RandomChoice<MonarchAction>(MonarchAction.OFFER_MERCENARIES, 6 - dx)); } } if (player.getTax() > MINIMUM_TAX_RATE) { choices.add(new RandomChoice<MonarchAction>(MonarchAction.LOWER_TAX, 10 - dx)); } return choices; } /** * Returns a Set of all REF units. * * @return a Set of all REF units. */ public List<AbstractUnit> getREF() { List<AbstractUnit> result = new ArrayList<AbstractUnit>(landUnits); result.addAll(navalUnits); return result; } /** * Returns the new increased tax. * * @return The increased tax. */ public int getNewTax(MonarchAction taxChange) { int newTax = 110; // set bigger that 100% to catch errors int adjustment = 0; switch(taxChange){ case RAISE_TAX: int turn = getGame().getTurn().getNumber(); adjustment = (6 - player.getDifficulty().getIndex()) * 10; // 20-60 // later in the game, the taxes will increase by more int increase = getGame().getModelController().getPseudoRandom().nextInt(5 + turn/adjustment) + 1; newTax = player.getTax() + increase; newTax = Math.min(newTax, MAXIMUM_TAX_RATE); break; case LOWER_TAX: adjustment = 10 - player.getDifficulty().getIndex(); // 5-10 int decrease = getGame().getModelController().getPseudoRandom().nextInt(adjustment) + 1; newTax = player.getTax() - decrease; newTax = Math.max(newTax, MINIMUM_TAX_RATE); break; default: logger.warning("Wrong tax change type"); return newTax; } return newTax; } /** * Returns units available as mercenaries. * * @return A troop of mercenaries. */ public List<AbstractUnit> getMercenaries() { List<AbstractUnit> mercenaries = new ArrayList<AbstractUnit>(); List<UnitType> unitTypes = new ArrayList<UnitType>(); for (UnitType unitType : FreeCol.getSpecification().getUnitTypeList()) { if (unitType.hasAbility("model.ability.mercenaryUnit")) { unitTypes.add(unitType); } } int gold = player.getGold(); int price = 0; int limit = unitTypes.size(); UnitType unitType = null; for (int count = 0; count < limit; count++) { int index = getGame().getModelController().getPseudoRandom().nextInt(unitTypes.size()); unitType = unitTypes.get(index); if (unitType.hasAbility("model.ability.canBeEquipped")) { int newPrice = getPrice(unitType, Role.DRAGOON); for (int number = 3; number > 0; number--) { if (price + newPrice * number <= gold) { mercenaries.add(new AbstractUnit(unitType, Role.DRAGOON, number)); price += newPrice * number; break; } } newPrice = getPrice(unitType, Role.SOLDIER); for (int number = 3; number > 0; number--) { if (price + newPrice * number <= gold) { mercenaries.add(new AbstractUnit(unitType, Role.SOLDIER, number)); price += newPrice * number; break; } } } else { int newPrice = getPrice(unitType, Role.DEFAULT); for (int number = 3; number > 0; number--) { if (price + newPrice * number <= gold) { mercenaries.add(new AbstractUnit(unitType, Role.DEFAULT, number)); price += newPrice * number; break; } } } unitTypes.remove(index); } if (price == 0 && unitType != null) { if (unitType.hasAbility("model.ability.canBeEquipped")) { mercenaries.add(new AbstractUnit(unitType, Role.SOLDIER, 1)); } else { mercenaries.add(new AbstractUnit(unitType, Role.DEFAULT, 1)); } } return mercenaries; } /** * Returns units to be added to the Royal Expeditionary Force. * * @return An addition to the Royal Expeditionary Force. */ public List<AbstractUnit> addToREF() { ArrayList<AbstractUnit> result = new ArrayList<AbstractUnit>(); if (capacity < spaceRequired) { AbstractUnit unit = navalUnits.get(getGame().getModelController().getPseudoRandom().nextInt(navalUnits.size())); result.add(new AbstractUnit(unit.getUnitType(), unit.getRole(), 1)); } else { int number = getGame().getModelController().getPseudoRandom().nextInt(3) + 1; AbstractUnit unit = landUnits.get(getGame().getModelController().getPseudoRandom().nextInt(landUnits.size())); result.add(new AbstractUnit(unit.getUnitType(), unit.getRole(), number)); } return result; } /** * Adds units to the Royal Expeditionary Force. * * @param units The addition to the Royal Expeditionary Force. */ public void addToREF(List<AbstractUnit> units) { for (AbstractUnit unitToAdd : units) { UnitType unitType = unitToAdd.getUnitType(); if (unitType.hasAbility("model.ability.navalUnit")) { for (AbstractUnit refUnit : navalUnits) { if (refUnit.getUnitType().equals(unitType)) { refUnit.setNumber(refUnit.getNumber() + unitToAdd.getNumber()); if (unitType.canCarryUnits()) { capacity += unitType.getSpace() * unitToAdd.getNumber(); } } } } else { for (AbstractUnit refUnit : landUnits) { if (refUnit.getUnitType().equals(unitType) && refUnit.getRole().equals(unitToAdd.getRole())) { refUnit.setNumber(refUnit.getNumber() + unitToAdd.getNumber()); spaceRequired += unitType.getSpaceTaken() * unitToAdd.getNumber(); } } } } } /** * Returns the price for the given units. * * @param units The units to get a price for. * @param rebate Whether to grant a rebate. * @return The price fo the units. */ public int getPrice(List<AbstractUnit> units, boolean rebate) { int price = 0; for (AbstractUnit unit : units) { int newPrice = getPrice(unit.getUnitType(), unit.getRole()); price += newPrice * unit.getNumber(); } if (price > player.getGold() && rebate) { return player.getGold(); } else { return price; } } public int getPrice(UnitType unitType, Role role) { if (unitType.hasPrice()) { int price = player.getEurope().getUnitPrice(unitType); if (Role.SOLDIER.equals(role)) { price += getEquipmentPrice(muskets); } else if (Role.DRAGOON.equals(role)) { price += getEquipmentPrice(muskets); price += getEquipmentPrice(horses); } return price / 10 + 25 * player.getDifficulty().getIndex(); } else { return 1000000; } } private int getEquipmentPrice(EquipmentType equipment) { int price = 0; for (AbstractGoods goods : equipment.getGoodsRequired()) { price += player.getMarket().getBidPrice(goods.getType(), goods.getAmount()); } return price; } /** * Returns the nation of another player to declare war on. * * @return The enemy nation. */ public Player declareWar() { ArrayList<Player> europeanPlayers = new ArrayList<Player>(); for (Player enemy : getGame().getPlayers()) { if (enemy == player) { continue; } else if (!player.hasContacted(enemy)) { continue; } else if (!enemy.isEuropean() || enemy.isREF()) { continue; } Stance stance = player.getStance(enemy); if (stance == Stance.PEACE || stance == Stance.CEASE_FIRE) { europeanPlayers.add(enemy); } } if (europeanPlayers.size() > 0) { int randomInt = getGame().getModelController().getPseudoRandom().nextInt(europeanPlayers.size()); Player enemy = europeanPlayers.get(randomInt); return enemy; } return null; } /** * Returns an addition to the colonial forces. * * @return An addition to the colonial forces. */ /* public int[] supportLand() { int[] units = new int[NUMBER_OF_TYPES]; switch (player.getDifficulty()) { case Player.VERY_EASY: units[ARTILLERY] = 1; units[DRAGOON] = 2; break; case Player.EASY: units[DRAGOON] = 2; units[INFANTRY] = 1; break; case Player.MEDIUM: units[DRAGOON] = 2; break; case Player.HARD: units[DRAGOON] = 1; units[INFANTRY] = 1; break; case Player.VERY_HARD: units[INFANTRY] = 1; break; } return units; } */ /** * This method writes an XML-representation of this object to * the given stream. * * <br><br> * * Only attributes visible to the given <code>Player</code> will * be added to that representation if <code>showAll</code> is * set to <code>false</code>. * * @param out The target stream. * @param player The <code>Player</code> this XML-representation * should be made for, or <code>null</code> if * <code>showAll == true</code>. * @param showAll Only attributes visible to <code>player</code> * will be added to the representation if <code>showAll</code> * is set to <i>false</i>. * @param toSavedGame If <code>true</code> then information that * is only needed when saving a game is added. * @throws XMLStreamException if there are any problems writing * to the stream. */ protected void toXMLImpl(XMLStreamWriter out, Player player, boolean showAll, boolean toSavedGame) throws XMLStreamException { // Start element: out.writeStartElement(getXMLElementTagName()); out.writeAttribute("ID", getId()); out.writeAttribute("player", this.player.getId()); out.writeAttribute("name", name); out.writeAttribute("supportSea", String.valueOf(supportSea)); out.writeStartElement("navalUnits"); for (AbstractUnit unit : navalUnits) { unit.toXMLImpl(out); } out.writeEndElement(); out.writeStartElement("landUnits"); for (AbstractUnit unit : landUnits) { unit.toXMLImpl(out); } out.writeEndElement(); out.writeEndElement(); } /** * Initialize this object from an XML-representation of this object. * @param in The input stream with the XML. */ protected void readFromXMLImpl(XMLStreamReader in) throws XMLStreamException { setId(in.getAttributeValue(null, "ID")); player = (Player) getGame().getFreeColGameObject(in.getAttributeValue(null, "player")); if (player == null) { player = new Player(getGame(), in.getAttributeValue(null, "player")); } name = in.getAttributeValue(null, "name"); supportSea = Boolean.valueOf(in.getAttributeValue(null, "supportSea")).booleanValue(); while (in.nextTag() != XMLStreamConstants.END_ELEMENT) { String childName = in.getLocalName(); if ("navalUnits".equals(childName)) { while (in.nextTag() != XMLStreamConstants.END_ELEMENT) { AbstractUnit newUnit = new AbstractUnit(in); navalUnits.add(newUnit); } } else if ("landUnits".equals(childName)) { while (in.nextTag() != XMLStreamConstants.END_ELEMENT) { AbstractUnit newUnit = new AbstractUnit(in); landUnits.add(newUnit); } } } // sanity check: we should be on the closing tag if (!in.getLocalName().equals(Monarch.getXMLElementTagName())) { logger.warning("Error parsing xml: expecting closing tag </" + Monarch.getXMLElementTagName() + "> "+ "found instead: " +in.getLocalName()); } } /** * Gets the tag name of the root element representing this object. * This method should be overwritten by any sub-class, preferably * with the name of the class with the first letter in lower case. * * @return "monarch". */ public static String getXMLElementTagName() { return "monarch"; } }

The table below shows all metrics for Monarch.java.

MetricValueDescription
BLOCKS85.00Number of blocks
BLOCK_COMMENT26.00Number of block comment lines
COMMENTS202.00Comment lines
COMMENT_DENSITY 0.72Comment density
COMPARISONS76.00Number of comparison operators
CYCLOMATIC80.00Cyclomatic complexity
DECL_COMMENTS30.00Comments in declarations
DOC_COMMENT163.00Number of javadoc comment lines
ELOC282.00Effective lines of code
EXEC_COMMENTS12.00Comments in executable code
EXITS80.00Procedure exits
FUNCTIONS18.00Number of function declarations
HALSTEAD_DIFFICULTY95.67Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY62.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 0.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 0.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 0.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 0.00JAVA0031 Case statement not properly closed
JAVA0032 1.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA0034 0.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 0.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 1.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 1.00JAVA0075 Method parameter hides field
JAVA007612.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 1.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 1.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 1.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 0.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA0108 1.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 0.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 1.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 1.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 1.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 2.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 0.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 0.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 0.00JAVA0143 Synchronized method
JAVA0144 0.00JAVA0144 Line exceeds maximum M characters
JAVA0145 2.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 0.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 0.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 0.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 0.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 1.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 0.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 0.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 0.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 0.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 0.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES636.00Number of lines in the source file
LINE_COMMENT13.00Number of line comments
LOC357.00Lines of code
LOGICAL_LINES180.00Number of statements
LOOPS 7.00Number of loops
NEST_DEPTH 6.00Maximum nesting depth
OPERANDS984.00Number of operands
OPERATORS1896.00Number of operators
PARAMS21.00Number of formal parameter declarations
PROGRAM_LENGTH2880.00Halstead program length
PROGRAM_VOCAB344.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS41.00Number of return points from functions
SIZE23015.00Size of the file in bytes
UNIQUE_OPERANDS288.00Number of unique operands
UNIQUE_OPERATORS56.00Number of unique operators
WHITESPACE77.00Number of whitespace lines