DXAttribute.java

Index Score
com.ca.commons.naming
JXplorer

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
JAVA0034JAVA0034 Missing braces in if statement
CYCLOMATICCyclomatic complexity
DECL_COMMENTSComments in declarations
SIZESize of the file in bytes
COMPARISONSNumber of comparison operators
RETURNSNumber of return points from functions
JAVA0081JAVA0081 Boolean literal in comparison
LINESNumber of lines in the source file
LOCLines of code
BLOCKSNumber of blocks
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
DOC_COMMENTNumber of javadoc comment lines
JAVA0144JAVA0144 Line exceeds maximum M characters
EXITSProcedure exits
LINE_COMMENTNumber of line comments
INTERFACE_COMPLEXITYInterface complexity
ELOCEffective lines of code
OPERATORSNumber of operators
FUNCTIONSNumber of function declarations
EXEC_COMMENTSComments in executable code
COMMENTSComment lines
LOOPSNumber of loops
PROGRAM_LENGTHHalstead program length
LOGICAL_LINESNumber of statements
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0071JAVA0071 Strings compared with ==
PROGRAM_VOCABHalstead program vocabulary
UNIQUE_OPERANDSNumber of unique operands
OPERANDSNumber of operands
JAVA0035JAVA0035 Missing braces in for statement
JAVA0076JAVA0076 Use of magic number
UNIQUE_OPERATORSNumber of unique operators
WHITESPACENumber of whitespace lines
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0179JAVA0179 Local variable hides visible field
JAVA0117JAVA0117 Missing javadoc: method 'method'
JAVA0100JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0075JAVA0075 Method parameter hides field
JAVA0068JAVA0068 Modifiers not declared in recommended order
NEST_DEPTHMaximum nesting depth
JAVA0145JAVA0145 Tab character used in source file
package com.ca.commons.naming; import javax.naming.*; import javax.naming.directory.*; import java.util.*; import java.util.logging.Logger; import java.util.logging.Level; import java.text.CollationKey; import java.text.Collator; import com.ca.commons.cbutil.*; import com.ca.commons.jndi.SchemaOps; /** * <p>This is a schema-aware wrapper to BasicAttribute<p> * * <p>It goes to a lot of effort to figure out whether the attribute has * string values, or contains 'byte array' values. If it contains byte array values, * it also tries to figure out whether they are ASN1 values. This is important, as we * need to make sure that byte array values are passed correctly to JNDI, and in addition * we need to make sure that ASN1 values are passed using ';binary'.</p> */ //There was Confusion here between non-string syntaxes, and 'Binary' syntaxes which in ldap means ASN.1. encoded. //We have modified the class to use 'non string' (for byte arrays) and 'ASN1' (for ASN1 structures). All ASN1 //structures are 'non string', but attributes like jpeg photos and so on are byte arrays, but not ASN1 structures... public class DXAttribute extends BasicAttribute implements Comparable { //protected boolean isNonString = false; // whether this attribute is isNonString data (e.g. ASN1 or a jpeg, an audio file etc.) protected boolean isString = true; // whether this attribute is an ordinary string, or something else (e.g. ASN1 or a jpeg, an audio file etc.). Default is true (most attributes are strings). protected boolean isASN1 = false; static boolean appendBinaryOption = false; // whether to add ';binary' to the end of non String attribute names. String name; // the name of the attribute (usually identical to the ID, unless ';binary' has been added to the ID) String syntaxOID; // the OID of the Syntax (i.e. "1.3.6.1.4.1.1466.115.121.1.5" for binary) String syntaxDesc; // the same thing as a human readable description String description; // the free form description of the attribute that may exist in schema private static final String STRING = "string"; private static final String BYTE_ARRAY = "bytes"; private static final String ASN1 = "asn1"; static Hashtable knownAttributeTypes; // a list of known 'attributes, matched against the constants above static SchemaOps schema; // the schema of the most recently connected to directory private CollationKey collationKey; // used for language-sensitive sorting. private static Collator myCollator = Collator.getInstance(); // used for language-sensitive sorting. private final static Logger log = Logger.getLogger(DXAttribute.class.getName()); // ...It's round it's heavy it's wood... It's better than bad, it's good... static { knownAttributeTypes = new Hashtable(100); } /** * Normal constructor for an Attribute with no (current) value. * @param ID the name of the attribute (e.g. "userCertificate") */ public DXAttribute(String ID) { super(ID); init(); } /** * Normal constructor an Attribute with a single value. * @param ID the name of the attribute (e.g. "commonName") * @param value the value of the attribute (String or byte array). e.g. "Fred" */ public DXAttribute(String ID, Object value) { super(ID, value); init(); } /** * Make a copy of a normal, pre-existing attribute. * @param att the attribute (e.g. BasicAttribute) to wrap. */ public DXAttribute(Attribute att) { super(att.getID()); try { addValues(att.getAll()); } catch (NamingException e) { log.log(Level.WARNING, "error reading attribute values for attribute " + getID() + "\n", e); } setName(att.getID()); // ?? necessary?? init(); } /** * Creates an attribute with an enumeration of existing values. * @param ID the name of the attribute (e.g. "favoriteDrink") * @param values a set of values (e.g. "midori"... "cointreau"... "lemon juice"... "japanese slipper" */ public DXAttribute(String ID, NamingEnumeration values) { super(ID); addValues(values); init(); } /** * Adds a series of values to the attribute. * @param values a bunch of new values to append to the attribute */ public void addValues(NamingEnumeration values) { try { while (values.hasMore()) { add(values.next()); } } catch (NamingException e) { log.log(Level.WARNING, "error adding values for attribute " + getID(), e); } } /** * Attempts to sort the values of the attribute alphabetically. This is a * relatively expensive operation, and should be used sparingly. (e.g. at GUI * display time) */ public void sort() { if (values.size()<2) return; // nothing to do. try { // $%^# don't know how to write this to keep both java 1.4 & 1.5 happy - compiles under both, but 1.5 IDEs may flag this... Collections.sort((List)values); } catch (ClassCastException e) { // nope, can't do that... } catch (UnsupportedOperationException e) { // nope, can't do that either... } } /** * This sets the standard schema to use while this connection is open. * (It may be possible in future releases to set schema on a per-Attribute * basis - it is not clear yet whether this would be useful.) */ public static void setDefaultSchema(SchemaOps defaultSchema) { schema = defaultSchema; } /** * <p>Code common to all constructors, run at the *end* of each constructor.</p> */ protected void init() { // figure out whether this is a byte array, and whether it is an ASN1 structure setAttributeType(); // used for sorting. XXX should this be delayed until we actually need to do any sorting?? collationKey = myCollator.getCollationKey(getID()); } /** * This method examines the schema to test whether the attribute is string, byte array or ASN1 data. */ protected void setAttributeType() { // quickly handle schema atts. String ID = getID(); // skip 'synthetic' schemas if ("SYNTAXNAMENUMERICOIDDESCEQUALITY".indexOf(ID) != -1) return; ID = ID.toLowerCase(); // see if we've already cached details about this attribute ID if (knownAttributeTypes.get(ID) != null) { isString = STRING.equals(knownAttributeTypes.get(ID)); isASN1 = ASN1.equals(knownAttributeTypes.get(ID)); } // if the attribute ends with ;binary, then it must be both isNonString and ASN1 else if (ID.endsWith(";binary")) { isString = false; isASN1 = true; } else if (schema != null) { setAttributeTypeFromSchema(); // sets isString and isASN1 variables } else // guessing time - we don't have a schema, but we'll try to figure it out from the value. { try { if (size() > 0) { Object value = get(); isString = (value == null || value instanceof String); if (!isString) isASN1 = isKnownASN1Attribute(ID); // more guessing... } } catch (NamingException e) { log.log(Level.WARNING, "Unexpected error reading value from attribute " + ID, e); } } updateTypesHashtable(ID); } private void updateTypesHashtable(String ID) { if (knownAttributeTypes.contains(ID) == false) { if (isString) knownAttributeTypes.put(ID, STRING); else if (isASN1) knownAttributeTypes.put(ID, ASN1); else knownAttributeTypes.put(ID, BYTE_ARRAY); } } /** * Does this attribute have a valid value (i.e. not null, or empty string). */ public static boolean isEmpty(Attribute att) { if (att == null || att.size() == 0) { return true; } else if (att.size() == 1) { Object val = null; try { val = att.get(); } catch (NamingException e) { return true; // assume naming exception means empty attribute... (?) } if (val == null || "".equals(val)) return true; } return false; } /** * This returns whether the Syntax is a non string syntax that should be passed * via a byte array in JNDI * * @param syntaxName * @return */ public static boolean isStringSyntax(String syntaxName) { if (syntaxName == null) return true; //don't know - default to 'yes' int pos = syntaxName.indexOf("1.3.6.1.4.1.1466.115.121.1."); if (pos == -1) return true; //don't know - default to 'yes' // some faffing around to get the final number of the OID. Could probably be neatened up :-). String number = syntaxName.substring(pos + "1.3.6.1.4.1.1466.115.121.1.".length()); if (number.length() > 2) { number = number.substring(0, 2); char c = number.charAt(1); if (Character.isDigit(c) == false) number = number.substring(0, 1); } try { int finalNumber = Integer.parseInt(number); switch (finalNumber) { case 4: return false; // 1.3.6.1.4.1.1466.115.121.1.4 - audio case 5: return false; // 1.3.6.1.4.1.1466.115.121.1.5 - ASN1 binary case 8: return false; // 1.3.6.1.4.1.1466.115.121.1.8 - certificate case 9: return false; // 1.3.6.1.4.1.1466.115.121.1.9 - certificate list case 10: return false; // 1.3.6.1.4.1.1466.115.121.1.10 - certificate pair case 28: return false; // 1.3.6.1.4.1.1466.115.121.1.28 - jpeg case 40: return false; // 1.3.6.1.4.1.1466.115.121.1.40 - octet string default: return true; } } catch (NumberFormatException e) { log.log(Level.WARNING, "Unexpected error parsing syntax: " + syntaxName, e); return true; } } /** * Returns whether the attribute is an ASN.1 structure * (and thus a candidate for having ;binary tacked on to its name) * * @param syntaxName the name of the syntax (usually a thumping great OID) * @return */ public static boolean isASN1Syntax(String syntaxName) { if (syntaxName == null) return false; int pos = syntaxName.indexOf("1.3.6.1.4.1.1466.115.121.1."); if (pos == -1) return false; String number = syntaxName.substring(pos + "1.3.6.1.4.1.1466.115.121.1.".length()); if (number.length() > 2) { number = number.substring(0, 2); char c = number.charAt(1); if (Character.isDigit(c) == false) number = number.substring(0, 1); } try { int finalNumber = Integer.parseInt(number); switch (finalNumber) { case 5: return true; // 1.3.6.1.4.1.1466.115.121.1.5 - ASN1 binary case 8: return true; // 1.3.6.1.4.1.1466.115.121.1.8 - certificate case 9: return true; // 1.3.6.1.4.1.1466.115.121.1.9 - certificate list case 10: return true; // 1.3.6.1.4.1.1466.115.121.1.10 - certificate pair default: return false; } } catch (NumberFormatException e) { log.log(Level.WARNING, "Unexpected error parsing syntax: " + syntaxName, e); return false; } } /** * <p>Look up the attribute ID in the schema, and see whether the * syntax found there is a String, or if it is a byte array whether it is also an ASN1 structure.</p> * <p>This method sets the following globals:</p> * syntaxOID<br> * isString<br> * isASN1<br> */ public void setAttributeTypeFromSchema() { if (schema != null) { try { String attributeNameInSchema = "AttributeDefinition/" + getID(); Attributes atts = schema.getAttributes(attributeNameInSchema); Attribute syntaxAttribute = null; while (atts!=null && (syntaxAttribute = atts.get("SUP")) != null) { atts = schema.getAttributes("AttributeDefinition/" + syntaxAttribute.get().toString()); } if (atts!=null) syntaxAttribute = atts.get("SYNTAX"); if (syntaxAttribute != null) { syntaxOID = syntaxAttribute.toString(); isString = isStringSyntax(syntaxOID); if (!isString) isASN1 = isASN1Syntax(syntaxOID); } else { log.info(" Can't find SYNTAX for... " + getID()); } } // XXX does this actually work on any known ldap server?? // XXX - if so, should modify above so that when atts == null the below is run I guess... catch (NamingException e) // usually means the attribute wasn't found under that name. Try again using ';binary' suffix. { try { Attributes atts = schema.getAttributes("AttributeDefinition/" + getID() + ";binary"); // if we find anything at all, it must be an ASN1 ;binary attribute... if (atts != null) { isString = false; isASN1 = true; } } catch (Exception e2) // give up { log.log(Level.INFO, "can't find syntax for attribute " + getID(), e); } } } else { log.fine("no schema available"); } } /** * Whether the attribute contains isNonString data; ideally found by checking Syntax, but * often set by inspection of the attribute value (whether it is a Byte array). * * @deprecated use isString instead */ public boolean isBinary() { return !isString(); } /** * Whether the attribute contains isNonString data; ideally found by checking Syntax, but * often set by inspection of the attribute value (whether it is a Byte array). */ public boolean isString() { return isString; } /** * Sets the isNonString status of the attribute. Shouldn't be required any more; * should be set by syntax checking. * * @deprecated use setString() instead */ public void setBinary(boolean bin) { setString(!bin); } /** * Sets the isNonString status of the attribute. Shouldn't be required any more; * should be set by syntax checking. */ public void setString(boolean stringStatus) { knownAttributeTypes.put(getID(), (stringStatus)?STRING:BYTE_ARRAY); isString = stringStatus; } /** * Utility Function: takes a schema Entry class such as 'AttributeDefinition/cn', * * and returns the result of looking up a particular attribute within that * (e.g. 'DESC'). * * @param schemaEntry the full schema entry name to lookup, e.g. 'ClassDefinition/alias' * @param schemaAttribute the attribute to look up, e.g. 'MUST' * @return the value of the schema entry attribute (e.g. '2.5.4.1') */ public String schemaLookup(String schemaEntry, String schemaAttribute) { if (schema == null) return null; else return schema.schemaLookup(schemaEntry, schemaAttribute); } /** * returns whether this attribute has a description in the schema * @return */ public boolean hasOptions() { if (description == null) // try to load a description if it exists getDescription(); if (description == null || description == "" || description.indexOf("LIST:") < 0) return false; return true; } /** * IF a description field has been set in the schema, and IF that * description field LISTs a set of values, read 'em and return them * as a string array. */ public String[] getOptions() { if (description == null) getDescription(); if (description == null || description == "") return new String[0]; // can't be fagged working out java generic parse stuff - do own quickie... int len = description.length(); int pos = description.indexOf("LIST:"); if (pos < 0) return new String[0]; pos += 5; int next = pos; Vector resVect = new Vector(); resVect.add(""); // String option; while (pos < len && pos > 0) { next = description.indexOf(',', next + 1); if (next < 0) { resVect.add(description.substring(pos)); pos = 0; } else if (description.charAt(next - 1) != '\\') { resVect.add(description.substring(pos, next)); pos = next + 1; } else { next++; // move past the escaped comma } } // dump vector into string array, unescaping as we go. String[] result = new String[resVect.size()]; for (int i = 0; i < resVect.size(); i++) result[i] = unEscape((String) resVect.elementAt(i)); return result; } public String unEscape(String escapeMe) { int slashpos = escapeMe.indexOf('\\'); while (slashpos >= 0) { escapeMe = escapeMe.substring(0, slashpos) + escapeMe.substring(slashpos + 1); slashpos = escapeMe.indexOf('\\'); } return escapeMe; } /** * returns the OID of the schema entry corresponding to this particular entry. Whoo hoo... something like * '1.3.6.1.4.1.1466.115.121.1.27'. * @return */ public String getSyntaxOID() { if (syntaxOID == null) setAttributeTypeFromSchema(); // sets syntaxOID if (syntaxOID == null) return "<unknown>"; else return syntaxOID; } /** * Returns (and caches) the syntax description. */ public String getSyntaxDesc() { if (syntaxDesc == null) syntaxDesc = schemaLookup("SyntaxDefinition/" + getSyntaxOID(), "DESC"); return syntaxDesc; } public String getSyntaxName() { if (syntaxOID == null) setAttributeTypeFromSchema(); // sets syntaxOID if (syntaxOID == null) return "<unknown>"; else return schema.translateOID(syntaxOID); } /** * Usefull escape to allow renaming of attributes. Use with caution, * since an arbitrary name may not correspond to a valid schema name. */ public void setName(String newName) { name = newName; } public String getName() { if (name == null) name = schemaLookup("AttributeDefinition/" + getID(), "NAME"); if (name == null) name = getID(); return name; } /** * Returns the attribute's 'DESC' field from the attribute schema * definition, if such exists (it's an extension). Not to be * confused with the Syntax Description, which is something like "isNonString". */ public String getDescription() { if (description == null) { description = schemaLookup("AttributeDefinition/" + getID(), "DESC"); if (description == null) // if description is still null, set it description = ""; // to an empty string, to avoid repeatedly looking it up. } return description; } /** * <p>A synonym for getID(). Use 'toDebugString()' for the complete printout.</p> * * @return */ public String toString() { return getID(); } /** * General descriptive string: used mainly for debugging... */ public String toDebugString() { int count = 1; try { StringBuffer result = new StringBuffer().append("att: ").append(getID()).append(" (size=").append(size()).append(") "); NamingEnumeration vals = getAll(); if (!isString) { result.append(" (Byte Array) "); while (vals.hasMore()) { try { byte[] b = (byte[]) vals.next(); result.append("\n ").append((count++)).append(":").append(((b == null) ? "null" : CBBase64.binaryToString(b))); } catch (ClassCastException cce) { result.append("\n ").append((count++)).append(": <error - not a byte array>"); } } } else { while (vals.hasMore()) { Object o = vals.next(); result.append("\n ").append((count++)).append(":").append(((o == null) ? "null" : o.toString())); } } return result.append("\n").toString(); } catch (NamingException e) { log.log(Level.WARNING, "error listing values for " + getID(), e); return (getID() + " (error listing values)"); } } // ugly, ugly hack to add ';binary' when writting data to dir, but // not otherwise. public static void setVerboseBinary(boolean status) { appendBinaryOption = status; log.fine("setting isNonString attribute status to " + status); } /** * This returns the name of the attribute. * @return the attribute name; e.g. 'commonName' */ //TODO: should this use the OID instead? Would solve problems with loonies who //TODO: use different names for the same attribute in different place public String getID() { String id = super.getID(); if (appendBinaryOption && !(id.endsWith(";binary"))) { //System.out.println("binaryness = " + isNonString); // TODO: this should only happen for ASN.1. syntaxes. if (isASN1) { id = id + ";binary"; log.info("appending ;binary to attribute name "+id); } } return id; } /** * A last resort hack to guess whether an otherwise unknown attribute is * an ASN1 structure. This should only be used if the schema is unavailable. * @param id * @return */ public boolean isKnownASN1Attribute(String id) { String search = id.toLowerCase(); if (search.indexOf("certificate") >= 0) return true; else if (search.indexOf("revocation") >= 0) return true; else if (search.indexOf("supportedalgorithms") >= 0) return true; else if (search.indexOf("userpkcs12") >= 0) return true; return false; } /** * This method gets all the values of an attribute. Useful only * for multivalued attributes (use get() otherwise). * * @return all the values of this attribute in a String Array. * XXX - assumes all values are strings?? */ public Object[] getValues() { Object[] values = new String[size()]; try { for (int i = 0; i < size(); i++) values[i] = get(i); return values; } catch (NamingException e) { return new String[]{}; } } /** * Gets rid of null values and empty strings from the value set. */ public void trim() { for (int i = size() - 1; i > 0; i--) { Object o = null; try { o = get(i); if (o == null || "".equals(o)) { remove(i); } } catch (NamingException e) // shouldn't happen... { log.log(Level.WARNING, "Bad Attribute value in DXAttribute - removing ", e); remove(i); // .. but remove offending entry if it does. } } } public void setOrdered(boolean state) { ordered = state; } /** * Returns true if this attribute is a SINGLE-VALUE attribute. * * @return true if this attribute is a SINGLE-VALUE attribute, * false otherwise. */ public boolean isSingleValued() {/* TE */ return schema.isAttributeSingleValued(getName()); } /** * <p>The collation key is usually set by the constructor * based on getID(), but * may be over-ridden here if required. Not sure that this * will ever be necessary; maybe if doing something insanely * clever across multiple platforms with different languages?</p> * * @param key */ public void setCollationKey(CollationKey key) { collationKey = key; } /** * <p>This returns the collation key used for language sensitive * sorting.</p> * * @return */ public CollationKey getCollationKey() { return collationKey; } /** * <p>This is intended to compare two DXAttribute objects, and will * throw a class cast exception for anything else. It sorts on * their internal collationkeys.</p> * * @param o * @return */ public int compareTo(Object o) { return collationKey.compareTo(((DXAttribute) o).getCollationKey()); } }

The table below shows all metrics for DXAttribute.java.

MetricValueDescription
BLOCKS99.00Number of blocks
BLOCK_COMMENT 0.00Number of block comment lines
COMMENTS210.00Comment lines
COMMENT_DENSITY 0.59Comment density
COMPARISONS84.00Number of comparison operators
CYCLOMATIC140.00Cyclomatic complexity
DECL_COMMENTS41.00Comments in declarations
DOC_COMMENT184.00Number of javadoc comment lines
ELOC353.00Effective lines of code
EXEC_COMMENTS16.00Comments in executable code
EXITS68.00Procedure exits
FUNCTIONS40.00Number of function declarations
HALSTEAD_DIFFICULTY89.41Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY97.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 1.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 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA003436.00JAVA0034 Missing braces in if statement
JAVA0035 2.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 0.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 1.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 1.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 2.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
JAVA0076 6.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 0.00JAVA0080 Import declaration not used
JAVA0081 3.00JAVA0081 Boolean literal in comparison
JAVA0082 1.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 1.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 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 1.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 5.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 7.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 0.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 5.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 1.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 6.00JAVA0144 Line exceeds maximum M characters
JAVA0145 0.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 1.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 1.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 1.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 0.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
LINES886.00Number of lines in the source file
LINE_COMMENT26.00Number of line comments
LOC555.00Lines of code
LOGICAL_LINES206.00Number of statements
LOOPS 9.00Number of loops
NEST_DEPTH 5.00Maximum nesting depth
OPERANDS847.00Number of operands
OPERATORS1868.00Number of operators
PARAMS23.00Number of formal parameter declarations
PROGRAM_LENGTH2715.00Halstead program length
PROGRAM_VOCAB327.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS74.00Number of return points from functions
SIZE27257.00Size of the file in bytes
UNIQUE_OPERANDS270.00Number of unique operands
UNIQUE_OPERATORS57.00Number of unique operators
WHITESPACE121.00Number of whitespace lines