OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.or
g/TR/html4/loose.dtd"> |
| 2 <html><head><title>FindBugs Bug Descriptions</title> |
| 3 <link rel="stylesheet" type="text/css" href="findbugs.css"/> |
| 4 <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/> |
| 5 </head><body> |
| 6 |
| 7 <table width="100%"><tr> |
| 8 |
| 9 <td bgcolor="#b9b9fe" valign="top" align="left" width="20%"> |
| 10 <table width="100%" cellspacing="0" border="0"> |
| 11 <tr><td><a class="sidebar" href="index.html"><img src="umdFindbugs.png" alt="Fin
dBugs"></a></td></tr> |
| 12 |
| 13 <tr><td> </td></tr> |
| 14 |
| 15 <tr><td><b>Docs and Info</b></td></tr> |
| 16 <tr><td><font size="-1"> <a class="sidebar" href="findbugs2.html">FindBugs
2.0</a></font></td></tr> |
| 17 <tr><td><font size="-1"> <a class="sidebar" href="demo.html">Demo and data<
/a></font></td></tr> |
| 18 <tr><td><font size="-1"> <a class="sidebar" href="users.html">Users and sup
porters</a></font></td></tr> |
| 19 <tr><td><font size="-1"> <a class="sidebar" href="http://findbugs.blogspot.
com/">FindBugs blog</a></font></td></tr> |
| 20 <tr><td><font size="-1"> <a class="sidebar" href="factSheet.html">Fact shee
t</a></font></td></tr> |
| 21 <tr><td><font size="-1"> <a class="sidebar" href="manual/index.html">Manual
</a></font></td></tr> |
| 22 <tr><td><font size="-1"> <a class="sidebar" href="ja/manual/index.html">Man
ual(ja/日本語)</a></font></td></tr> |
| 23 <tr><td><font size="-1"> <a class="sidebar" href="FAQ.html">FAQ</a></font><
/td></tr> |
| 24 <tr><td><font size="-1"> <a class="sidebar" href="bugDescriptions.html">Bug
descriptions</a></font></td></tr> |
| 25 <tr><td><font size="-1"> <a class="sidebar" href="bugDescriptions_ja.html">
Bug descriptions(ja/日本語)</a></font></td></tr> |
| 26 <tr><td><font size="-1"> <a class="sidebar" href="bugDescriptions_fr.html">
Bug descriptions(fr)</a></font></td></tr> |
| 27 <tr><td><font size="-1"> <a class="sidebar" href="mailingLists.html">Mailin
g lists</a></font></td></tr> |
| 28 <tr><td><font size="-1"> <a class="sidebar" href="publications.html">Docume
nts and Publications</a></font></td></tr> |
| 29 <tr><td><font size="-1"> <a class="sidebar" href="links.html">Links</a></fo
nt></td></tr> |
| 30 |
| 31 <tr><td> </td></tr> |
| 32 |
| 33 <tr><td><a class="sidebar" href="downloads.html"><b>Downloads</b></a></td></tr> |
| 34 |
| 35 <tr><td> </td></tr> |
| 36 |
| 37 <tr><td><a class="sidebar" href="http://www.cafeshops.com/findbugs"><b>FindBugs
Swag</b></a></td></tr> |
| 38 |
| 39 <tr><td> </td></tr> |
| 40 |
| 41 <tr><td><b>Development</b></td></tr> |
| 42 <tr><td><font size="-1"> <a class="sidebar" href="http://sourceforge.net/tr
acker/?group_id=96405">Open bugs</a></font></td></tr> |
| 43 <tr><td><font size="-1"> <a class="sidebar" href="reportingBugs.html">Repor
ting bugs</a></font></td></tr> |
| 44 <tr><td><font size="-1"> <a class="sidebar" href="contributing.html">Contri
buting</a></font></td></tr> |
| 45 <tr><td><font size="-1"> <a class="sidebar" href="team.html">Dev team</a></
font></td></tr> |
| 46 <tr><td><font size="-1"> <a class="sidebar" href="api/index.html">API</a> <
a class="sidebar" href="api/overview-summary.html">[no frames]</a></font></td></
tr> |
| 47 <tr><td><font size="-1"> <a class="sidebar" href="Changes.html">Change log<
/a></font></td></tr> |
| 48 <tr><td><font size="-1"> <a class="sidebar" href="http://sourceforge.net/pr
ojects/findbugs">SF project page</a></font></td></tr> |
| 49 <tr><td><font size="-1"> <a class="sidebar" href="http://code.google.com/p/
findbugs/source/browse/">Browse source</a></font></td></tr> |
| 50 <tr><td><font size="-1"> <a class="sidebar" href="http://code.google.com/p/
findbugs/source/list">Latest code changes</a></font></td></tr> |
| 51 </table> |
| 52 </td> |
| 53 <td align="left" valign="top"> |
| 54 <h1>FindBugs Bug Descriptions</h1> |
| 55 <p>This document lists the standard bug patterns reported by |
| 56 <a href="http://findbugs.sourceforge.net">FindBugs</a> version 3.0.0.</p> |
| 57 <h2>Summary</h2> |
| 58 <table width="100%"> |
| 59 <tr bgcolor="#b9b9fe"><th>Description</th><th>Category</th></tr> |
| 60 <tr bgcolor="#eeeeee"><td><a href="#BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS
">BC: Equals method should not assume anything about the type of its argument</a
></td><td>Bad practice</td></tr> |
| 61 <tr bgcolor="#ffffff"><td><a href="#BIT_SIGNED_CHECK">BIT: Check for sign of bit
wise operation</a></td><td>Bad practice</td></tr> |
| 62 <tr bgcolor="#eeeeee"><td><a href="#CN_IDIOM">CN: La classe implémente Cloneable
mais ne définit et n'utilise pas la méthode clone()</a></td><td>Bad practice</t
d></tr> |
| 63 <tr bgcolor="#ffffff"><td><a href="#CN_IDIOM_NO_SUPER_CALL">CN: La méthode clone
() n'appelle pas super.clone()</a></td><td>Bad practice</td></tr> |
| 64 <tr bgcolor="#eeeeee"><td><a href="#CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE">CN: C
lass defines clone() but doesn't implement Cloneable</a></td><td>Bad practice</t
d></tr> |
| 65 <tr bgcolor="#ffffff"><td><a href="#CNT_ROUGH_CONSTANT_VALUE">CNT: Rough value o
f known constant found</a></td><td>Bad practice</td></tr> |
| 66 <tr bgcolor="#eeeeee"><td><a href="#CO_ABSTRACT_SELF">Co: Une classe abstraite d
éfinit une méthode compareTo() covariante</a></td><td>Bad practice</td></tr> |
| 67 <tr bgcolor="#ffffff"><td><a href="#CO_SELF_NO_OBJECT">Co: Définition d'une méth
ode compareTo() covariante</a></td><td>Bad practice</td></tr> |
| 68 <tr bgcolor="#eeeeee"><td><a href="#DE_MIGHT_DROP">DE: La méthode peut déclenche
r une exception</a></td><td>Bad practice</td></tr> |
| 69 <tr bgcolor="#ffffff"><td><a href="#DE_MIGHT_IGNORE">DE: La méthode peut ignorer
une exception</a></td><td>Bad practice</td></tr> |
| 70 <tr bgcolor="#eeeeee"><td><a href="#DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS">DMI:
Adding elements of an entry set may fail due to reuse of Entry objects</a></td>
<td>Bad practice</td></tr> |
| 71 <tr bgcolor="#ffffff"><td><a href="#DMI_RANDOM_USED_ONLY_ONCE">DMI: Random objec
t created and used only once</a></td><td>Bad practice</td></tr> |
| 72 <tr bgcolor="#eeeeee"><td><a href="#DMI_USING_REMOVEALL_TO_CLEAR_COLLECTION">DMI
: Don't use removeAll to clear a collection</a></td><td>Bad practice</td></tr> |
| 73 <tr bgcolor="#ffffff"><td><a href="#DM_EXIT">Dm: La méthode invoque System.exit(
...)</a></td><td>Bad practice</td></tr> |
| 74 <tr bgcolor="#eeeeee"><td><a href="#DM_RUN_FINALIZERS_ON_EXIT">Dm: Méthode invoq
uant runFinalizersOnExit, l'une des plus dangeureuses méthodes des librairies Ja
va</a></td><td>Bad practice</td></tr> |
| 75 <tr bgcolor="#ffffff"><td><a href="#ES_COMPARING_PARAMETER_STRING_WITH_EQ">ES: C
omparison of String parameter using == or !=</a></td><td>Bad practice</td></tr> |
| 76 <tr bgcolor="#eeeeee"><td><a href="#ES_COMPARING_STRINGS_WITH_EQ">ES: Comparaiso
n d'objets String utilisant == ou !=</a></td><td>Bad practice</td></tr> |
| 77 <tr bgcolor="#ffffff"><td><a href="#EQ_ABSTRACT_SELF">Eq: Une classe abstraite d
éfinit une méthode equals() covariante</a></td><td>Bad practice</td></tr> |
| 78 <tr bgcolor="#eeeeee"><td><a href="#EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THI
S">Eq: Equals checks for incompatible operand</a></td><td>Bad practice</td></tr> |
| 79 <tr bgcolor="#ffffff"><td><a href="#EQ_COMPARETO_USE_OBJECT_EQUALS">Eq: Class de
fines compareTo(...) and uses Object.equals()</a></td><td>Bad practice</td></tr> |
| 80 <tr bgcolor="#eeeeee"><td><a href="#EQ_GETCLASS_AND_CLASS_CONSTANT">Eq: equals m
ethod fails for subtypes</a></td><td>Bad practice</td></tr> |
| 81 <tr bgcolor="#ffffff"><td><a href="#EQ_SELF_NO_OBJECT">Eq: Définition d'une méth
ode equals() covariante</a></td><td>Bad practice</td></tr> |
| 82 <tr bgcolor="#eeeeee"><td><a href="#FI_EMPTY">FI: Un finaliseur vide devrait êtr
e supprimé</a></td><td>Bad practice</td></tr> |
| 83 <tr bgcolor="#ffffff"><td><a href="#FI_EXPLICIT_INVOCATION">FI: Invocation expli
cite d'un finaliseur</a></td><td>Bad practice</td></tr> |
| 84 <tr bgcolor="#eeeeee"><td><a href="#FI_FINALIZER_NULLS_FIELDS">FI: Finalizer nul
ls fields</a></td><td>Bad practice</td></tr> |
| 85 <tr bgcolor="#ffffff"><td><a href="#FI_FINALIZER_ONLY_NULLS_FIELDS">FI: Finalize
r only nulls fields</a></td><td>Bad practice</td></tr> |
| 86 <tr bgcolor="#eeeeee"><td><a href="#FI_MISSING_SUPER_CALL">FI: Le finaliseur n'a
ppelle pas le finaliseur de la super-classe</a></td><td>Bad practice</td></tr> |
| 87 <tr bgcolor="#ffffff"><td><a href="#FI_NULLIFY_SUPER">FI: Un finaliseur rend inu
tile celui de sa super-classe</a></td><td>Bad practice</td></tr> |
| 88 <tr bgcolor="#eeeeee"><td><a href="#FI_USELESS">FI: Le finaliseur ne fait rien s
auf appeler celui de la super-classe</a></td><td>Bad practice</td></tr> |
| 89 <tr bgcolor="#ffffff"><td><a href="#VA_FORMAT_STRING_USES_NEWLINE">FS: Format st
ring should use %n rather than \n</a></td><td>Bad practice</td></tr> |
| 90 <tr bgcolor="#eeeeee"><td><a href="#GC_UNCHECKED_TYPE_IN_GENERIC_CALL">GC: Unche
cked type in generic call</a></td><td>Bad practice</td></tr> |
| 91 <tr bgcolor="#ffffff"><td><a href="#HE_EQUALS_NO_HASHCODE">HE: La classe définit
equals() mais pas hashCode()</a></td><td>Bad practice</td></tr> |
| 92 <tr bgcolor="#eeeeee"><td><a href="#HE_EQUALS_USE_HASHCODE">HE: La classe défini
t equals() et utilise Object.hashCode()</a></td><td>Bad practice</td></tr> |
| 93 <tr bgcolor="#ffffff"><td><a href="#HE_HASHCODE_NO_EQUALS">HE: La classe définit
hashCode() mais pas equals()</a></td><td>Bad practice</td></tr> |
| 94 <tr bgcolor="#eeeeee"><td><a href="#HE_HASHCODE_USE_OBJECT_EQUALS">HE: La classe
définit hashCode() et utilise Object.equals()</a></td><td>Bad practice</td></tr
> |
| 95 <tr bgcolor="#ffffff"><td><a href="#HE_INHERITS_EQUALS_USE_HASHCODE">HE: La clas
se hérite de equals() et utilise Object.hashCode()</a></td><td>Bad practice</td>
</tr> |
| 96 <tr bgcolor="#eeeeee"><td><a href="#IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZ
ATION">IC: Classe mère utilisant une sous-classe durant son initialisation</a></
td><td>Bad practice</td></tr> |
| 97 <tr bgcolor="#ffffff"><td><a href="#IMSE_DONT_CATCH_IMSE">IMSE: Interception dou
teuse d'une IllegalMonitorStateException</a></td><td>Bad practice</td></tr> |
| 98 <tr bgcolor="#eeeeee"><td><a href="#ISC_INSTANTIATE_STATIC_CLASS">ISC: Instantia
tion inutile d'une classe qui n'a que des méthodes statiques</a></td><td>Bad pra
ctice</td></tr> |
| 99 <tr bgcolor="#ffffff"><td><a href="#IT_NO_SUCH_ELEMENT">It: La méthode next() de
Iterator ne peut pas déclencher une exception NoSuchElement</a></td><td>Bad pra
ctice</td></tr> |
| 100 <tr bgcolor="#eeeeee"><td><a href="#J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_S
ESSION">J2EE: Stockage d'un objet non serialisable dans une session Http</a></td
><td>Bad practice</td></tr> |
| 101 <tr bgcolor="#ffffff"><td><a href="#JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS">JC
IP: Les champs d'une classe immuable devraient être finaux.</a></td><td>Bad prac
tice</td></tr> |
| 102 <tr bgcolor="#eeeeee"><td><a href="#NP_BOOLEAN_RETURN_NULL">NP: Method with Bool
ean return type returns explicit null</a></td><td>Bad practice</td></tr> |
| 103 <tr bgcolor="#ffffff"><td><a href="#NP_CLONE_COULD_RETURN_NULL">NP: Clone method
may return null</a></td><td>Bad practice</td></tr> |
| 104 <tr bgcolor="#eeeeee"><td><a href="#NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT">NP: M
éthode equals() ne vérifiant pas la nullité</a></td><td>Bad practice</td></tr> |
| 105 <tr bgcolor="#ffffff"><td><a href="#NP_TOSTRING_COULD_RETURN_NULL">NP: toString
method may return null</a></td><td>Bad practice</td></tr> |
| 106 <tr bgcolor="#eeeeee"><td><a href="#NM_CLASS_NAMING_CONVENTION">Nm: Nom de class
e devant commencer par une majuscule</a></td><td>Bad practice</td></tr> |
| 107 <tr bgcolor="#ffffff"><td><a href="#NM_CLASS_NOT_EXCEPTION">Nm: Cette classe ne
dérive pas d'Exception, même si son nom le sous-entend</a></td><td>Bad practice<
/td></tr> |
| 108 <tr bgcolor="#eeeeee"><td><a href="#NM_CONFUSING">Nm: Noms de méthodes ambigus</
a></td><td>Bad practice</td></tr> |
| 109 <tr bgcolor="#ffffff"><td><a href="#NM_FIELD_NAMING_CONVENTION">Nm: Nom de champ
devant commencer par une minuscule</a></td><td>Bad practice</td></tr> |
| 110 <tr bgcolor="#eeeeee"><td><a href="#NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER">Nm: Us
e of identifier that is a keyword in later versions of Java</a></td><td>Bad prac
tice</td></tr> |
| 111 <tr bgcolor="#ffffff"><td><a href="#NM_FUTURE_KEYWORD_USED_AS_MEMBER_IDENTIFIER"
>Nm: Use of identifier that is a keyword in later versions of Java</a></td><td>B
ad practice</td></tr> |
| 112 <tr bgcolor="#eeeeee"><td><a href="#NM_METHOD_NAMING_CONVENTION">Nm: Nom de méth
ode devant commencer par une minuscule</a></td><td>Bad practice</td></tr> |
| 113 <tr bgcolor="#ffffff"><td><a href="#NM_SAME_SIMPLE_NAME_AS_INTERFACE">Nm: Class
names shouldn't shadow simple name of implemented interface</a></td><td>Bad prac
tice</td></tr> |
| 114 <tr bgcolor="#eeeeee"><td><a href="#NM_SAME_SIMPLE_NAME_AS_SUPERCLASS">Nm: Class
names shouldn't shadow simple name of superclass</a></td><td>Bad practice</td><
/tr> |
| 115 <tr bgcolor="#ffffff"><td><a href="#NM_VERY_CONFUSING_INTENTIONAL">Nm: Very conf
using method names (but perhaps intentional)</a></td><td>Bad practice</td></tr> |
| 116 <tr bgcolor="#eeeeee"><td><a href="#NM_WRONG_PACKAGE_INTENTIONAL">Nm: Method doe
sn't override method in superclass due to wrong package for parameter</a></td><t
d>Bad practice</td></tr> |
| 117 <tr bgcolor="#ffffff"><td><a href="#ODR_OPEN_DATABASE_RESOURCE">ODR: La méthode
peut ne pas fermer une ressource base de données</a></td><td>Bad practice</td></
tr> |
| 118 <tr bgcolor="#eeeeee"><td><a href="#ODR_OPEN_DATABASE_RESOURCE_EXCEPTION_PATH">O
DR: La méthode peut ne pas fermer une ressource base de données sur une exceptio
n</a></td><td>Bad practice</td></tr> |
| 119 <tr bgcolor="#ffffff"><td><a href="#OS_OPEN_STREAM">OS: La méthode peut ne pas f
ermer un flux</a></td><td>Bad practice</td></tr> |
| 120 <tr bgcolor="#eeeeee"><td><a href="#OS_OPEN_STREAM_EXCEPTION_PATH">OS: La méthod
e peut oublier de fermer un flux en cas d'exception</a></td><td>Bad practice</td
></tr> |
| 121 <tr bgcolor="#ffffff"><td><a href="#PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS">PZ
: Don't reuse entry objects in iterators</a></td><td>Bad practice</td></tr> |
| 122 <tr bgcolor="#eeeeee"><td><a href="#RC_REF_COMPARISON_BAD_PRACTICE">RC: Suspicio
us reference comparison to constant</a></td><td>Bad practice</td></tr> |
| 123 <tr bgcolor="#ffffff"><td><a href="#RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN">RC:
Suspicious reference comparison of Boolean values</a></td><td>Bad practice</td><
/tr> |
| 124 <tr bgcolor="#eeeeee"><td><a href="#RR_NOT_CHECKED">RR: La méthode ignore le rés
ultat de InputStream.read()</a></td><td>Bad practice</td></tr> |
| 125 <tr bgcolor="#ffffff"><td><a href="#SR_NOT_CHECKED">RR: La méthode ignore le rés
ultat de InputStream.skip()</a></td><td>Bad practice</td></tr> |
| 126 <tr bgcolor="#eeeeee"><td><a href="#RV_NEGATING_RESULT_OF_COMPARETO">RV: Negatin
g the result of compareTo()/compare()</a></td><td>Bad practice</td></tr> |
| 127 <tr bgcolor="#ffffff"><td><a href="#RV_RETURN_VALUE_IGNORED_BAD_PRACTICE">RV: Me
thod ignores exceptional return value</a></td><td>Bad practice</td></tr> |
| 128 <tr bgcolor="#eeeeee"><td><a href="#SI_INSTANCE_BEFORE_FINALS_ASSIGNED">SI: Init
ialiseur statique de classe créant une instance avant que tous les champs static
final soient alimentés</a></td><td>Bad practice</td></tr> |
| 129 <tr bgcolor="#ffffff"><td><a href="#SW_SWING_METHODS_INVOKED_IN_SWING_THREAD">SW
: Certaines méthodes Swing ne doivent être invoquées qu'à partir du thread Swing
</a></td><td>Bad practice</td></tr> |
| 130 <tr bgcolor="#eeeeee"><td><a href="#SE_BAD_FIELD">Se: Champ d'instance non trans
ient et non sérialisable dans une classe sérialisable</a></td><td>Bad practice</
td></tr> |
| 131 <tr bgcolor="#ffffff"><td><a href="#SE_BAD_FIELD_INNER_CLASS">Se: Non-serializab
le class has a serializable inner class</a></td><td>Bad practice</td></tr> |
| 132 <tr bgcolor="#eeeeee"><td><a href="#SE_BAD_FIELD_STORE">Se: Valeur non sérialisa
ble stockée dans un champ d'instance de classe sérialisable</a></td><td>Bad prac
tice</td></tr> |
| 133 <tr bgcolor="#ffffff"><td><a href="#SE_COMPARATOR_SHOULD_BE_SERIALIZABLE">Se: Co
mparateur n'implémentant pas Serializable</a></td><td>Bad practice</td></tr> |
| 134 <tr bgcolor="#eeeeee"><td><a href="#SE_INNER_CLASS">Se: Serializable inner class
</a></td><td>Bad practice</td></tr> |
| 135 <tr bgcolor="#ffffff"><td><a href="#SE_NONFINAL_SERIALVERSIONID">Se: serialVersi
onUID n'est pas final</a></td><td>Bad practice</td></tr> |
| 136 <tr bgcolor="#eeeeee"><td><a href="#SE_NONLONG_SERIALVERSIONID">Se: serialVersio
nUID n'est pas de type long</a></td><td>Bad practice</td></tr> |
| 137 <tr bgcolor="#ffffff"><td><a href="#SE_NONSTATIC_SERIALVERSIONID">Se: serialVers
ionUID n'est pas static</a></td><td>Bad practice</td></tr> |
| 138 <tr bgcolor="#eeeeee"><td><a href="#SE_NO_SUITABLE_CONSTRUCTOR">Se: La classe es
t Serializable mais sa super-classe ne possède pas de constructeur par défaut vi
sible</a></td><td>Bad practice</td></tr> |
| 139 <tr bgcolor="#ffffff"><td><a href="#SE_NO_SUITABLE_CONSTRUCTOR_FOR_EXTERNALIZATI
ON">Se: La classe est Externalizable mais ne définit pas de constructeur par déf
aut</a></td><td>Bad practice</td></tr> |
| 140 <tr bgcolor="#eeeeee"><td><a href="#SE_READ_RESOLVE_MUST_RETURN_OBJECT">Se: La m
éthode readResolve doit retourner un Object</a></td><td>Bad practice</td></tr> |
| 141 <tr bgcolor="#ffffff"><td><a href="#SE_TRANSIENT_FIELD_NOT_RESTORED">Se: Champ "
transient" non positionné lors de la désérialisation</a></td><td>Bad practice</t
d></tr> |
| 142 <tr bgcolor="#eeeeee"><td><a href="#SE_NO_SERIALVERSIONID">SnVI: La classe est S
erializable, mais ne définit pas serialVersionUID</a></td><td>Bad practice</td><
/tr> |
| 143 <tr bgcolor="#ffffff"><td><a href="#UI_INHERITANCE_UNSAFE_GETRESOURCE">UI: L'uti
lisation de GetResource peut-être instable si la classe est étendue</a></td><td>
Bad practice</td></tr> |
| 144 <tr bgcolor="#eeeeee"><td><a href="#BC_IMPOSSIBLE_CAST">BC: Transtypage impossib
le</a></td><td>Correctness</td></tr> |
| 145 <tr bgcolor="#ffffff"><td><a href="#BC_IMPOSSIBLE_DOWNCAST">BC: Impossible downc
ast</a></td><td>Correctness</td></tr> |
| 146 <tr bgcolor="#eeeeee"><td><a href="#BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY">BC: Impos
sible downcast of toArray() result</a></td><td>Correctness</td></tr> |
| 147 <tr bgcolor="#ffffff"><td><a href="#BC_IMPOSSIBLE_INSTANCEOF">BC: instanceof ren
verra toujours faux</a></td><td>Correctness</td></tr> |
| 148 <tr bgcolor="#eeeeee"><td><a href="#BIT_ADD_OF_SIGNED_BYTE">BIT: Bitwise add of
signed byte value</a></td><td>Correctness</td></tr> |
| 149 <tr bgcolor="#ffffff"><td><a href="#BIT_AND">BIT: Masques binaires incompatibles
</a></td><td>Correctness</td></tr> |
| 150 <tr bgcolor="#eeeeee"><td><a href="#BIT_AND_ZZ">BIT: Masques binaires incompatib
les</a></td><td>Correctness</td></tr> |
| 151 <tr bgcolor="#ffffff"><td><a href="#BIT_IOR">BIT: Masques binaires incompatibles
</a></td><td>Correctness</td></tr> |
| 152 <tr bgcolor="#eeeeee"><td><a href="#BIT_IOR_OF_SIGNED_BYTE">BIT: Ou binaire d'un
octet signé</a></td><td>Correctness</td></tr> |
| 153 <tr bgcolor="#ffffff"><td><a href="#BIT_SIGNED_CHECK_HIGH_BIT">BIT: Check for si
gn of bitwise operation</a></td><td>Correctness</td></tr> |
| 154 <tr bgcolor="#eeeeee"><td><a href="#BOA_BADLY_OVERRIDDEN_ADAPTER">BOA: La classe
surcharge mal une méthode implémentée dans une superclasse Adapter</a></td><td>
Correctness</td></tr> |
| 155 <tr bgcolor="#ffffff"><td><a href="#ICAST_BAD_SHIFT_AMOUNT">BSHIFT: Décalage d'u
n int hors de proportion (0..31)</a></td><td>Correctness</td></tr> |
| 156 <tr bgcolor="#eeeeee"><td><a href="#BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR"
>Bx: Primitive value is unboxed and coerced for ternary operator</a></td><td>Cor
rectness</td></tr> |
| 157 <tr bgcolor="#ffffff"><td><a href="#CO_COMPARETO_RESULTS_MIN_VALUE">Co: compareT
o()/compare() returns Integer.MIN_VALUE</a></td><td>Correctness</td></tr> |
| 158 <tr bgcolor="#eeeeee"><td><a href="#DLS_DEAD_LOCAL_INCREMENT_IN_RETURN">DLS: Use
less increment in return statement</a></td><td>Correctness</td></tr> |
| 159 <tr bgcolor="#ffffff"><td><a href="#DLS_DEAD_STORE_OF_CLASS_LITERAL">DLS: Dead s
tore of class literal</a></td><td>Correctness</td></tr> |
| 160 <tr bgcolor="#eeeeee"><td><a href="#DLS_OVERWRITTEN_INCREMENT">DLS: Incrémentati
on annulée</a></td><td>Correctness</td></tr> |
| 161 <tr bgcolor="#ffffff"><td><a href="#DMI_ARGUMENTS_WRONG_ORDER">DMI: Reversed met
hod arguments</a></td><td>Correctness</td></tr> |
| 162 <tr bgcolor="#eeeeee"><td><a href="#DMI_BAD_MONTH">DMI: Valeur constante pour un
mois en dehors de l'intervalle attendu de 0 à 11</a></td><td>Correctness</td></
tr> |
| 163 <tr bgcolor="#ffffff"><td><a href="#DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE">DMI:
BigDecimal constructed from double that isn't represented precisely</a></td><td
>Correctness</td></tr> |
| 164 <tr bgcolor="#eeeeee"><td><a href="#DMI_CALLING_NEXT_FROM_HASNEXT">DMI: Méthode
hasNext() appelant next()</a></td><td>Correctness</td></tr> |
| 165 <tr bgcolor="#ffffff"><td><a href="#DMI_COLLECTIONS_SHOULD_NOT_CONTAIN_THEMSELVE
S">DMI: Collections should not contain themselves</a></td><td>Correctness</td></
tr> |
| 166 <tr bgcolor="#eeeeee"><td><a href="#DMI_DOH">DMI: D'oh! A nonsensical method inv
ocation</a></td><td>Correctness</td></tr> |
| 167 <tr bgcolor="#ffffff"><td><a href="#DMI_INVOKING_HASHCODE_ON_ARRAY">DMI: Invocat
ion of hashCode on an array</a></td><td>Correctness</td></tr> |
| 168 <tr bgcolor="#eeeeee"><td><a href="#DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT">DMI:
Double.longBitsToDouble invoked on an int</a></td><td>Correctness</td></tr> |
| 169 <tr bgcolor="#ffffff"><td><a href="#DMI_VACUOUS_SELF_COLLECTION_CALL">DMI: Vacuo
us call to collections</a></td><td>Correctness</td></tr> |
| 170 <tr bgcolor="#eeeeee"><td><a href="#DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION"
>Dm: La réflexion ne peut pas être utilisée pour vérifier la présence d'une anno
tation avec la rétention par défaut</a></td><td>Correctness</td></tr> |
| 171 <tr bgcolor="#ffffff"><td><a href="#DMI_FUTILE_ATTEMPT_TO_CHANGE_MAXPOOL_SIZE_OF
_SCHEDULED_THREAD_POOL_EXECUTOR">Dm: Futile attempt to change max pool size of S
cheduledThreadPoolExecutor</a></td><td>Correctness</td></tr> |
| 172 <tr bgcolor="#eeeeee"><td><a href="#DMI_SCHEDULED_THREAD_POOL_EXECUTOR_WITH_ZERO
_CORE_THREADS">Dm: Creation of ScheduledThreadPoolExecutor with zero core thread
s</a></td><td>Correctness</td></tr> |
| 173 <tr bgcolor="#ffffff"><td><a href="#DMI_VACUOUS_CALL_TO_EASYMOCK_METHOD">Dm: Use
less/vacuous call to EasyMock method</a></td><td>Correctness</td></tr> |
| 174 <tr bgcolor="#eeeeee"><td><a href="#EC_ARRAY_AND_NONARRAY">EC: Utilisation de eq
uals() pour comparer un tableau et un objet</a></td><td>Correctness</td></tr> |
| 175 <tr bgcolor="#ffffff"><td><a href="#EC_BAD_ARRAY_COMPARE">EC: Appel à equals() s
ur un tableau équivalent à ==</a></td><td>Correctness</td></tr> |
| 176 <tr bgcolor="#eeeeee"><td><a href="#EC_INCOMPATIBLE_ARRAY_COMPARE">EC: equals(..
.) used to compare incompatible arrays</a></td><td>Correctness</td></tr> |
| 177 <tr bgcolor="#ffffff"><td><a href="#EC_NULL_ARG">EC: Appel de equals() avec un a
rgument à null</a></td><td>Correctness</td></tr> |
| 178 <tr bgcolor="#eeeeee"><td><a href="#EC_UNRELATED_CLASS_AND_INTERFACE">EC: Appel
de equals() comparant une classe et une interface sans relation</a></td><td>Corr
ectness</td></tr> |
| 179 <tr bgcolor="#ffffff"><td><a href="#EC_UNRELATED_INTERFACES">EC: Appel de equals
() comparant différentes interfaces</a></td><td>Correctness</td></tr> |
| 180 <tr bgcolor="#eeeeee"><td><a href="#EC_UNRELATED_TYPES">EC: Appel de equals() co
mparant des types différents</a></td><td>Correctness</td></tr> |
| 181 <tr bgcolor="#ffffff"><td><a href="#EC_UNRELATED_TYPES_USING_POINTER_EQUALITY">E
C: Using pointer equality to compare different types</a></td><td>Correctness</td
></tr> |
| 182 <tr bgcolor="#eeeeee"><td><a href="#EQ_ALWAYS_FALSE">Eq: equals method always re
turns false</a></td><td>Correctness</td></tr> |
| 183 <tr bgcolor="#ffffff"><td><a href="#EQ_ALWAYS_TRUE">Eq: equals method always ret
urns true</a></td><td>Correctness</td></tr> |
| 184 <tr bgcolor="#eeeeee"><td><a href="#EQ_COMPARING_CLASS_NAMES">Eq: equals method
compares class names rather than class objects</a></td><td>Correctness</td></tr> |
| 185 <tr bgcolor="#ffffff"><td><a href="#EQ_DONT_DEFINE_EQUALS_FOR_ENUM">Eq: Covarian
t equals() method defined for enum</a></td><td>Correctness</td></tr> |
| 186 <tr bgcolor="#eeeeee"><td><a href="#EQ_OTHER_NO_OBJECT">Eq: equals() method defi
ned that doesn't override equals(Object)</a></td><td>Correctness</td></tr> |
| 187 <tr bgcolor="#ffffff"><td><a href="#EQ_OTHER_USE_OBJECT">Eq: equals() method def
ined that doesn't override Object.equals(Object)</a></td><td>Correctness</td></t
r> |
| 188 <tr bgcolor="#eeeeee"><td><a href="#EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC">Eq: equa
ls method overrides equals in superclass and may not be symmetric</a></td><td>Co
rrectness</td></tr> |
| 189 <tr bgcolor="#ffffff"><td><a href="#EQ_SELF_USE_OBJECT">Eq: Définition d'une mét
hode equals() covariante, Object.equals(Object) est hérité</a></td><td>Correctne
ss</td></tr> |
| 190 <tr bgcolor="#eeeeee"><td><a href="#FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER">FE: Test d
'égalité avec NaN erroné</a></td><td>Correctness</td></tr> |
| 191 <tr bgcolor="#ffffff"><td><a href="#VA_FORMAT_STRING_BAD_ARGUMENT">FS: Format st
ring placeholder incompatible with passed argument</a></td><td>Correctness</td><
/tr> |
| 192 <tr bgcolor="#eeeeee"><td><a href="#VA_FORMAT_STRING_BAD_CONVERSION">FS: The typ
e of a supplied argument doesn't match format specifier</a></td><td>Correctness<
/td></tr> |
| 193 <tr bgcolor="#ffffff"><td><a href="#VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUP
PLIED">FS: MessageFormat supplied where printf style format expected</a></td><td
>Correctness</td></tr> |
| 194 <tr bgcolor="#eeeeee"><td><a href="#VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED">FS:
More arguments are passed than are actually used in the format string</a></td><
td>Correctness</td></tr> |
| 195 <tr bgcolor="#ffffff"><td><a href="#VA_FORMAT_STRING_ILLEGAL">FS: Illegal format
string</a></td><td>Correctness</td></tr> |
| 196 <tr bgcolor="#eeeeee"><td><a href="#VA_FORMAT_STRING_MISSING_ARGUMENT">FS: Forma
t string references missing argument</a></td><td>Correctness</td></tr> |
| 197 <tr bgcolor="#ffffff"><td><a href="#VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT">FS: N
o previous argument for format string</a></td><td>Correctness</td></tr> |
| 198 <tr bgcolor="#eeeeee"><td><a href="#GC_UNRELATED_TYPES">GC: No relationship betw
een generic parameter and method argument</a></td><td>Correctness</td></tr> |
| 199 <tr bgcolor="#ffffff"><td><a href="#HE_SIGNATURE_DECLARES_HASHING_OF_UNHASHABLE_
CLASS">HE: Signature declares use of unhashable class in hashed construct</a></t
d><td>Correctness</td></tr> |
| 200 <tr bgcolor="#eeeeee"><td><a href="#HE_USE_OF_UNHASHABLE_CLASS">HE: Use of class
without a hashCode() method in a hashed data structure</a></td><td>Correctness<
/td></tr> |
| 201 <tr bgcolor="#ffffff"><td><a href="#ICAST_INT_2_LONG_AS_INSTANT">ICAST: int valu
e converted to long and used as absolute time</a></td><td>Correctness</td></tr> |
| 202 <tr bgcolor="#eeeeee"><td><a href="#ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL">ICA
ST: Valeur entière transtypée en nombre flottant passée à Math.ceil</a></td><td>
Correctness</td></tr> |
| 203 <tr bgcolor="#ffffff"><td><a href="#ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND">ICA
ST: Valeur entière transtypée en flottant puis transmise à Math.round</a></td><t
d>Correctness</td></tr> |
| 204 <tr bgcolor="#eeeeee"><td><a href="#IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METHOD">I
JU: JUnit assertion in run method will not be noticed by JUnit</a></td><td>Corre
ctness</td></tr> |
| 205 <tr bgcolor="#ffffff"><td><a href="#IJU_BAD_SUITE_METHOD">IJU: TestCase declares
a bad suite method </a></td><td>Correctness</td></tr> |
| 206 <tr bgcolor="#eeeeee"><td><a href="#IJU_NO_TESTS">IJU: TestCase sans tests</a></
td><td>Correctness</td></tr> |
| 207 <tr bgcolor="#ffffff"><td><a href="#IJU_SETUP_NO_SUPER">IJU: Une classe dérivant
de TestCase implémente setUp() sans appeler super.setUp()</a></td><td>Correctne
ss</td></tr> |
| 208 <tr bgcolor="#eeeeee"><td><a href="#IJU_SUITE_NOT_STATIC">IJU: Une classe dériva
nt de TestCase implémente une méthode suite() non statique</a></td><td>Correctne
ss</td></tr> |
| 209 <tr bgcolor="#ffffff"><td><a href="#IJU_TEARDOWN_NO_SUPER">IJU: Une classe dériv
ant de TestCase implémente tearDown() sans appeler super.tearDown()</a></td><td>
Correctness</td></tr> |
| 210 <tr bgcolor="#eeeeee"><td><a href="#IL_CONTAINER_ADDED_TO_ITSELF">IL: Un contene
ur est ajouté à lui-même</a></td><td>Correctness</td></tr> |
| 211 <tr bgcolor="#ffffff"><td><a href="#IL_INFINITE_LOOP">IL: Boucle apparemment ini
finie</a></td><td>Correctness</td></tr> |
| 212 <tr bgcolor="#eeeeee"><td><a href="#IL_INFINITE_RECURSIVE_LOOP">IL: Boucle récur
sive infinie</a></td><td>Correctness</td></tr> |
| 213 <tr bgcolor="#ffffff"><td><a href="#IM_MULTIPLYING_RESULT_OF_IREM">IM: Multiplic
ation d'un entier avec le résulat entier d'un modulo</a></td><td>Correctness</td
></tr> |
| 214 <tr bgcolor="#eeeeee"><td><a href="#INT_BAD_COMPARISON_WITH_INT_VALUE">INT: Bad
comparison of int value with long constant</a></td><td>Correctness</td></tr> |
| 215 <tr bgcolor="#ffffff"><td><a href="#INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE">I
NT: Bad comparison of nonnegative value with negative constant</a></td><td>Corre
ctness</td></tr> |
| 216 <tr bgcolor="#eeeeee"><td><a href="#INT_BAD_COMPARISON_WITH_SIGNED_BYTE">INT: Ba
d comparison of signed byte</a></td><td>Correctness</td></tr> |
| 217 <tr bgcolor="#ffffff"><td><a href="#IO_APPENDING_TO_OBJECT_OUTPUT_STREAM">IO: Do
omed attempt to append to an object output stream</a></td><td>Correctness</td></
tr> |
| 218 <tr bgcolor="#eeeeee"><td><a href="#IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN">IP: Un
paramètre est ré-écrit avant d'être utilisé</a></td><td>Correctness</td></tr> |
| 219 <tr bgcolor="#ffffff"><td><a href="#MF_CLASS_MASKS_FIELD">MF: La classe définit
un champ qui masque un champ d'une classe mère</a></td><td>Correctness</td></tr> |
| 220 <tr bgcolor="#eeeeee"><td><a href="#MF_METHOD_MASKS_FIELD">MF: La méthode défini
t une variable qui masque un champ</a></td><td>Correctness</td></tr> |
| 221 <tr bgcolor="#ffffff"><td><a href="#NP_ALWAYS_NULL">NP: Déréférencement d'un poi
nteur null dans la méthode</a></td><td>Correctness</td></tr> |
| 222 <tr bgcolor="#eeeeee"><td><a href="#NP_ALWAYS_NULL_EXCEPTION">NP: Déréférencemen
t d'un pointeur null dans le chemin d'exception d'une méthode</a></td><td>Correc
tness</td></tr> |
| 223 <tr bgcolor="#ffffff"><td><a href="#NP_ARGUMENT_MIGHT_BE_NULL">NP: Méthode ne te
stant pas les paramètres à null</a></td><td>Correctness</td></tr> |
| 224 <tr bgcolor="#eeeeee"><td><a href="#NP_CLOSING_NULL">NP: close() invoked on a va
lue that is always null</a></td><td>Correctness</td></tr> |
| 225 <tr bgcolor="#ffffff"><td><a href="#NP_GUARANTEED_DEREF">NP: Null déréférencé</a
></td><td>Correctness</td></tr> |
| 226 <tr bgcolor="#eeeeee"><td><a href="#NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH">NP: V
alue is null and guaranteed to be dereferenced on exception path</a></td><td>Cor
rectness</td></tr> |
| 227 <tr bgcolor="#ffffff"><td><a href="#NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUC
TOR">NP: Nonnull field is not initialized</a></td><td>Correctness</td></tr> |
| 228 <tr bgcolor="#eeeeee"><td><a href="#NP_NONNULL_PARAM_VIOLATION">NP: Appel de mét
hode transmettant null à un paramètre déclaré @NonNull</a></td><td>Correctness</
td></tr> |
| 229 <tr bgcolor="#ffffff"><td><a href="#NP_NONNULL_RETURN_VIOLATION">NP: Méthode ren
voyer null mais déclarée @NonNull</a></td><td>Correctness</td></tr> |
| 230 <tr bgcolor="#eeeeee"><td><a href="#NP_NULL_INSTANCEOF">NP: A known null value i
s checked to see if it is an instance of a type</a></td><td>Correctness</td></tr
> |
| 231 <tr bgcolor="#ffffff"><td><a href="#NP_NULL_ON_SOME_PATH">NP: Possible déréféren
cement d'un pointeur null dans une méthode</a></td><td>Correctness</td></tr> |
| 232 <tr bgcolor="#eeeeee"><td><a href="#NP_NULL_ON_SOME_PATH_EXCEPTION">NP: Possible
déréférencement d'un pointeur null dans le chemin d'exception d'une méthode</a>
</td><td>Correctness</td></tr> |
| 233 <tr bgcolor="#ffffff"><td><a href="#NP_NULL_PARAM_DEREF">NP: Méthode passant nul
l à un paramètre déréférencé inconditionnellement</a></td><td>Correctness</td></
tr> |
| 234 <tr bgcolor="#eeeeee"><td><a href="#NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS">N
P: Appel de méthode passant null à un paramètre déréférencé inconditionnellement
</a></td><td>Correctness</td></tr> |
| 235 <tr bgcolor="#ffffff"><td><a href="#NP_NULL_PARAM_DEREF_NONVIRTUAL">NP: Appel à
une méthode non virtuelle passant null à un paramètre déréférencé de façon incon
ditionnelle</a></td><td>Correctness</td></tr> |
| 236 <tr bgcolor="#eeeeee"><td><a href="#NP_OPTIONAL_RETURN_NULL">NP: Method with Opt
ional return type returns explicit null</a></td><td>Correctness</td></tr> |
| 237 <tr bgcolor="#ffffff"><td><a href="#NP_STORE_INTO_NONNULL_FIELD">NP: Stocke une
valeur null dans un champ annoté NonNull</a></td><td>Correctness</td></tr> |
| 238 <tr bgcolor="#eeeeee"><td><a href="#NP_UNWRITTEN_FIELD">NP: Lecture d'un champ j
amais écrit</a></td><td>Correctness</td></tr> |
| 239 <tr bgcolor="#ffffff"><td><a href="#NM_BAD_EQUAL">Nm: La classe définit equal()
; ne devrait-ce pas être equals() ?</a></td><td>Correctness</td></tr> |
| 240 <tr bgcolor="#eeeeee"><td><a href="#NM_LCASE_HASHCODE">Nm: La classe définit has
hcode() ; ne devrait-ce pas être hashCode() ?</a></td><td>Correctness</td></tr> |
| 241 <tr bgcolor="#ffffff"><td><a href="#NM_LCASE_TOSTRING">Nm: La classe définit tos
tring() ; ne devrait-ce pas être toString() ?</a></td><td>Correctness</td></tr> |
| 242 <tr bgcolor="#eeeeee"><td><a href="#NM_METHOD_CONSTRUCTOR_CONFUSION">Nm: Confusi
on apparente entre une méthode et un constructeur</a></td><td>Correctness</td></
tr> |
| 243 <tr bgcolor="#ffffff"><td><a href="#NM_VERY_CONFUSING">Nm: Noms de méthodes très
ambigus</a></td><td>Correctness</td></tr> |
| 244 <tr bgcolor="#eeeeee"><td><a href="#NM_WRONG_PACKAGE">Nm: Method doesn't overrid
e method in superclass due to wrong package for parameter</a></td><td>Correctnes
s</td></tr> |
| 245 <tr bgcolor="#ffffff"><td><a href="#QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT">QBA: Mé
thode assignant une valeur boléenne fixe dans une expression booléenne</a></td><
td>Correctness</td></tr> |
| 246 <tr bgcolor="#eeeeee"><td><a href="#RC_REF_COMPARISON">RC: Comparaison de référe
nces suspecte</a></td><td>Correctness</td></tr> |
| 247 <tr bgcolor="#ffffff"><td><a href="#RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NP
E">RCN: Test de nullité d'une valeur préalablement déréférencée</a></td><td>Corr
ectness</td></tr> |
| 248 <tr bgcolor="#eeeeee"><td><a href="#RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION">RE: Sy
ntaxe d'expression régulière invalide</a></td><td>Correctness</td></tr> |
| 249 <tr bgcolor="#ffffff"><td><a href="#RE_CANT_USE_FILE_SEPARATOR_AS_REGULAR_EXPRES
SION">RE: File.separator used for regular expression</a></td><td>Correctness</td
></tr> |
| 250 <tr bgcolor="#eeeeee"><td><a href="#RE_POSSIBLE_UNINTENDED_PATTERN">RE: "." util
isé dans une expression régulière</a></td><td>Correctness</td></tr> |
| 251 <tr bgcolor="#ffffff"><td><a href="#RV_01_TO_INT">RV: Les valeurs aléatoires ent
re 0 et 1 sont réduites à l'entier 0</a></td><td>Correctness</td></tr> |
| 252 <tr bgcolor="#eeeeee"><td><a href="#RV_ABSOLUTE_VALUE_OF_HASHCODE">RV: Bad attem
pt to compute absolute value of signed 32-bit hashcode </a></td><td>Correctness<
/td></tr> |
| 253 <tr bgcolor="#ffffff"><td><a href="#RV_ABSOLUTE_VALUE_OF_RANDOM_INT">RV: Bad att
empt to compute absolute value of signed random integer</a></td><td>Correctness<
/td></tr> |
| 254 <tr bgcolor="#eeeeee"><td><a href="#RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE
">RV: Code checks for specific values returned by compareTo</a></td><td>Correctn
ess</td></tr> |
| 255 <tr bgcolor="#ffffff"><td><a href="#RV_EXCEPTION_NOT_THROWN">RV: Exception creat
ed and dropped rather than thrown</a></td><td>Correctness</td></tr> |
| 256 <tr bgcolor="#eeeeee"><td><a href="#RV_RETURN_VALUE_IGNORED">RV: La méthode igno
re une valeur de retour</a></td><td>Correctness</td></tr> |
| 257 <tr bgcolor="#ffffff"><td><a href="#RpC_REPEATED_CONDITIONAL_TEST">RpC: Repeated
conditional tests</a></td><td>Correctness</td></tr> |
| 258 <tr bgcolor="#eeeeee"><td><a href="#SA_FIELD_SELF_ASSIGNMENT">SA: Auto-alimentat
ion d'un champs</a></td><td>Correctness</td></tr> |
| 259 <tr bgcolor="#ffffff"><td><a href="#SA_FIELD_SELF_COMPARISON">SA: Self compariso
n of field with itself</a></td><td>Correctness</td></tr> |
| 260 <tr bgcolor="#eeeeee"><td><a href="#SA_FIELD_SELF_COMPUTATION">SA: Nonsensical s
elf computation involving a field (e.g., x & x)</a></td><td>Correctness</td></tr
> |
| 261 <tr bgcolor="#ffffff"><td><a href="#SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD">S
A: Self assignment of local rather than assignment to field</a></td><td>Correctn
ess</td></tr> |
| 262 <tr bgcolor="#eeeeee"><td><a href="#SA_LOCAL_SELF_COMPARISON">SA: Self compariso
n of value with itself</a></td><td>Correctness</td></tr> |
| 263 <tr bgcolor="#ffffff"><td><a href="#SA_LOCAL_SELF_COMPUTATION">SA: Nonsensical s
elf computation involving a variable (e.g., x & x)</a></td><td>Correctness</td><
/tr> |
| 264 <tr bgcolor="#eeeeee"><td><a href="#SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH">SF:
Dead store due to switch statement fall through</a></td><td>Correctness</td></t
r> |
| 265 <tr bgcolor="#ffffff"><td><a href="#SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_T
HROW">SF: Dead store due to switch statement fall through to throw</a></td><td>C
orrectness</td></tr> |
| 266 <tr bgcolor="#eeeeee"><td><a href="#SIC_THREADLOCAL_DEADLY_EMBRACE">SIC: Deadly
embrace of non-static inner class and thread local</a></td><td>Correctness</td><
/tr> |
| 267 <tr bgcolor="#ffffff"><td><a href="#SIO_SUPERFLUOUS_INSTANCEOF">SIO: Vérificatio
n de type inutile avec l'opérateur instanceof</a></td><td>Correctness</td></tr> |
| 268 <tr bgcolor="#eeeeee"><td><a href="#SQL_BAD_PREPARED_STATEMENT_ACCESS">SQL: Méth
ode essayant au paramêtre d'indice 0 d'un PreparedStatement</a></td><td>Correctn
ess</td></tr> |
| 269 <tr bgcolor="#ffffff"><td><a href="#SQL_BAD_RESULTSET_ACCESS">SQL: Méthode essay
ant d'accèder à un champ de ResultSet d'indice 0</a></td><td>Correctness</td></t
r> |
| 270 <tr bgcolor="#eeeeee"><td><a href="#STI_INTERRUPTED_ON_CURRENTTHREAD">STI: Utili
sation superflue d'un appel à currentThread() pour appeler interrupted()</a></td
><td>Correctness</td></tr> |
| 271 <tr bgcolor="#ffffff"><td><a href="#STI_INTERRUPTED_ON_UNKNOWNTHREAD">STI: Threa
d.interrupted() appelée par erreur sur un objet Thread arbitraire</a></td><td>Co
rrectness</td></tr> |
| 272 <tr bgcolor="#eeeeee"><td><a href="#SE_METHOD_MUST_BE_PRIVATE">Se: Méthode devan
t être privée pour que la sérialisation fonctionne</a></td><td>Correctness</td><
/tr> |
| 273 <tr bgcolor="#ffffff"><td><a href="#SE_READ_RESOLVE_IS_STATIC">Se: The readResol
ve method must not be declared as a static method. </a></td><td>Correctness</td
></tr> |
| 274 <tr bgcolor="#eeeeee"><td><a href="#TQ_ALWAYS_VALUE_USED_WHERE_NEVER_REQUIRED">T
Q: Value annotated as carrying a type qualifier used where a value that must not
carry that qualifier is required</a></td><td>Correctness</td></tr> |
| 275 <tr bgcolor="#ffffff"><td><a href="#TQ_COMPARING_VALUES_WITH_INCOMPATIBLE_TYPE_Q
UALIFIERS">TQ: Comparing values with incompatible type qualifiers</a></td><td>Co
rrectness</td></tr> |
| 276 <tr bgcolor="#eeeeee"><td><a href="#TQ_MAYBE_SOURCE_VALUE_REACHES_ALWAYS_SINK">T
Q: Value that might not carry a type qualifier is always used in a way requires
that type qualifier</a></td><td>Correctness</td></tr> |
| 277 <tr bgcolor="#ffffff"><td><a href="#TQ_MAYBE_SOURCE_VALUE_REACHES_NEVER_SINK">TQ
: Value that might carry a type qualifier is always used in a way prohibits it f
rom having that type qualifier</a></td><td>Correctness</td></tr> |
| 278 <tr bgcolor="#eeeeee"><td><a href="#TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED">T
Q: Value annotated as never carrying a type qualifier used where value carrying
that qualifier is required</a></td><td>Correctness</td></tr> |
| 279 <tr bgcolor="#ffffff"><td><a href="#TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_
REQUIRED">TQ: Value without a type qualifier used where a value is required to h
ave that qualifier</a></td><td>Correctness</td></tr> |
| 280 <tr bgcolor="#eeeeee"><td><a href="#UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS">U
MAC: Méthode non appelable définie dans une classe anonyme</a></td><td>Correctne
ss</td></tr> |
| 281 <tr bgcolor="#ffffff"><td><a href="#UR_UNINIT_READ">UR: Lecture d'un champ non i
nitialisé dans un constructeur</a></td><td>Correctness</td></tr> |
| 282 <tr bgcolor="#eeeeee"><td><a href="#UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR
">UR: Uninitialized read of field method called from constructor of superclass</
a></td><td>Correctness</td></tr> |
| 283 <tr bgcolor="#ffffff"><td><a href="#DMI_INVOKING_TOSTRING_ON_ANONYMOUS_ARRAY">US
ELESS_STRING: Invocation of toString on an unnamed array</a></td><td>Correctness
</td></tr> |
| 284 <tr bgcolor="#eeeeee"><td><a href="#DMI_INVOKING_TOSTRING_ON_ARRAY">USELESS_STRI
NG: Invocation de toString sur un tableau</a></td><td>Correctness</td></tr> |
| 285 <tr bgcolor="#ffffff"><td><a href="#VA_FORMAT_STRING_BAD_CONVERSION_FROM_ARRAY">
USELESS_STRING: Array formatted in useless way using format string</a></td><td>C
orrectness</td></tr> |
| 286 <tr bgcolor="#eeeeee"><td><a href="#UWF_NULL_FIELD">UwF: Champ uniquement mis à
null</a></td><td>Correctness</td></tr> |
| 287 <tr bgcolor="#ffffff"><td><a href="#UWF_UNWRITTEN_FIELD">UwF: Champ jamais écrit
</a></td><td>Correctness</td></tr> |
| 288 <tr bgcolor="#eeeeee"><td><a href="#VA_PRIMITIVE_ARRAY_PASSED_TO_OBJECT_VARARG">
VA: Tableau de primitives passé à une fonction attendant un nombre variable d'ob
jets en argument</a></td><td>Correctness</td></tr> |
| 289 <tr bgcolor="#ffffff"><td><a href="#LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE">LG: Po
tential lost logger changes due to weak reference in OpenJDK</a></td><td>Experim
ental</td></tr> |
| 290 <tr bgcolor="#eeeeee"><td><a href="#OBL_UNSATISFIED_OBLIGATION">OBL: Method may
fail to clean up stream or resource</a></td><td>Experimental</td></tr> |
| 291 <tr bgcolor="#ffffff"><td><a href="#OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE">O
BL: Method may fail to clean up stream or resource on checked exception</a></td>
<td>Experimental</td></tr> |
| 292 <tr bgcolor="#eeeeee"><td><a href="#DM_CONVERT_CASE">Dm: La méthode appelle les
String.toUpperCase() ou String.toLowerCase ; utilisez plutôt la version paramètr
ée par une Locale</a></td><td>Internationalization</td></tr> |
| 293 <tr bgcolor="#ffffff"><td><a href="#DM_DEFAULT_ENCODING">Dm: Reliance on default
encoding</a></td><td>Internationalization</td></tr> |
| 294 <tr bgcolor="#eeeeee"><td><a href="#DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED">
DP: Les chargeurs de classes ne doivent être créés qu'à partir de block doPrivil
eged</a></td><td>Malicious code vulnerability</td></tr> |
| 295 <tr bgcolor="#ffffff"><td><a href="#DP_DO_INSIDE_DO_PRIVILEGED">DP: Méthode invo
quée alors qu'elle ne devrait l'être qu'à partir d'un block doPrivileged</a></td
><td>Malicious code vulnerability</td></tr> |
| 296 <tr bgcolor="#eeeeee"><td><a href="#EI_EXPOSE_REP">EI: Une méthode peut exposer
sa représentation interne en renvoyant une référence à un objet modifiable</a></
td><td>Malicious code vulnerability</td></tr> |
| 297 <tr bgcolor="#ffffff"><td><a href="#EI_EXPOSE_REP2">EI2: Une méthode expose sa r
eprésentation interne en incorporant une référence à un objet modifiable</a></td
><td>Malicious code vulnerability</td></tr> |
| 298 <tr bgcolor="#eeeeee"><td><a href="#FI_PUBLIC_SHOULD_BE_PROTECTED">FI: Un finali
seur devrait être protégé, pas public</a></td><td>Malicious code vulnerability</
td></tr> |
| 299 <tr bgcolor="#ffffff"><td><a href="#EI_EXPOSE_STATIC_REP2">MS: Une méthode peut
exposer un état interne statique en stockant un objet modifiable dans un champs
statique</a></td><td>Malicious code vulnerability</td></tr> |
| 300 <tr bgcolor="#eeeeee"><td><a href="#MS_CANNOT_BE_FINAL">MS: Un champ n'est pas f
inal et ne peut pas être protégé face à du code malveillant</a></td><td>Maliciou
s code vulnerability</td></tr> |
| 301 <tr bgcolor="#ffffff"><td><a href="#MS_EXPOSE_REP">MS: Une méthode statique publ
ique risque d'exposer une représentation interne en renvoyant un tableau</a></td
><td>Malicious code vulnerability</td></tr> |
| 302 <tr bgcolor="#eeeeee"><td><a href="#MS_FINAL_PKGPROTECT">MS: Le champ devrait êt
re à la fois final et package protected</a></td><td>Malicious code vulnerability
</td></tr> |
| 303 <tr bgcolor="#ffffff"><td><a href="#MS_MUTABLE_ARRAY">MS: Un champ est un tablea
u modifiable</a></td><td>Malicious code vulnerability</td></tr> |
| 304 <tr bgcolor="#eeeeee"><td><a href="#MS_MUTABLE_HASHTABLE">MS: Un champ modifiabl
e est une Hashtable</a></td><td>Malicious code vulnerability</td></tr> |
| 305 <tr bgcolor="#ffffff"><td><a href="#MS_OOI_PKGPROTECT">MS: Le champ devrait être
sorti de l'interface et mis en package protected</a></td><td>Malicious code vul
nerability</td></tr> |
| 306 <tr bgcolor="#eeeeee"><td><a href="#MS_PKGPROTECT">MS: Un champ devrait être pac
kage protected</a></td><td>Malicious code vulnerability</td></tr> |
| 307 <tr bgcolor="#ffffff"><td><a href="#MS_SHOULD_BE_FINAL">MS: Un champ n'est pas f
inal alors qu'il devrait l'être</a></td><td>Malicious code vulnerability</td></t
r> |
| 308 <tr bgcolor="#eeeeee"><td><a href="#MS_SHOULD_BE_REFACTORED_TO_BE_FINAL">MS: Fie
ld isn't final but should be refactored to be so</a></td><td>Malicious code vuln
erability</td></tr> |
| 309 <tr bgcolor="#ffffff"><td><a href="#AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACT
ION">AT: Sequence of calls to concurrent abstraction may not be atomic</a></td><
td>Multithreaded correctness</td></tr> |
| 310 <tr bgcolor="#eeeeee"><td><a href="#DC_DOUBLECHECK">DC: Possible double vérifica
tion d'un champ</a></td><td>Multithreaded correctness</td></tr> |
| 311 <tr bgcolor="#ffffff"><td><a href="#DL_SYNCHRONIZATION_ON_BOOLEAN">DL: Synchroni
zation on Boolean</a></td><td>Multithreaded correctness</td></tr> |
| 312 <tr bgcolor="#eeeeee"><td><a href="#DL_SYNCHRONIZATION_ON_BOXED_PRIMITIVE">DL: S
ynchronization on boxed primitive</a></td><td>Multithreaded correctness</td></tr
> |
| 313 <tr bgcolor="#ffffff"><td><a href="#DL_SYNCHRONIZATION_ON_SHARED_CONSTANT">DL: S
ynchronization on interned String </a></td><td>Multithreaded correctness</td></t
r> |
| 314 <tr bgcolor="#eeeeee"><td><a href="#DL_SYNCHRONIZATION_ON_UNSHARED_BOXED_PRIMITI
VE">DL: Synchronization on boxed primitive values</a></td><td>Multithreaded corr
ectness</td></tr> |
| 315 <tr bgcolor="#ffffff"><td><a href="#DM_MONITOR_WAIT_ON_CONDITION">Dm: Wait() app
elé sur une Condition</a></td><td>Multithreaded correctness</td></tr> |
| 316 <tr bgcolor="#eeeeee"><td><a href="#DM_USELESS_THREAD">Dm: Thread créé avec la m
éthode run vide par défaut</a></td><td>Multithreaded correctness</td></tr> |
| 317 <tr bgcolor="#ffffff"><td><a href="#ESync_EMPTY_SYNC">ESync: Bloc synchronisé vi
de</a></td><td>Multithreaded correctness</td></tr> |
| 318 <tr bgcolor="#eeeeee"><td><a href="#IS2_INCONSISTENT_SYNC">IS: Synchronisation i
ncohérente</a></td><td>Multithreaded correctness</td></tr> |
| 319 <tr bgcolor="#ffffff"><td><a href="#IS_FIELD_NOT_GUARDED">IS: Champ non protégé
contre les accès concurrents</a></td><td>Multithreaded correctness</td></tr> |
| 320 <tr bgcolor="#eeeeee"><td><a href="#JLM_JSR166_LOCK_MONITORENTER">JLM: Synchroni
sation effectuée sur un Lock java.util.concurrent</a></td><td>Multithreaded corr
ectness</td></tr> |
| 321 <tr bgcolor="#ffffff"><td><a href="#JLM_JSR166_UTILCONCURRENT_MONITORENTER">JLM:
Synchronization performed on util.concurrent instance</a></td><td>Multithreaded
correctness</td></tr> |
| 322 <tr bgcolor="#eeeeee"><td><a href="#JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT">J
LM: Using monitor style wait methods on util.concurrent abstraction</a></td><td>
Multithreaded correctness</td></tr> |
| 323 <tr bgcolor="#ffffff"><td><a href="#LI_LAZY_INIT_STATIC">LI: Initialisation pare
sseuse incorrecte d'un champ statique</a></td><td>Multithreaded correctness</td>
</tr> |
| 324 <tr bgcolor="#eeeeee"><td><a href="#LI_LAZY_INIT_UPDATE_STATIC">LI: Incorrect la
zy initialization and update of static field</a></td><td>Multithreaded correctne
ss</td></tr> |
| 325 <tr bgcolor="#ffffff"><td><a href="#ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIEL
D">ML: Synchronization on field in futile attempt to guard that field</a></td><t
d>Multithreaded correctness</td></tr> |
| 326 <tr bgcolor="#eeeeee"><td><a href="#ML_SYNC_ON_UPDATED_FIELD">ML: La méthode se
synchronise sur un champ mis à jour</a></td><td>Multithreaded correctness</td></
tr> |
| 327 <tr bgcolor="#ffffff"><td><a href="#MSF_MUTABLE_SERVLET_FIELD">MSF: Mutable serv
let field</a></td><td>Multithreaded correctness</td></tr> |
| 328 <tr bgcolor="#eeeeee"><td><a href="#MWN_MISMATCHED_NOTIFY">MWN: notify() non app
areillé</a></td><td>Multithreaded correctness</td></tr> |
| 329 <tr bgcolor="#ffffff"><td><a href="#MWN_MISMATCHED_WAIT">MWN: wait() non apparei
llé</a></td><td>Multithreaded correctness</td></tr> |
| 330 <tr bgcolor="#eeeeee"><td><a href="#NN_NAKED_NOTIFY">NN: Appel notify() isolé da
ns une méthode</a></td><td>Multithreaded correctness</td></tr> |
| 331 <tr bgcolor="#ffffff"><td><a href="#NP_SYNC_AND_NULL_CHECK_FIELD">NP: Synchroniz
e and null check on the same field.</a></td><td>Multithreaded correctness</td></
tr> |
| 332 <tr bgcolor="#eeeeee"><td><a href="#NO_NOTIFY_NOT_NOTIFYALL">No: Utilisation de
notify() plutôt que notifyAll() dans une méthode</a></td><td>Multithreaded corre
ctness</td></tr> |
| 333 <tr bgcolor="#ffffff"><td><a href="#RS_READOBJECT_SYNC">RS: Seule la méthode rea
dObject() est synchronisée</a></td><td>Multithreaded correctness</td></tr> |
| 334 <tr bgcolor="#eeeeee"><td><a href="#RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED">RV:
Return value of putIfAbsent ignored, value passed to putIfAbsent reused</a></td>
<td>Multithreaded correctness</td></tr> |
| 335 <tr bgcolor="#ffffff"><td><a href="#RU_INVOKE_RUN">Ru: Invocation de run() sur u
n thread (Vouliez-vous plutôt dire start() ?)</a></td><td>Multithreaded correctn
ess</td></tr> |
| 336 <tr bgcolor="#eeeeee"><td><a href="#SC_START_IN_CTOR">SC: Un constructeur invoqu
e Thread.start()</a></td><td>Multithreaded correctness</td></tr> |
| 337 <tr bgcolor="#ffffff"><td><a href="#SP_SPIN_ON_FIELD">SP: Méthode bouclant sur u
n champ</a></td><td>Multithreaded correctness</td></tr> |
| 338 <tr bgcolor="#eeeeee"><td><a href="#STCAL_INVOKE_ON_STATIC_CALENDAR_INSTANCE">ST
CAL: Call to static Calendar</a></td><td>Multithreaded correctness</td></tr> |
| 339 <tr bgcolor="#ffffff"><td><a href="#STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE"
>STCAL: Call to static DateFormat</a></td><td>Multithreaded correctness</td></tr
> |
| 340 <tr bgcolor="#eeeeee"><td><a href="#STCAL_STATIC_CALENDAR_INSTANCE">STCAL: Stati
c Calendar field</a></td><td>Multithreaded correctness</td></tr> |
| 341 <tr bgcolor="#ffffff"><td><a href="#STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE">ST
CAL: Static DateFormat</a></td><td>Multithreaded correctness</td></tr> |
| 342 <tr bgcolor="#eeeeee"><td><a href="#SWL_SLEEP_WITH_LOCK_HELD">SWL: Appel de la m
éthode Thread.sleep() avec un verrou</a></td><td>Multithreaded correctness</td><
/tr> |
| 343 <tr bgcolor="#ffffff"><td><a href="#TLW_TWO_LOCK_WAIT">TLW: wait() avec deux ver
rous en attente</a></td><td>Multithreaded correctness</td></tr> |
| 344 <tr bgcolor="#eeeeee"><td><a href="#UG_SYNC_SET_UNSYNC_GET">UG: Méthode getXXX n
on synchronisée, méthode setXXX synchronisée</a></td><td>Multithreaded correctne
ss</td></tr> |
| 345 <tr bgcolor="#ffffff"><td><a href="#UL_UNRELEASED_LOCK">UL: La méthode ne libère
pas un verrou dans tous les chemins d'exécution</a></td><td>Multithreaded corre
ctness</td></tr> |
| 346 <tr bgcolor="#eeeeee"><td><a href="#UL_UNRELEASED_LOCK_EXCEPTION_PATH">UL: La mé
thode ne libère pas un verrou dans tous les chemins d'exception</a></td><td>Mult
ithreaded correctness</td></tr> |
| 347 <tr bgcolor="#ffffff"><td><a href="#UW_UNCOND_WAIT">UW: Méthode contenant un wai
t() non conditionné</a></td><td>Multithreaded correctness</td></tr> |
| 348 <tr bgcolor="#eeeeee"><td><a href="#VO_VOLATILE_INCREMENT">VO: An increment to a
volatile field isn't atomic</a></td><td>Multithreaded correctness</td></tr> |
| 349 <tr bgcolor="#ffffff"><td><a href="#VO_VOLATILE_REFERENCE_TO_ARRAY">VO: Une réfé
rence volatile à un tableau ne traite pas les éléments du tableau comme volatile
s</a></td><td>Multithreaded correctness</td></tr> |
| 350 <tr bgcolor="#eeeeee"><td><a href="#WL_USING_GETCLASS_RATHER_THAN_CLASS_LITERAL"
>WL: Synchronization on getClass rather than class literal</a></td><td>Multithre
aded correctness</td></tr> |
| 351 <tr bgcolor="#ffffff"><td><a href="#WS_WRITEOBJECT_SYNC">WS: Seule la méthode wr
iteObject() est synchronisée</a></td><td>Multithreaded correctness</td></tr> |
| 352 <tr bgcolor="#eeeeee"><td><a href="#WA_AWAIT_NOT_IN_LOOP">Wa: Condition.await()
en dehors d'une boucle</a></td><td>Multithreaded correctness</td></tr> |
| 353 <tr bgcolor="#ffffff"><td><a href="#WA_NOT_IN_LOOP">Wa: Méthode contenant un wai
t() en dehors d'une boucle</a></td><td>Multithreaded correctness</td></tr> |
| 354 <tr bgcolor="#eeeeee"><td><a href="#BX_BOXING_IMMEDIATELY_UNBOXED">Bx: Primitive
value is boxed and then immediately unboxed</a></td><td>Performance</td></tr> |
| 355 <tr bgcolor="#ffffff"><td><a href="#BX_BOXING_IMMEDIATELY_UNBOXED_TO_PERFORM_COE
RCION">Bx: Primitive value is boxed then unboxed to perform primitive coercion</
a></td><td>Performance</td></tr> |
| 356 <tr bgcolor="#eeeeee"><td><a href="#BX_UNBOXING_IMMEDIATELY_REBOXED">Bx: Boxed v
alue is unboxed and then immediately reboxed</a></td><td>Performance</td></tr> |
| 357 <tr bgcolor="#ffffff"><td><a href="#DM_BOXED_PRIMITIVE_FOR_PARSING">Bx: Boxing/u
nboxing to parse a primitive</a></td><td>Performance</td></tr> |
| 358 <tr bgcolor="#eeeeee"><td><a href="#DM_BOXED_PRIMITIVE_TOSTRING">Bx: Méthode all
ouant une primitive boxed pour appeler toString</a></td><td>Performance</td></tr
> |
| 359 <tr bgcolor="#ffffff"><td><a href="#DM_FP_NUMBER_CTOR">Bx: Method invokes ineffi
cient floating-point Number constructor; use static valueOf instead</a></td><td>
Performance</td></tr> |
| 360 <tr bgcolor="#eeeeee"><td><a href="#DM_NUMBER_CTOR">Bx: Method invokes inefficie
nt Number constructor; use static valueOf instead</a></td><td>Performance</td></
tr> |
| 361 <tr bgcolor="#ffffff"><td><a href="#DMI_BLOCKING_METHODS_ON_URL">Dm: The equals
and hashCode methods of URL are blocking</a></td><td>Performance</td></tr> |
| 362 <tr bgcolor="#eeeeee"><td><a href="#DMI_COLLECTION_OF_URLS">Dm: Maps and sets of
URLs can be performance hogs</a></td><td>Performance</td></tr> |
| 363 <tr bgcolor="#ffffff"><td><a href="#DM_BOOLEAN_CTOR">Dm: La méthode invoque le c
onstructeur inutile Boolean() ; utilisez Boolean.valueOf(...) à la place</a></td
><td>Performance</td></tr> |
| 364 <tr bgcolor="#eeeeee"><td><a href="#DM_GC">Dm: Ramasse-miettes explicite ; extrê
mement douteux sauf dans du code de banc d'essai</a></td><td>Performance</td></t
r> |
| 365 <tr bgcolor="#ffffff"><td><a href="#DM_NEW_FOR_GETCLASS">Dm: Méthode allouant un
objet juste pour obtenir la classe</a></td><td>Performance</td></tr> |
| 366 <tr bgcolor="#eeeeee"><td><a href="#DM_NEXTINT_VIA_NEXTDOUBLE">Dm: Utiliser la m
éthode nextInt de Random plutôt que nextDouble pour générer un entier aléatoire<
/a></td><td>Performance</td></tr> |
| 367 <tr bgcolor="#ffffff"><td><a href="#DM_STRING_CTOR">Dm: La méthode invoque le co
nstructeur inutile String(String) ; utilisez juste l'argument</a></td><td>Perfor
mance</td></tr> |
| 368 <tr bgcolor="#eeeeee"><td><a href="#DM_STRING_TOSTRING">Dm: La méthode appel toS
tring() sur un objet String ; utilisez directement l'objet String</a></td><td>Pe
rformance</td></tr> |
| 369 <tr bgcolor="#ffffff"><td><a href="#DM_STRING_VOID_CTOR">Dm: La méthode invoque
le constructeur inutile String() ; utilisez juste ""</a></td><td>Performance</td
></tr> |
| 370 <tr bgcolor="#eeeeee"><td><a href="#HSC_HUGE_SHARED_STRING_CONSTANT">HSC: Huge s
tring constants is duplicated across multiple class files</a></td><td>Performanc
e</td></tr> |
| 371 <tr bgcolor="#ffffff"><td><a href="#IIO_INEFFICIENT_INDEX_OF">IIO: Inefficient u
se of String.indexOf(String)</a></td><td>Performance</td></tr> |
| 372 <tr bgcolor="#eeeeee"><td><a href="#IIO_INEFFICIENT_LAST_INDEX_OF">IIO: Ineffici
ent use of String.lastIndexOf(String)</a></td><td>Performance</td></tr> |
| 373 <tr bgcolor="#ffffff"><td><a href="#ITA_INEFFICIENT_TO_ARRAY">ITA: La méthode ut
ilise toArray() avec un tableau vide en paramètre</a></td><td>Performance</td></
tr> |
| 374 <tr bgcolor="#eeeeee"><td><a href="#SBSC_USE_STRINGBUFFER_CONCATENATION">SBSC: L
a méthode concatène des chaînes au moyen de + en boucle</a></td><td>Performance<
/td></tr> |
| 375 <tr bgcolor="#ffffff"><td><a href="#SIC_INNER_SHOULD_BE_STATIC">SIC: Devrait êtr
e une classe interne statique</a></td><td>Performance</td></tr> |
| 376 <tr bgcolor="#eeeeee"><td><a href="#SIC_INNER_SHOULD_BE_STATIC_ANON">SIC: Peut-ê
tre transformée en classe interne statique nommée</a></td><td>Performance</td></
tr> |
| 377 <tr bgcolor="#ffffff"><td><a href="#SIC_INNER_SHOULD_BE_STATIC_NEEDS_THIS">SIC:
Pourrait-être transformée en classe interne statique</a></td><td>Performance</td
></tr> |
| 378 <tr bgcolor="#eeeeee"><td><a href="#SS_SHOULD_BE_STATIC">SS: Champ non lu : devr
ait-il être statique ?</a></td><td>Performance</td></tr> |
| 379 <tr bgcolor="#ffffff"><td><a href="#UM_UNNECESSARY_MATH">UM: Appel d'une méthode
statique de la classe Math sur une valeur constante</a></td><td>Performance</td
></tr> |
| 380 <tr bgcolor="#eeeeee"><td><a href="#UPM_UNCALLED_PRIVATE_METHOD">UPM: Méthode pr
ivée jamais appelée</a></td><td>Performance</td></tr> |
| 381 <tr bgcolor="#ffffff"><td><a href="#URF_UNREAD_FIELD">UrF: Champ inutilisé</a></
td><td>Performance</td></tr> |
| 382 <tr bgcolor="#eeeeee"><td><a href="#UUF_UNUSED_FIELD">UuF: Champ inutilisé</a></
td><td>Performance</td></tr> |
| 383 <tr bgcolor="#ffffff"><td><a href="#WMI_WRONG_MAP_ITERATOR">WMI: Utilisation ine
fficace d'un itérateur sur keySet au lieu de entrySet</a></td><td>Performance</t
d></tr> |
| 384 <tr bgcolor="#eeeeee"><td><a href="#DMI_CONSTANT_DB_PASSWORD">Dm: Hardcoded cons
tant database password</a></td><td>Security</td></tr> |
| 385 <tr bgcolor="#ffffff"><td><a href="#DMI_EMPTY_DB_PASSWORD">Dm: Empty database pa
ssword</a></td><td>Security</td></tr> |
| 386 <tr bgcolor="#eeeeee"><td><a href="#HRS_REQUEST_PARAMETER_TO_COOKIE">HRS: HTTP c
ookie formed from untrusted input</a></td><td>Security</td></tr> |
| 387 <tr bgcolor="#ffffff"><td><a href="#HRS_REQUEST_PARAMETER_TO_HTTP_HEADER">HRS: H
TTP Response splitting vulnerability</a></td><td>Security</td></tr> |
| 388 <tr bgcolor="#eeeeee"><td><a href="#PT_ABSOLUTE_PATH_TRAVERSAL">PT: Absolute pat
h traversal in servlet</a></td><td>Security</td></tr> |
| 389 <tr bgcolor="#ffffff"><td><a href="#PT_RELATIVE_PATH_TRAVERSAL">PT: Relative pat
h traversal in servlet</a></td><td>Security</td></tr> |
| 390 <tr bgcolor="#eeeeee"><td><a href="#SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE">SQ
L: Une chaîne non constante est passée à la méthode execute d'une commande SQL</
a></td><td>Security</td></tr> |
| 391 <tr bgcolor="#ffffff"><td><a href="#SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCON
STANT_STRING">SQL: Une requète est préparée à partir d'une chaine non constante<
/a></td><td>Security</td></tr> |
| 392 <tr bgcolor="#eeeeee"><td><a href="#XSS_REQUEST_PARAMETER_TO_JSP_WRITER">XSS: JS
P reflected cross site scripting vulnerability</a></td><td>Security</td></tr> |
| 393 <tr bgcolor="#ffffff"><td><a href="#XSS_REQUEST_PARAMETER_TO_SEND_ERROR">XSS: Se
rvlet reflected cross site scripting vulnerability in error page</a></td><td>Sec
urity</td></tr> |
| 394 <tr bgcolor="#eeeeee"><td><a href="#XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER">XSS
: Servlet reflected cross site scripting vulnerability</a></td><td>Security</td>
</tr> |
| 395 <tr bgcolor="#ffffff"><td><a href="#BC_BAD_CAST_TO_ABSTRACT_COLLECTION">BC: Tran
stypage douteux d'un type Collection vers une classe abstraite</a></td><td>Dodgy
code</td></tr> |
| 396 <tr bgcolor="#eeeeee"><td><a href="#BC_BAD_CAST_TO_CONCRETE_COLLECTION">BC: Tran
stypage douteux vers une collection concrète</a></td><td>Dodgy code</td></tr> |
| 397 <tr bgcolor="#ffffff"><td><a href="#BC_UNCONFIRMED_CAST">BC: Transtypage non vér
ifié/non confirmé</a></td><td>Dodgy code</td></tr> |
| 398 <tr bgcolor="#eeeeee"><td><a href="#BC_UNCONFIRMED_CAST_OF_RETURN_VALUE">BC: Unc
hecked/unconfirmed cast of return value from method</a></td><td>Dodgy code</td><
/tr> |
| 399 <tr bgcolor="#ffffff"><td><a href="#BC_VACUOUS_INSTANCEOF">BC: instanceof renver
ra toujours vrai</a></td><td>Dodgy code</td></tr> |
| 400 <tr bgcolor="#eeeeee"><td><a href="#ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT">BSH
IFT: Décalage à droite non signé et transtypage short/byte</a></td><td>Dodgy cod
e</td></tr> |
| 401 <tr bgcolor="#ffffff"><td><a href="#CI_CONFUSED_INHERITANCE">CI: Classe finale d
éclarant un champ protégé</a></td><td>Dodgy code</td></tr> |
| 402 <tr bgcolor="#eeeeee"><td><a href="#DB_DUPLICATE_BRANCHES">DB: Méthode utilsant
le même code pour deux branches</a></td><td>Dodgy code</td></tr> |
| 403 <tr bgcolor="#ffffff"><td><a href="#DB_DUPLICATE_SWITCH_CLAUSES">DB: Méthode uti
lisant le même code pour deux clauses switch</a></td><td>Dodgy code</td></tr> |
| 404 <tr bgcolor="#eeeeee"><td><a href="#DLS_DEAD_LOCAL_STORE">DLS: Alimentation à pe
rte d'une variable locale</a></td><td>Dodgy code</td></tr> |
| 405 <tr bgcolor="#ffffff"><td><a href="#DLS_DEAD_LOCAL_STORE_IN_RETURN">DLS: Useless
assignment in return statement</a></td><td>Dodgy code</td></tr> |
| 406 <tr bgcolor="#eeeeee"><td><a href="#DLS_DEAD_LOCAL_STORE_OF_NULL">DLS: Alimentat
ion à null d'une variable</a></td><td>Dodgy code</td></tr> |
| 407 <tr bgcolor="#ffffff"><td><a href="#DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD">DLS: Dea
d store to local variable that shadows field</a></td><td>Dodgy code</td></tr> |
| 408 <tr bgcolor="#eeeeee"><td><a href="#DMI_HARDCODED_ABSOLUTE_FILENAME">DMI: Chemin
absolu codé en dur dans le code</a></td><td>Dodgy code</td></tr> |
| 409 <tr bgcolor="#ffffff"><td><a href="#DMI_NONSERIALIZABLE_OBJECT_WRITTEN">DMI: Obj
et non sérialisable écrit dans un ObjectOutput</a></td><td>Dodgy code</td></tr> |
| 410 <tr bgcolor="#eeeeee"><td><a href="#DMI_USELESS_SUBSTRING">DMI: Appel de substri
ng(0) qui retourne la valeur originale</a></td><td>Dodgy code</td></tr> |
| 411 <tr bgcolor="#ffffff"><td><a href="#DMI_THREAD_PASSED_WHERE_RUNNABLE_EXPECTED">D
m: Thread passed where Runnable expected</a></td><td>Dodgy code</td></tr> |
| 412 <tr bgcolor="#eeeeee"><td><a href="#EQ_DOESNT_OVERRIDE_EQUALS">Eq: Class doesn't
override equals in superclass</a></td><td>Dodgy code</td></tr> |
| 413 <tr bgcolor="#ffffff"><td><a href="#EQ_UNUSUAL">Eq: Unusual equals method </a></
td><td>Dodgy code</td></tr> |
| 414 <tr bgcolor="#eeeeee"><td><a href="#FE_FLOATING_POINT_EQUALITY">FE: Test d'égali
té en virgule flottante.</a></td><td>Dodgy code</td></tr> |
| 415 <tr bgcolor="#ffffff"><td><a href="#VA_FORMAT_STRING_BAD_CONVERSION_TO_BOOLEAN">
FS: Non-Boolean argument formatted using %b format specifier</a></td><td>Dodgy c
ode</td></tr> |
| 416 <tr bgcolor="#eeeeee"><td><a href="#IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTE
R_METHOD">IA: Appel ambigu d'une méthode hérité ou externe</a></td><td>Dodgy cod
e</td></tr> |
| 417 <tr bgcolor="#ffffff"><td><a href="#IC_INIT_CIRCULARITY">IC: Initialisation circ
ulaire</a></td><td>Dodgy code</td></tr> |
| 418 <tr bgcolor="#eeeeee"><td><a href="#ICAST_IDIV_CAST_TO_DOUBLE">ICAST: Résultat d
'une division entière transtypé en nombre flottant</a></td><td>Dodgy code</td></
tr> |
| 419 <tr bgcolor="#ffffff"><td><a href="#ICAST_INTEGER_MULTIPLY_CAST_TO_LONG">ICAST:
Résultat d'une multiplication entière transtypée en long</a></td><td>Dodgy code<
/td></tr> |
| 420 <tr bgcolor="#eeeeee"><td><a href="#IM_AVERAGE_COMPUTATION_COULD_OVERFLOW">IM: P
ossibilité de débordement du calcul d'une moyenne</a></td><td>Dodgy code</td></t
r> |
| 421 <tr bgcolor="#ffffff"><td><a href="#IM_BAD_CHECK_FOR_ODD">IM: Test d'impaire ne
fonctionnant pas avec les négatifs</a></td><td>Dodgy code</td></tr> |
| 422 <tr bgcolor="#eeeeee"><td><a href="#INT_BAD_REM_BY_1">INT: Reste entier modulo 1
</a></td><td>Dodgy code</td></tr> |
| 423 <tr bgcolor="#ffffff"><td><a href="#INT_VACUOUS_BIT_OPERATION">INT: Vacuous bit
mask operation on integer value</a></td><td>Dodgy code</td></tr> |
| 424 <tr bgcolor="#eeeeee"><td><a href="#INT_VACUOUS_COMPARISON">INT: Comparaison inu
tile de valeurs entières</a></td><td>Dodgy code</td></tr> |
| 425 <tr bgcolor="#ffffff"><td><a href="#MTIA_SUSPECT_SERVLET_INSTANCE_FIELD">MTIA: L
a classe hérite de Servlet et utilise les variables de l'instance.</a></td><td>D
odgy code</td></tr> |
| 426 <tr bgcolor="#eeeeee"><td><a href="#MTIA_SUSPECT_STRUTS_INSTANCE_FIELD">MTIA: La
classe hérite d'une classe action Struts et utilise les variables de l'instance
.</a></td><td>Dodgy code</td></tr> |
| 427 <tr bgcolor="#ffffff"><td><a href="#NP_DEREFERENCE_OF_READLINE_VALUE">NP: Derefe
rence of the result of readLine() without nullcheck</a></td><td>Dodgy code</td><
/tr> |
| 428 <tr bgcolor="#eeeeee"><td><a href="#NP_IMMEDIATE_DEREFERENCE_OF_READLINE">NP: Dé
référencement immédiat du résultat d'un readLine()</a></td><td>Dodgy code</td></
tr> |
| 429 <tr bgcolor="#ffffff"><td><a href="#NP_LOAD_OF_KNOWN_NULL_VALUE">NP: Chargement
d'une valeur connue pour être à null</a></td><td>Dodgy code</td></tr> |
| 430 <tr bgcolor="#eeeeee"><td><a href="#NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION">NP:
Method tightens nullness annotation on parameter</a></td><td>Dodgy code</td></t
r> |
| 431 <tr bgcolor="#ffffff"><td><a href="#NP_METHOD_RETURN_RELAXING_ANNOTATION">NP: Me
thod relaxes nullness annotation on return value</a></td><td>Dodgy code</td></tr
> |
| 432 <tr bgcolor="#eeeeee"><td><a href="#NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE">NP:
Pointeur à null renvoyé par une méthode qui risque d'être déréférencé</a></td><t
d>Dodgy code</td></tr> |
| 433 <tr bgcolor="#ffffff"><td><a href="#NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE">NP
: Possible null pointer dereference on branch that might be infeasible</a></td><
td>Dodgy code</td></tr> |
| 434 <tr bgcolor="#eeeeee"><td><a href="#NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_N
ULLABLE">NP: Parameter must be nonnull but is marked as nullable</a></td><td>Dod
gy code</td></tr> |
| 435 <tr bgcolor="#ffffff"><td><a href="#NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD">NP:
Read of unwritten public or protected field</a></td><td>Dodgy code</td></tr> |
| 436 <tr bgcolor="#eeeeee"><td><a href="#NS_DANGEROUS_NON_SHORT_CIRCUIT">NS: Potentia
lly dangerous use of non-short-circuit logic</a></td><td>Dodgy code</td></tr> |
| 437 <tr bgcolor="#ffffff"><td><a href="#NS_NON_SHORT_CIRCUIT">NS: Utilisation discut
able de logique binaire</a></td><td>Dodgy code</td></tr> |
| 438 <tr bgcolor="#eeeeee"><td><a href="#PZLA_PREFER_ZERO_LENGTH_ARRAYS">PZLA: Envisa
gez de renvoyer un tableau vide plutôt que null</a></td><td>Dodgy code</td></tr> |
| 439 <tr bgcolor="#ffffff"><td><a href="#QF_QUESTIONABLE_FOR_LOOP">QF: Incrémentation
compliquée, subtile au incorrecte dans une boucle for</a></td><td>Dodgy code</t
d></tr> |
| 440 <tr bgcolor="#eeeeee"><td><a href="#RCN_REDUNDANT_COMPARISON_OF_NULL_AND_NONNULL
_VALUE">RCN: Comparaison redondante d'une valeur non nulle avec null</a></td><td
>Dodgy code</td></tr> |
| 441 <tr bgcolor="#ffffff"><td><a href="#RCN_REDUNDANT_COMPARISON_TWO_NULL_VALUES">RC
N: Comparaison redondante de deux valeurs nulles</a></td><td>Dodgy code</td></tr
> |
| 442 <tr bgcolor="#eeeeee"><td><a href="#RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE">RC
N: Test de nullité redondant sur une valeur non nulle</a></td><td>Dodgy code</td
></tr> |
| 443 <tr bgcolor="#ffffff"><td><a href="#RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE">RCN:
Test de nullité redondant sur une valeur connue pour être à null</a></td><td>Dod
gy code</td></tr> |
| 444 <tr bgcolor="#eeeeee"><td><a href="#REC_CATCH_EXCEPTION">REC: java.lang.Exceptio
n est intercepté alors qu'Exception n'est jamais lancé</a></td><td>Dodgy code</t
d></tr> |
| 445 <tr bgcolor="#ffffff"><td><a href="#RI_REDUNDANT_INTERFACES">RI: Classe implémen
tant la même interface que sa super-classe</a></td><td>Dodgy code</td></tr> |
| 446 <tr bgcolor="#eeeeee"><td><a href="#RV_CHECK_FOR_POSITIVE_INDEXOF">RV: Méthode v
érifiant que le résultat d'un String.indexOf() est positif</a></td><td>Dodgy cod
e</td></tr> |
| 447 <tr bgcolor="#ffffff"><td><a href="#RV_DONT_JUST_NULL_CHECK_READLINE">RV: Méthod
e ignorant le résultat d'un readLine() après avoir vérifié qu'il est non nul</a>
</td><td>Dodgy code</td></tr> |
| 448 <tr bgcolor="#eeeeee"><td><a href="#RV_REM_OF_HASHCODE">RV: Reste d'un hashCode
pouvant être négatif</a></td><td>Dodgy code</td></tr> |
| 449 <tr bgcolor="#ffffff"><td><a href="#RV_REM_OF_RANDOM_INT">RV: Reste d'un entier
signé 32 bits aléeatoire</a></td><td>Dodgy code</td></tr> |
| 450 <tr bgcolor="#eeeeee"><td><a href="#RV_RETURN_VALUE_IGNORED_INFERRED">RV: Method
ignores return value, is this OK?</a></td><td>Dodgy code</td></tr> |
| 451 <tr bgcolor="#ffffff"><td><a href="#SA_FIELD_DOUBLE_ASSIGNMENT">SA: Double assig
nment of field</a></td><td>Dodgy code</td></tr> |
| 452 <tr bgcolor="#eeeeee"><td><a href="#SA_LOCAL_DOUBLE_ASSIGNMENT">SA: Double assig
nment of local variable </a></td><td>Dodgy code</td></tr> |
| 453 <tr bgcolor="#ffffff"><td><a href="#SA_LOCAL_SELF_ASSIGNMENT">SA: Auto-alimentat
ion d'une variable locale</a></td><td>Dodgy code</td></tr> |
| 454 <tr bgcolor="#eeeeee"><td><a href="#SF_SWITCH_FALLTHROUGH">SF: Un switch comport
e un cas qui déborde sur le suivant</a></td><td>Dodgy code</td></tr> |
| 455 <tr bgcolor="#ffffff"><td><a href="#SF_SWITCH_NO_DEFAULT">SF: Switch statement f
ound where default case is missing</a></td><td>Dodgy code</td></tr> |
| 456 <tr bgcolor="#eeeeee"><td><a href="#ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD">ST:
Ecriture d'un champ statique depuis la méthode d'une instance</a></td><td>Dodgy
code</td></tr> |
| 457 <tr bgcolor="#ffffff"><td><a href="#SE_PRIVATE_READ_RESOLVE_NOT_INHERITED">Se: P
rivate readResolve method not inherited by subclasses</a></td><td>Dodgy code</td
></tr> |
| 458 <tr bgcolor="#eeeeee"><td><a href="#SE_TRANSIENT_FIELD_OF_NONSERIALIZABLE_CLASS"
>Se: Transient field of class that isn't Serializable. </a></td><td>Dodgy code</
td></tr> |
| 459 <tr bgcolor="#ffffff"><td><a href="#TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALW
AYS_SINK">TQ: Value required to have type qualifier, but marked as unknown</a></
td><td>Dodgy code</td></tr> |
| 460 <tr bgcolor="#eeeeee"><td><a href="#TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEV
ER_SINK">TQ: Value required to not have type qualifier, but marked as unknown</a
></td><td>Dodgy code</td></tr> |
| 461 <tr bgcolor="#ffffff"><td><a href="#UCF_USELESS_CONTROL_FLOW">UCF: Instruction d
e contrôle du flux inutile</a></td><td>Dodgy code</td></tr> |
| 462 <tr bgcolor="#eeeeee"><td><a href="#UCF_USELESS_CONTROL_FLOW_NEXT_LINE">UCF: Use
less control flow to next line</a></td><td>Dodgy code</td></tr> |
| 463 <tr bgcolor="#ffffff"><td><a href="#URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD">UrF: U
nread public/protected field</a></td><td>Dodgy code</td></tr> |
| 464 <tr bgcolor="#eeeeee"><td><a href="#UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD">UuF: U
nused public or protected field</a></td><td>Dodgy code</td></tr> |
| 465 <tr bgcolor="#ffffff"><td><a href="#UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR">Uw
F: Champ non initialisé dans le constructeur</a></td><td>Dodgy code</td></tr> |
| 466 <tr bgcolor="#eeeeee"><td><a href="#UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD">UwF
: Unwritten public or protected field</a></td><td>Dodgy code</td></tr> |
| 467 <tr bgcolor="#ffffff"><td><a href="#XFB_XML_FACTORY_BYPASS">XFB: Méthode instanc
iant directement une implémentation spécifique des interfaces XML</a></td><td>Do
dgy code</td></tr> |
| 468 </table> |
| 469 <h2>Descriptions</h2> |
| 470 <h3><a name="BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS">BC: Equals method sho
uld not assume anything about the type of its argument (BC_EQUALS_METHOD_SHOULD_
WORK_FOR_ALL_OBJECTS)</a></h3> |
| 471 |
| 472 |
| 473 <p> |
| 474 The <code>equals(Object o)</code> method shouldn't make any assumptions |
| 475 about the type of <code>o</code>. It should simply return |
| 476 false if <code>o</code> is not the same type as <code>this</code>. |
| 477 </p> |
| 478 |
| 479 |
| 480 <h3><a name="BIT_SIGNED_CHECK">BIT: Check for sign of bitwise operation (BIT_SIG
NED_CHECK)</a></h3> |
| 481 |
| 482 |
| 483 <p> This method compares an expression such as</p> |
| 484 <pre>((event.detail & SWT.SELECTED) > 0)</pre>. |
| 485 <p>Using bit arithmetic and then comparing with the greater than operator can |
| 486 lead to unexpected results (of course depending on the value of |
| 487 SWT.SELECTED). If SWT.SELECTED is a negative number, this is a candidate |
| 488 for a bug. Even when SWT.SELECTED is not negative, it seems good practice |
| 489 to use '!= 0' instead of '> 0'. |
| 490 </p> |
| 491 <p> |
| 492 <em>Boris Bokowski</em> |
| 493 </p> |
| 494 |
| 495 |
| 496 <h3><a name="CN_IDIOM">CN: La classe implémente Cloneable mais ne définit et n'u
tilise pas la méthode clone() (CN_IDIOM)</a></h3> |
| 497 |
| 498 |
| 499 <p>La classe implémente <code>Cloneable</code> sans définir ou utiliser la métho
de <code>clone()</code>.</p> |
| 500 |
| 501 |
| 502 <h3><a name="CN_IDIOM_NO_SUPER_CALL">CN: La méthode clone() n'appelle pas super.
clone() (CN_IDIOM_NO_SUPER_CALL)</a></h3> |
| 503 |
| 504 |
| 505 <p>Cette classe définit une méthode <code>clone()</code> qui n'appelle pas <code
>super.clone()</code>, et n'est pas finale. Si cette classe ("<i>A</i>") est éte
ndue par une classe fille ("<i>B</i>"), et que la classe fille <i>B</i> appelle
<code>super.clone()</code>, alors il est probable que la méthode <code>clone()</
code> de <i>B</i> retournera un objet de type <i>A</i>, ce qui viole le contrat
standard de <code>clone()</code>.</p> |
| 506 <p>Si toutes les méthodes <code>clone()</code> appellent <code>super.clone()</co
de>, elles ont alors la garantie d'utiliser <code>Object.clone()</code>, qui ret
ourne toujours un objet du type correct.</p> |
| 507 |
| 508 |
| 509 <h3><a name="CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE">CN: Class defines clone() bu
t doesn't implement Cloneable (CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE)</a></h3> |
| 510 |
| 511 |
| 512 <p> This class defines a clone() method but the class doesn't implement Cloneabl
e. |
| 513 There are some situations in which this is OK (e.g., you want to control how sub
classes |
| 514 can clone themselves), but just make sure that this is what you intended. |
| 515 </p> |
| 516 |
| 517 |
| 518 <h3><a name="CNT_ROUGH_CONSTANT_VALUE">CNT: Rough value of known constant found
(CNT_ROUGH_CONSTANT_VALUE)</a></h3> |
| 519 |
| 520 |
| 521 <p>It's recommended to use the predefined library constant for code clarity
and better precision.</p> |
| 522 |
| 523 |
| 524 <h3><a name="CO_ABSTRACT_SELF">Co: Une classe abstraite définit une méthode comp
areTo() covariante (CO_ABSTRACT_SELF)</a></h3> |
| 525 |
| 526 |
| 527 <p>Cette classe définit une version covariante de <code>compareTo()</code>. Pour
surcharger correctement la méthode <code>compareTo()</code> de l'interface <cod
e>Comparable</code>, le paramètre de <code>compareTo()</code> doit être du type
<code>java.lang.Object</code>.</p> |
| 528 |
| 529 |
| 530 <h3><a name="CO_SELF_NO_OBJECT">Co: Définition d'une méthode compareTo() covaria
nte (CO_SELF_NO_OBJECT)</a></h3> |
| 531 |
| 532 |
| 533 <p>Cette classe définit une version covariante de <code>compareTo()</code>. Pour
correctement surcharger la méthode <code>compareTo() </code>de l'interface <cod
e>Comparable</code>, le paramètre de <code>compareTo()</code> doit être du type
<code>java.lang.Object</code>.</p> |
| 534 |
| 535 |
| 536 <h3><a name="DE_MIGHT_DROP">DE: La méthode peut déclencher une exception (DE_MIG
HT_DROP)</a></h3> |
| 537 |
| 538 |
| 539 <p>Cette méthode peut déclencher une exception. En général, les exceptions doive
nt être gérées ou transmises hors de la méthode.</p> |
| 540 |
| 541 |
| 542 <h3><a name="DE_MIGHT_IGNORE">DE: La méthode peut ignorer une exception (DE_MIGH
T_IGNORE)</a></h3> |
| 543 |
| 544 |
| 545 <p>Cette méthode peut ignorer une exception. En général, les exceptions doivent
être gérées ou transmises hors de la méthode.</p> |
| 546 |
| 547 |
| 548 <h3><a name="DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS">DMI: Adding elements of an
entry set may fail due to reuse of Entry objects (DMI_ENTRY_SETS_MAY_REUSE_ENTRY
_OBJECTS)</a></h3> |
| 549 |
| 550 |
| 551 <p> The entrySet() method is allowed to return a view of the |
| 552 underlying Map in which a single Entry object is reused and returned |
| 553 during the iteration. As of Java 1.6, both IdentityHashMap |
| 554 and EnumMap did so. When iterating through such a Map, |
| 555 the Entry value is only valid until you advance to the next iteration. |
| 556 If, for example, you try to pass such an entrySet to an addAll method, |
| 557 things will go badly wrong. |
| 558 </p> |
| 559 |
| 560 |
| 561 <h3><a name="DMI_RANDOM_USED_ONLY_ONCE">DMI: Random object created and used only
once (DMI_RANDOM_USED_ONLY_ONCE)</a></h3> |
| 562 |
| 563 |
| 564 <p> This code creates a java.util.Random object, uses it to generate one random
number, and then discards |
| 565 the Random object. This produces mediocre quality random numbers and is ineffici
ent. |
| 566 If possible, rewrite the code so that the Random object is created once and save
d, and each time a new random number |
| 567 is required invoke a method on the existing Random object to obtain it. |
| 568 </p> |
| 569 |
| 570 <p>If it is important that the generated Random numbers not be guessable, you <e
m>must</em> not create a new Random for each random |
| 571 number; the values are too easily guessable. You should strongly consider using
a java.security.SecureRandom instead |
| 572 (and avoid allocating a new SecureRandom for each random number needed). |
| 573 </p> |
| 574 |
| 575 |
| 576 <h3><a name="DMI_USING_REMOVEALL_TO_CLEAR_COLLECTION">DMI: Don't use removeAll t
o clear a collection (DMI_USING_REMOVEALL_TO_CLEAR_COLLECTION)</a></h3> |
| 577 |
| 578 |
| 579 <p> If you want to remove all elements from a collection <code>c</code>, us
e <code>c.clear</code>, |
| 580 not <code>c.removeAll(c)</code>. Calling <code>c.removeAll(c)</code> to clear a
collection |
| 581 is less clear, susceptible to errors from typos, less efficient and |
| 582 for some collections, might throw a <code>ConcurrentModificationException</code>
. |
| 583 </p> |
| 584 |
| 585 |
| 586 <h3><a name="DM_EXIT">Dm: La méthode invoque System.exit(...) (DM_EXIT)</a></h3> |
| 587 |
| 588 |
| 589 <p>Invoquer <code>System.exit()</code> arrête toute la JVM. Cela ne doit être fa
it que lorsque c'est nécessaire. De tels appels rendent difficile ou impossible
l'invocation de votre code par d'autre code. Envisagez de déclencher une <code>R
untimeException</code> à la place.</p> |
| 590 |
| 591 |
| 592 <h3><a name="DM_RUN_FINALIZERS_ON_EXIT">Dm: Méthode invoquant runFinalizersOnExi
t, l'une des plus dangeureuses méthodes des librairies Java (DM_RUN_FINALIZERS_O
N_EXIT)</a></h3> |
| 593 |
| 594 |
| 595 <p>N'appelez jamais <code>System.runFinalizersOnExit</code> ou <code>Runtime.run
FinalizersOnExit</code> pour quelque raison que ce soit : elles font partie des
méthodes les plus dangeureuses des librairies Java</p> |
| 596 <p>Joshua Bloch</p> |
| 597 |
| 598 |
| 599 <h3><a name="ES_COMPARING_PARAMETER_STRING_WITH_EQ">ES: Comparison of String par
ameter using == or != (ES_COMPARING_PARAMETER_STRING_WITH_EQ)</a></h3> |
| 600 |
| 601 |
| 602 <p>This code compares a <code>java.lang.String</code> parameter for reference |
| 603 equality using the == or != operators. Requiring callers to |
| 604 pass only String constants or interned strings to a method is unnecessarily |
| 605 fragile, and rarely leads to measurable performance gains. Consider |
| 606 using the <code>equals(Object)</code> method instead.</p> |
| 607 |
| 608 |
| 609 <h3><a name="ES_COMPARING_STRINGS_WITH_EQ">ES: Comparaison d'objets String utili
sant == ou != (ES_COMPARING_STRINGS_WITH_EQ)</a></h3> |
| 610 |
| 611 |
| 612 <p>Ce code compare des objets <code>java.lang.String</code> au moyen de l'égalit
é par référence des opérateurs <code>==</code> ou <code>!=</code>. A moins que l
es deux chaînes ne soient des constantes dans le fichier source ou aient été int
ernalisées au moyen de la méthode <code>String.intern()</code>, deux chaînes ide
ntiques peuvent être représentées par deux objets <code>String</code> différents
. Envisagez d'utiliser la méthode <code>equals(Object)</code> à la place.</p> |
| 613 |
| 614 |
| 615 <h3><a name="EQ_ABSTRACT_SELF">Eq: Une classe abstraite définit une méthode equa
ls() covariante (EQ_ABSTRACT_SELF)</a></h3> |
| 616 |
| 617 |
| 618 <p>Cette classe définit une version covariante de la méthode <code>equals()</cod
e>. Pour surcharger correctement la méthode <code>equals()</code> de <code>java.
lang.Object</code>, le paramètre de <code>equals()</code> doit être du type <cod
e>java.lang.Object</code>.</p> |
| 619 |
| 620 |
| 621 <h3><a name="EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS">Eq: Equals checks fo
r incompatible operand (EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS)</a></h3> |
| 622 |
| 623 |
| 624 <p> This equals method is checking to see if the argument is some incompatible
type |
| 625 (i.e., a class that is neither a supertype nor subtype of the class that defines |
| 626 the equals method). For example, the Foo class might have an equals method |
| 627 that looks like: |
| 628 </p> |
| 629 <pre> |
| 630 public boolean equals(Object o) { |
| 631 if (o instanceof Foo) |
| 632 return name.equals(((Foo)o).name); |
| 633 else if (o instanceof String) |
| 634 return name.equals(o); |
| 635 else return false; |
| 636 </pre> |
| 637 |
| 638 <p>This is considered bad practice, as it makes it very hard to implement an equ
als method that |
| 639 is symmetric and transitive. Without those properties, very unexpected behavoirs
are possible. |
| 640 </p> |
| 641 |
| 642 |
| 643 <h3><a name="EQ_COMPARETO_USE_OBJECT_EQUALS">Eq: Class defines compareTo(...) an
d uses Object.equals() (EQ_COMPARETO_USE_OBJECT_EQUALS)</a></h3> |
| 644 |
| 645 |
| 646 <p> This class defines a <code>compareTo(...)</code> method but inherits its |
| 647 <code>equals()</code> method from <code>java.lang.Object</code>. |
| 648 Generally, the value of compareTo should return zero if and only if |
| 649 equals returns true. If this is violated, weird and unpredictable |
| 650 failures will occur in classes such as PriorityQueue. |
| 651 In Java 5 the PriorityQueue.remove method uses the compareTo method, |
| 652 while in Java 6 it uses the equals method. |
| 653 |
| 654 <p>From the JavaDoc for the compareTo method in the Comparable interface: |
| 655 <blockquote> |
| 656 It is strongly recommended, but not strictly required that <code>(x.compareTo(y)
==0) == (x.equals(y))</code>. |
| 657 Generally speaking, any class that implements the Comparable interface and viola
tes this condition |
| 658 should clearly indicate this fact. The recommended language |
| 659 is "Note: this class has a natural ordering that is inconsistent with equals." |
| 660 </blockquote> |
| 661 |
| 662 |
| 663 <h3><a name="EQ_GETCLASS_AND_CLASS_CONSTANT">Eq: equals method fails for subtype
s (EQ_GETCLASS_AND_CLASS_CONSTANT)</a></h3> |
| 664 |
| 665 |
| 666 <p> This class has an equals method that will be broken if it is inherited by
subclasses. |
| 667 It compares a class literal with the class of the argument (e.g., in class <code
>Foo</code> |
| 668 it might check if <code>Foo.class == o.getClass()</code>). |
| 669 It is better to check if <code>this.getClass() == o.getClass()</code>. |
| 670 </p> |
| 671 |
| 672 |
| 673 <h3><a name="EQ_SELF_NO_OBJECT">Eq: Définition d'une méthode equals() covariante
(EQ_SELF_NO_OBJECT)</a></h3> |
| 674 |
| 675 |
| 676 <p>Cette classe définit une version covariante de <code>equals()</code>. Pour su
rcharger correctement la méthode <code>equals()</code> de <code>java.lang.Object
</code>, le paramètre de <code>equals()</code> doit être du type <code>java.lang
.Object</code>.</p> |
| 677 |
| 678 |
| 679 <h3><a name="FI_EMPTY">FI: Un finaliseur vide devrait être supprimé (FI_EMPTY)</
a></h3> |
| 680 |
| 681 |
| 682 <p>Les méthodes <code>finalize()</code> vides sont inutiles, donc elles devraien
t être supprimées.</p> |
| 683 |
| 684 |
| 685 <h3><a name="FI_EXPLICIT_INVOCATION">FI: Invocation explicite d'un finaliseur (F
I_EXPLICIT_INVOCATION)</a></h3> |
| 686 |
| 687 |
| 688 <p>Cette méthode contient un appel explicite à la méthode <code>finalize()</code
> d'un objet. Les méthodes <code>finalize()</code> étant sensées n'être appelées
qu'une fois, et uniquement par la JVM, c'est une mauvaise idée.</p> |
| 689 |
| 690 |
| 691 <h3><a name="FI_FINALIZER_NULLS_FIELDS">FI: Finalizer nulls fields (FI_FINALIZER
_NULLS_FIELDS)</a></h3> |
| 692 |
| 693 |
| 694 <p> This finalizer nulls out fields. This is usually an error, as it does not
aid garbage collection, |
| 695 and the object is going to be garbage collected anyway. |
| 696 |
| 697 |
| 698 <h3><a name="FI_FINALIZER_ONLY_NULLS_FIELDS">FI: Finalizer only nulls fields (FI
_FINALIZER_ONLY_NULLS_FIELDS)</a></h3> |
| 699 |
| 700 |
| 701 <p> This finalizer does nothing except null out fields. This is completely poi
ntless, and requires that |
| 702 the object be garbage collected, finalized, and then garbage collected again. Yo
u should just remove the finalize |
| 703 method. |
| 704 |
| 705 |
| 706 <h3><a name="FI_MISSING_SUPER_CALL">FI: Le finaliseur n'appelle pas le finaliseu
r de la super-classe (FI_MISSING_SUPER_CALL)</a></h3> |
| 707 |
| 708 |
| 709 <p>Cette méthode <code>finalize()</code> n'appelle pas la méthode <code>finalize
()</code> de sa classe mère ; donc toutes les actions définies au niveau de la c
lasse mère seront ignorées. Ajoutez un appel à <code>super.finalize()</code>.</p
> |
| 710 |
| 711 |
| 712 <h3><a name="FI_NULLIFY_SUPER">FI: Un finaliseur rend inutile celui de sa super-
classe (FI_NULLIFY_SUPER)</a></h3> |
| 713 |
| 714 |
| 715 <p>Cette méthode <code>finalize()</code> vide rend explicitement inutile tout fi
naliseur défini dans les super-classes. Toute action définie dans un finaliseur
d'une superclasse sera ignorée. A moins que cela ne soit voulu, supprimer cette
méthode.</p> |
| 716 |
| 717 |
| 718 <h3><a name="FI_USELESS">FI: Le finaliseur ne fait rien sauf appeler celui de la
super-classe (FI_USELESS)</a></h3> |
| 719 |
| 720 |
| 721 <p>La seule chose que cette méthode <code>finalize()</code> fait est d'appeler l
a méthode <code>finalize()</code> de la super-classe, ce qui la rend redondante.
Supprimez la.</p> |
| 722 |
| 723 |
| 724 <h3><a name="VA_FORMAT_STRING_USES_NEWLINE">FS: Format string should use %n rath
er than \n (VA_FORMAT_STRING_USES_NEWLINE)</a></h3> |
| 725 |
| 726 |
| 727 <p> |
| 728 This format string include a newline character (\n). In format strings, it is ge
nerally |
| 729 preferable better to use %n, which will produce the platform-specific line sepa
rator. |
| 730 </p> |
| 731 |
| 732 |
| 733 <h3><a name="GC_UNCHECKED_TYPE_IN_GENERIC_CALL">GC: Unchecked type in generic ca
ll (GC_UNCHECKED_TYPE_IN_GENERIC_CALL)</a></h3> |
| 734 |
| 735 |
| 736 <p> This call to a generic collection method passes an argument |
| 737 while compile type Object where a specific type from |
| 738 the generic type parameters is expected. |
| 739 Thus, neither the standard Java type system nor static analysis |
| 740 can provide useful information on whether the |
| 741 object being passed as a parameter is of an appropriate type. |
| 742 </p> |
| 743 |
| 744 |
| 745 <h3><a name="HE_EQUALS_NO_HASHCODE">HE: La classe définit equals() mais pas hash
Code() (HE_EQUALS_NO_HASHCODE)</a></h3> |
| 746 |
| 747 |
| 748 <p>Cette classe surcharge <code>equals(Object)</code>, mais pas <code>hashCode()
</code>. C'est pourquoi la classe peut violer le contrat indiquant que des objet
s égaux doivent avoir des codes de hachage identiques.</p> |
| 749 |
| 750 |
| 751 <h3><a name="HE_EQUALS_USE_HASHCODE">HE: La classe définit equals() et utilise O
bject.hashCode() (HE_EQUALS_USE_HASHCODE)</a></h3> |
| 752 |
| 753 |
| 754 <p>Cette classe surcharge <code>equals(Object)</code>, pas <code>hashCode()</cod
e>, et hérite de l'implémentation de <code>hashCode()</code> issue de <code>java
.lang.Object</code> (qui renvoie le code de hachage d'identité, une valeur arbit
raire assignée à l'objet par la JVM). C'est pourquoi la classe a des chances de
violer le contrat impliquant que des objets égaux doivent avoir des codes de hac
hage identiques.</p> |
| 755 <p>Si vous ne pensez pas que des instances de cette classe soient un jour inséré
s dans des<code>HashMap</code>/<code>Hashtable</code>, l'implémentation recommen
dée est du type :</p> |
| 756 <p><pre> |
| 757 public int hashCode() { |
| 758 assert false : "hashCode not designed"; |
| 759 return 42; // any arbitrary constant will do |
| 760 } |
| 761 </pre></p> |
| 762 |
| 763 |
| 764 <h3><a name="HE_HASHCODE_NO_EQUALS">HE: La classe définit hashCode() mais pas eq
uals() (HE_HASHCODE_NO_EQUALS)</a></h3> |
| 765 |
| 766 |
| 767 <p>Cette classe définit une méthode <code>hashCode()</code> mais pas de méthode
<code>equals()</code>. C'est pourquoi cette classe peut violer le contrat indiqu
ant que des objets identiques doivent avoir des codes de hachage identiques.</p> |
| 768 |
| 769 |
| 770 <h3><a name="HE_HASHCODE_USE_OBJECT_EQUALS">HE: La classe définit hashCode() et
utilise Object.equals() (HE_HASHCODE_USE_OBJECT_EQUALS)</a></h3> |
| 771 |
| 772 |
| 773 <p>Cette classe définit une méthode <code>hashCode()</code> mais hérite la métho
de <code>equals()</code> de <code>java.lang.Object</code> (qui définit l'égalité
par comparaison des références des objets). Bien que cela satisfasse certaineme
nt le contrat indiquant que les objets égaux doivent avoir des codes de hachage
égaux, ce n'est certainement pas ce qui était voulu lors de la surcharge de la m
éthode <code>hashCode()</code> (Surcharger <code>hashCode()</code> implique que
l'identité des objets soit basée sur des critères plus compliqués qu'une simple
égalités des références.)</p> |
| 774 <p>Si vous ne pensez pas que des instances de cette classe soient un jour inséré
es dans des <code>HashMap</code>/<code>HashTable</code>, l'implémentation recomm
endée de <code>hashCode</code> est :</p> |
| 775 <p><pre> |
| 776 public int hashCode() { |
| 777 assert false : "hashCode not designed"; |
| 778 return 42; // any arbitrary constant will do |
| 779 } |
| 780 </pre></p> |
| 781 |
| 782 |
| 783 <h3><a name="HE_INHERITS_EQUALS_USE_HASHCODE">HE: La classe hérite de equals() e
t utilise Object.hashCode() (HE_INHERITS_EQUALS_USE_HASHCODE)</a></h3> |
| 784 |
| 785 |
| 786 <p>Cette classe hérite de la méthode <code>equals((Object)</code> d'une super-cl
asse abstraite, et de la méthode <code>hashCode()</code> de l'objet <code>java.l
ang.Object</code> (qui renvoi le code de hachage d'identité, une valeur arbitrai
re assignée à l'objet par la JVM). C'est pourquoi la classe viole probablement l
e contrat indiquant que des objets égaux doivent avoir des codes de hachage iden
tiques.</p> |
| 787 <p>Si vous ne souhaitez pas définir une méthode <code>hashCode()</code> et/ou ne
pensez pas que l'objet puisse un jour être mis dans des <code>HashMap</code>/<c
ode>Hashtable</code>, définissez une méthode <code>hashCode()</code> déclenchant
une <code>UnsupportedOperationException</code>.</p> |
| 788 |
| 789 |
| 790 <h3><a name="IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION">IC: Classe mère
utilisant une sous-classe durant son initialisation (IC_SUPERCLASS_USES_SUBCLASS
_DURING_INITIALIZATION)</a></h3> |
| 791 |
| 792 |
| 793 <p>Durant l'intialisation, une classe utilise activement l'une de ses sous-class
es. Cette sous-classe ne sera pas encore initialisée lors de la première utilisa
tion. Par exemple, dans le code suivant, <code>foo</code> sera à <code>null</cod
e>.</p> |
| 794 <p><code><pre> |
| 795 public class CircularClassInitialization { |
| 796 static class InnerClassSingleton extends CircularClassInitialization { |
| 797 static InnerClassSingleton singleton = new InnerClassSingleton(); |
| 798 } |
| 799 static CircularClassInitialization foo = InnerClassSingleton.singleton; |
| 800 } |
| 801 </pre></code></p> |
| 802 |
| 803 |
| 804 <h3><a name="IMSE_DONT_CATCH_IMSE">IMSE: Interception douteuse d'une IllegalMoni
torStateException (IMSE_DONT_CATCH_IMSE)</a></h3> |
| 805 |
| 806 |
| 807 <p><code>IllegalMonitorStateException</code> n'est généralement déclenchée que d
ans le cas d'une faille dans la conception du code (appeler <code>wait()</code>
ou <code>notify()</code> sur un objet dont on ne possède pas le verrou).</p> |
| 808 |
| 809 |
| 810 <h3><a name="ISC_INSTANTIATE_STATIC_CLASS">ISC: Instantiation inutile d'une clas
se qui n'a que des méthodes statiques (ISC_INSTANTIATE_STATIC_CLASS)</a></h3> |
| 811 |
| 812 |
| 813 <p>Cette classe alloue un objet basé sur une classe qui n'a que des méthodes sta
tiques. Cet objet n'a pas besoin d'être créé, accédez directement aux méthodes e
n utilisant le nom de la classe.</p> |
| 814 |
| 815 |
| 816 <h3><a name="IT_NO_SUCH_ELEMENT">It: La méthode next() de Iterator ne peut pas d
éclencher une exception NoSuchElement (IT_NO_SUCH_ELEMENT)</a></h3> |
| 817 |
| 818 |
| 819 <p>Cette classe implémente l'interface <code>java.util.Iterator</code>. Néanmoin
s, sa méthode <code>next()</code> n'est pas capable de déclencher <code>java.uti
l.NoSuchElementException</code>. La méthode <code>next()</code> devrait être mod
ifiée pour déclencher <code>NoSuchElementException</code> si elle est appelée al
ors qu'il n'y a plus d'éléments à renvoyer.</p> |
| 820 |
| 821 |
| 822 <h3><a name="J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION">J2EE: Stockage
d'un objet non serialisable dans une session Http (J2EE_STORE_OF_NON_SERIALIZABL
E_OBJECT_INTO_SESSION)</a></h3> |
| 823 |
| 824 |
| 825 <p>Ce code semble stocker un objet non sérialisable dans un <code>HttpSession</c
ode>. Une erreur se produira si cette session est rendue passive ou migrée.</p> |
| 826 |
| 827 |
| 828 <h3><a name="JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS">JCIP: Les champs d'une cl
asse immuable devraient être finaux. (JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS)<
/a></h3> |
| 829 |
| 830 |
| 831 La classe est annotée avec <code>net.jcip.annotations.Immutable</code>, et la rè
gle liée à cette annotation réclame que tous les champs soient marqués <code>fin
al</code>. |
| 832 |
| 833 |
| 834 <h3><a name="NP_BOOLEAN_RETURN_NULL">NP: Method with Boolean return type returns
explicit null (NP_BOOLEAN_RETURN_NULL)</a></h3> |
| 835 |
| 836 |
| 837 <p> |
| 838 A method that returns either Boolean.TRUE, Boolean.FALSE or null is an accid
ent waiting to happen. |
| 839 This method can be invoked as though it returned a value of type boolean, an
d |
| 840 the compiler will insert automatic unboxing of the Boolean value. If a null
value is returned, |
| 841 this will result in a NullPointerException. |
| 842 </p> |
| 843 |
| 844 |
| 845 <h3><a name="NP_CLONE_COULD_RETURN_NULL">NP: Clone method may return null (NP_CL
ONE_COULD_RETURN_NULL)</a></h3> |
| 846 |
| 847 |
| 848 <p> |
| 849 This clone method seems to return null in some circumstances, but clone is n
ever |
| 850 allowed to return a null value. If you are convinced this path is unreachab
le, throw an AssertionError |
| 851 instead. |
| 852 </p> |
| 853 |
| 854 |
| 855 <h3><a name="NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT">NP: Méthode equals() ne véri
fiant pas la nullité (NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT)</a></h3> |
| 856 |
| 857 |
| 858 <p>Cette implémentation de <code>equals(Object)</code> ne respecte pas le contra
t défini par <code>java.lang.Object.equals()</code> car elle ne vérifie la nulli
té du paramètre reçu en argument. Toutes les méthodes <code>equals()</code> doiv
ent renvoyer <code>false</code> quand elles reçoivent une valeur à <code>null</c
ode>.</p> |
| 859 |
| 860 |
| 861 <h3><a name="NP_TOSTRING_COULD_RETURN_NULL">NP: toString method may return null
(NP_TOSTRING_COULD_RETURN_NULL)</a></h3> |
| 862 |
| 863 |
| 864 <p> |
| 865 This toString method seems to return null in some circumstances. A liberal r
eading of the |
| 866 spec could be interpreted as allowing this, but it is probably a bad idea an
d could cause |
| 867 other code to break. Return the empty string or some other appropriate strin
g rather than null. |
| 868 </p> |
| 869 |
| 870 |
| 871 <h3><a name="NM_CLASS_NAMING_CONVENTION">Nm: Nom de classe devant commencer par
une majuscule (NM_CLASS_NAMING_CONVENTION)</a></h3> |
| 872 |
| 873 |
| 874 <p>Les noms de classe doivent être en minuscules avec la première lettre de chaq
ue mot en majuscules. Essayez de conserver vos noms de classes simples et explic
ites. Utilisez des mots entiers et évitez acronymes et abbréviations (à moins qu
e l'abbréviation soit plus largement utilisée que la forme longue, comme "URL" o
u "HTML").</p> |
| 875 |
| 876 |
| 877 <h3><a name="NM_CLASS_NOT_EXCEPTION">Nm: Cette classe ne dérive pas d'Exception,
même si son nom le sous-entend (NM_CLASS_NOT_EXCEPTION)</a></h3> |
| 878 |
| 879 |
| 880 <p>Cette classe n'est pas dérivée d'une autre <code>Exception</code> alors que s
on nom se termine par 'Exception'. Ceci risque de porter à confusion les utilisa
teurs de cette classe.</p> |
| 881 |
| 882 |
| 883 <h3><a name="NM_CONFUSING">Nm: Noms de méthodes ambigus (NM_CONFUSING)</a></h3> |
| 884 |
| 885 |
| 886 <p>Les méthodes indiquées ont des noms qui ne diffèrent que par les majuscules.<
/p> |
| 887 |
| 888 |
| 889 <h3><a name="NM_FIELD_NAMING_CONVENTION">Nm: Nom de champ devant commencer par u
ne minuscule (NM_FIELD_NAMING_CONVENTION)</a></h3> |
| 890 |
| 891 |
| 892 <p>Les noms de champs qui ne sont pas finaux devraient être en minuscules avec l
a première lettre des mots, après le premier, en majuscule.</p> |
| 893 |
| 894 |
| 895 <h3><a name="NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER">Nm: Use of identifier that is
a keyword in later versions of Java (NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER)</a><
/h3> |
| 896 |
| 897 |
| 898 <p>The identifier is a word that is reserved as a keyword in later versions of J
ava, and your code will need to be changed |
| 899 in order to compile it in later versions of Java.</p> |
| 900 |
| 901 |
| 902 |
| 903 <h3><a name="NM_FUTURE_KEYWORD_USED_AS_MEMBER_IDENTIFIER">Nm: Use of identifier
that is a keyword in later versions of Java (NM_FUTURE_KEYWORD_USED_AS_MEMBER_ID
ENTIFIER)</a></h3> |
| 904 |
| 905 |
| 906 <p>This identifier is used as a keyword in later versions of Java. This code, an
d |
| 907 any code that references this API, |
| 908 will need to be changed in order to compile it in later versions of Java.</p> |
| 909 |
| 910 |
| 911 |
| 912 <h3><a name="NM_METHOD_NAMING_CONVENTION">Nm: Nom de méthode devant commencer pa
r une minuscule (NM_METHOD_NAMING_CONVENTION)</a></h3> |
| 913 |
| 914 |
| 915 <p>Les noms de méthodes devraient être des verbes en minuscules, avec la premièr
e lettre des mots, après le premier, en majuscules.</p> |
| 916 |
| 917 |
| 918 <h3><a name="NM_SAME_SIMPLE_NAME_AS_INTERFACE">Nm: Class names shouldn't shadow
simple name of implemented interface (NM_SAME_SIMPLE_NAME_AS_INTERFACE)</a></h3> |
| 919 |
| 920 |
| 921 <p> This class/interface has a simple name that is identical to that of an imp
lemented/extended interface, except |
| 922 that the interface is in a different package (e.g., <code>alpha.Foo</code> exten
ds <code>beta.Foo</code>). |
| 923 This can be exceptionally confusing, create lots of situations in which you have
to look at import statements |
| 924 to resolve references and creates many |
| 925 opportunities to accidently define methods that do not override methods in their
superclasses. |
| 926 </p> |
| 927 |
| 928 |
| 929 <h3><a name="NM_SAME_SIMPLE_NAME_AS_SUPERCLASS">Nm: Class names shouldn't shadow
simple name of superclass (NM_SAME_SIMPLE_NAME_AS_SUPERCLASS)</a></h3> |
| 930 |
| 931 |
| 932 <p> This class has a simple name that is identical to that of its superclass,
except |
| 933 that its superclass is in a different package (e.g., <code>alpha.Foo</code> exte
nds <code>beta.Foo</code>). |
| 934 This can be exceptionally confusing, create lots of situations in which you have
to look at import statements |
| 935 to resolve references and creates many |
| 936 opportunities to accidently define methods that do not override methods in their
superclasses. |
| 937 </p> |
| 938 |
| 939 |
| 940 <h3><a name="NM_VERY_CONFUSING_INTENTIONAL">Nm: Very confusing method names (but
perhaps intentional) (NM_VERY_CONFUSING_INTENTIONAL)</a></h3> |
| 941 |
| 942 |
| 943 <p> The referenced methods have names that differ only by capitalization. |
| 944 This is very confusing because if the capitalization were |
| 945 identical then one of the methods would override the other. From the existence o
f other methods, it |
| 946 seems that the existence of both of these methods is intentional, but is sure is
confusing. |
| 947 You should try hard to eliminate one of them, unless you are forced to have both
due to frozen APIs. |
| 948 </p> |
| 949 |
| 950 |
| 951 <h3><a name="NM_WRONG_PACKAGE_INTENTIONAL">Nm: Method doesn't override method in
superclass due to wrong package for parameter (NM_WRONG_PACKAGE_INTENTIONAL)</a
></h3> |
| 952 |
| 953 |
| 954 <p> The method in the subclass doesn't override a similar method in a supercla
ss because the type of a parameter doesn't exactly match |
| 955 the type of the corresponding parameter in the superclass. For example, if you h
ave:</p> |
| 956 |
| 957 <blockquote> |
| 958 <pre> |
| 959 import alpha.Foo; |
| 960 public class A { |
| 961 public int f(Foo x) { return 17; } |
| 962 } |
| 963 ---- |
| 964 import beta.Foo; |
| 965 public class B extends A { |
| 966 public int f(Foo x) { return 42; } |
| 967 public int f(alpha.Foo x) { return 27; } |
| 968 } |
| 969 </pre> |
| 970 </blockquote> |
| 971 |
| 972 <p>The <code>f(Foo)</code> method defined in class <code>B</code> doesn't |
| 973 override the |
| 974 <code>f(Foo)</code> method defined in class <code>A</code>, because the argument |
| 975 types are <code>Foo</code>'s from different packages. |
| 976 </p> |
| 977 |
| 978 <p>In this case, the subclass does define a method with a signature identical to
the method in the superclass, |
| 979 so this is presumably understood. However, such methods are exceptionally confus
ing. You should strongly consider |
| 980 removing or deprecating the method with the similar but not identical signature. |
| 981 </p> |
| 982 |
| 983 |
| 984 <h3><a name="ODR_OPEN_DATABASE_RESOURCE">ODR: La méthode peut ne pas fermer une
ressource base de données (ODR_OPEN_DATABASE_RESOURCE)</a></h3> |
| 985 |
| 986 |
| 987 <p>Cette méthode crée une ressource base de données (telle qu'une connexion ou u
n <code>RowSet</code>), ne l'affecte à aucun champ, ne la passe à aucune autre m
éthode, ne la renvoie pas, et ne semble pas la fermer dans tous les chemins d'ex
écution. Ne pas fermer une ressource base de données dans tous les chemins d'exé
cution peut entraîner de faibles performances et poser des problèmes de communic
ation entre la base de données et l'application.</p> |
| 988 |
| 989 |
| 990 <h3><a name="ODR_OPEN_DATABASE_RESOURCE_EXCEPTION_PATH">ODR: La méthode peut ne
pas fermer une ressource base de données sur une exception (ODR_OPEN_DATABASE_RE
SOURCE_EXCEPTION_PATH)</a></h3> |
| 991 |
| 992 |
| 993 <p>Cette méthode crée une ressource base de données (telle qu'une connexion ou u
n <code>RowSet</code>), ne l'affecte à aucun champ, ne la passe à aucune autre m
éthode, ne la renvoie pas, et ne semble pas la fermer dans tous les chemins d'ex
ception. Ne pas fermer une ressource base de données peut entraîner de faibles p
erformances et poser des problèmes de communication entre la base de données et
l'application.</p> |
| 994 |
| 995 |
| 996 <h3><a name="OS_OPEN_STREAM">OS: La méthode peut ne pas fermer un flux (OS_OPEN_
STREAM)</a></h3> |
| 997 |
| 998 |
| 999 <p>La méthode crée un objet de flux d'E/S, ne l'assigne à aucun champ, ne le pas
se à aucune méthode, ne le renvoit pas et ne semble pas le fermer dans tous les
chemins d'exécution. Ceci peut entraîner le blocage d'un descripteur de fichier.
C'est généralement une bonne idée d'utiliser un bloc <code>finally</code> pour
s'assurer de la fermeture des flux.</p> |
| 1000 |
| 1001 |
| 1002 <h3><a name="OS_OPEN_STREAM_EXCEPTION_PATH">OS: La méthode peut oublier de ferme
r un flux en cas d'exception (OS_OPEN_STREAM_EXCEPTION_PATH)</a></h3> |
| 1003 |
| 1004 |
| 1005 <p>La méthode crée un flux d'E/S, ne l'affecte à aucun champ, ne le passe à aucu
ne méthode, ne le renvoit pas, et ne semble pas le fermer dans tous les chemins
d'exception possibles. Ceci peut provoquer le blocage d'un descripteur de fichie
r. C'est généralement une bonne idée d'utiliser un bloc <code>finally</code> pou
r garantir la fermeture des flux.</p> |
| 1006 |
| 1007 |
| 1008 <h3><a name="PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS">PZ: Don't reuse entry obj
ects in iterators (PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS)</a></h3> |
| 1009 |
| 1010 |
| 1011 <p> The entrySet() method is allowed to return a view of the |
| 1012 underlying Map in which an Iterator and Map.Entry. This clever |
| 1013 idea was used in several Map implementations, but introduces the possibilit
y |
| 1014 of nasty coding mistakes. If a map <code>m</code> returns |
| 1015 such an iterator for an entrySet, then |
| 1016 <code>c.addAll(m.entrySet())</code> will go badly wrong. All of |
| 1017 the Map implementations in OpenJDK 1.7 have been rewritten to avoid this, |
| 1018 you should to. |
| 1019 </p> |
| 1020 |
| 1021 |
| 1022 <h3><a name="RC_REF_COMPARISON_BAD_PRACTICE">RC: Suspicious reference comparison
to constant (RC_REF_COMPARISON_BAD_PRACTICE)</a></h3> |
| 1023 |
| 1024 |
| 1025 <p> This method compares a reference value to a constant using the == or != oper
ator, |
| 1026 where the correct way to compare instances of this type is generally |
| 1027 with the equals() method. |
| 1028 It is possible to create distinct instances that are equal but do not compare as
== since |
| 1029 they are different objects. |
| 1030 Examples of classes which should generally |
| 1031 not be compared by reference are java.lang.Integer, java.lang.Float, etc.</p> |
| 1032 |
| 1033 |
| 1034 <h3><a name="RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN">RC: Suspicious reference co
mparison of Boolean values (RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN)</a></h3> |
| 1035 |
| 1036 |
| 1037 <p> This method compares two Boolean values using the == or != operator. |
| 1038 Normally, there are only two Boolean values (Boolean.TRUE and Boolean.FALSE), |
| 1039 but it is possible to create other Boolean objects using the <code>new Boolean(b
)</code> |
| 1040 constructor. It is best to avoid such objects, but if they do exist, |
| 1041 then checking Boolean objects for equality using == or != will give results |
| 1042 than are different than you would get using <code>.equals(...)</code> |
| 1043 </p> |
| 1044 |
| 1045 |
| 1046 <h3><a name="RR_NOT_CHECKED">RR: La méthode ignore le résultat de InputStream.re
ad() (RR_NOT_CHECKED)</a></h3> |
| 1047 |
| 1048 |
| 1049 <p>Cette méthode ignore le code retour d'une des variantes de <code>java.io.Inpu
tStream.read()</code> qui peut renvoyer de multiples octets. Si la valeur renvoy
ée n'est pas vérifiée, l'appelant ne sera pas capable de gérer correctement le c
as ou moins d'octets que prévu auront été lus. C'est un bogue particulièrement i
nsidieux car dans la plupart des programmes les lectures renvoient effectivement
souvent le nombre d'octets demandé, les plantages restant sporadiques.</p> |
| 1050 |
| 1051 |
| 1052 <h3><a name="SR_NOT_CHECKED">RR: La méthode ignore le résultat de InputStream.sk
ip() (SR_NOT_CHECKED)</a></h3> |
| 1053 |
| 1054 |
| 1055 <p>Cette méthode ignore la valeur renvoyée par <code>java.io.InputStream.skip()<
/code>, qui peut sauter de multiples octets. Si la valeur renvoyée n'est pas vér
ifiée, l'appelant n'est pas capable de gérer correctement les cas ou moins d'oct
ets que prévu auront été sautés. C'est un type de bogue particulièrement insidie
ux car la plupart du temps le bon nombre d'octet sera effectivement sauté, et le
s plantages seront sporadiques. Néanmoins, sur les flux bufferisés, <code>skip()
</code> ne s'applique qu'aux données du buffer et échoue fréquemment à sauter le
nombre d'octets demandé.</p> |
| 1056 |
| 1057 |
| 1058 <h3><a name="RV_NEGATING_RESULT_OF_COMPARETO">RV: Negating the result of compare
To()/compare() (RV_NEGATING_RESULT_OF_COMPARETO)</a></h3> |
| 1059 |
| 1060 |
| 1061 <p> This code negatives the return value of a compareTo or compare method. |
| 1062 This is a questionable or bad programming practice, since if the return |
| 1063 value is Integer.MIN_VALUE, negating the return value won't |
| 1064 negate the sign of the result. You can achieve the same intended result |
| 1065 by reversing the order of the operands rather than by negating the results. |
| 1066 </p> |
| 1067 |
| 1068 |
| 1069 <h3><a name="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE">RV: Method ignores exceptiona
l return value (RV_RETURN_VALUE_IGNORED_BAD_PRACTICE)</a></h3> |
| 1070 |
| 1071 |
| 1072 <p> This method returns a value that is not checked. The return value should
be checked |
| 1073 since it can indicate an unusual or unexpected function execution. For |
| 1074 example, the <code>File.delete()</code> method returns false |
| 1075 if the file could not be successfully deleted (rather than |
| 1076 throwing an Exception). |
| 1077 If you don't check the result, you won't notice if the method invocation |
| 1078 signals unexpected behavior by returning an atypical return value. |
| 1079 </p> |
| 1080 |
| 1081 |
| 1082 <h3><a name="SI_INSTANCE_BEFORE_FINALS_ASSIGNED">SI: Initialiseur statique de cl
asse créant une instance avant que tous les champs static final soient alimentés
(SI_INSTANCE_BEFORE_FINALS_ASSIGNED)</a></h3> |
| 1083 |
| 1084 |
| 1085 <p>L'initialiseur <code>static</code> de la classe crée une instance de la class
e avant que tous les champs <code>static final</code> soient alimentés.</p> |
| 1086 |
| 1087 |
| 1088 <h3><a name="SW_SWING_METHODS_INVOKED_IN_SWING_THREAD">SW: Certaines méthodes Sw
ing ne doivent être invoquées qu'à partir du thread Swing (SW_SWING_METHODS_INVO
KED_IN_SWING_THREAD)</a></h3> |
| 1089 |
| 1090 |
| 1091 <p>(<a href="http://java.sun.com/developer/JDCTechTips/2003/tt1208.html#1">Conse
il technique JDC</a>) : les méthodes Swing <code>show()</code>, <code>setVisible
()</code> et <code>pack()</code> créent les ressources associées à la fenêtre. E
n même temps que la création de ces ressources, le système crée le processus Swi
ng de répartition de évènements.</p> |
| 1092 <p>Ceci pose problème car le processus de répartition des évènements peut notifi
er des écouteurs alors que <code>pack()</code> et <code>validate()</code> sont t
oujours en cours de traitement. Cette situation peut conduire à ce que deux proc
essus essayent d'accèder en même temps au composant, ce qui est une faille série
use qui peut provoquer des interblocages et autres problèmes de synchronisation.
</p> |
| 1093 <p>Un appel à <code>pack()</code> provoque l'initialisation du composant. Quand
ils s'initialisent (sans être forcément visibles), les composants peuvent émettr
e des évènements vers le processus de répartition des évènements de Swing.</p> |
| 1094 |
| 1095 |
| 1096 <h3><a name="SE_BAD_FIELD">Se: Champ d'instance non transient et non sérialisabl
e dans une classe sérialisable (SE_BAD_FIELD)</a></h3> |
| 1097 |
| 1098 |
| 1099 <p>Cette classe <code>Serializable</code> définit un champ d'instance non primit
if qui n'est ni <code>transient</code>, ni <code>Serializable</code> ou <code>ja
va.lang.Object</code>, et qui ne semble pas implémenter l'interface <code>Extern
alizable</code> ou les méthodes <code>readObject()</code> et <code>writeObject()
</code>. Les objets de cette classe ne seront pas désérialisés correctement si u
n objet non <code>Serializable</code> est stocké dans ce champ.</p> |
| 1100 |
| 1101 |
| 1102 <h3><a name="SE_BAD_FIELD_INNER_CLASS">Se: Non-serializable class has a serializ
able inner class (SE_BAD_FIELD_INNER_CLASS)</a></h3> |
| 1103 |
| 1104 |
| 1105 <p> This Serializable class is an inner class of a non-serializable class. |
| 1106 Thus, attempts to serialize it will also attempt to associate instance of the ou
ter |
| 1107 class with which it is associated, leading to a runtime error. |
| 1108 </p> |
| 1109 <p>If possible, making the inner class a static inner class should solve the |
| 1110 problem. Making the outer class serializable might also work, but that would |
| 1111 mean serializing an instance of the inner class would always also serialize the
instance |
| 1112 of the outer class, which it often not what you really want. |
| 1113 |
| 1114 |
| 1115 <h3><a name="SE_BAD_FIELD_STORE">Se: Valeur non sérialisable stockée dans un cha
mp d'instance de classe sérialisable (SE_BAD_FIELD_STORE)</a></h3> |
| 1116 |
| 1117 |
| 1118 <p>Une valeur non sérialisable est stockée dans un champ non <code>transient</co
de> d'une classe sérialisable.</p> |
| 1119 |
| 1120 |
| 1121 <h3><a name="SE_COMPARATOR_SHOULD_BE_SERIALIZABLE">Se: Comparateur n'implémentan
t pas Serializable (SE_COMPARATOR_SHOULD_BE_SERIALIZABLE)</a></h3> |
| 1122 |
| 1123 |
| 1124 <p>Cette classe implémente l'interface <code>Comparator</code>. Vous devriez vér
ifier si elle doit ou pas également implémenter l'interface <code>Serializable</
code>. Si un comparateur est utilisé pour construire une collection triée, telle
que <code>TreeMap</code>, alors le <code>TreeMap</code> ne sera sérialisable un
iquement si le compareteur l'est aussi. Puisque la plupart des comparateurs ont
de petits voire aucun états, les rendre sérialisables est généralement une techn
ique de programmation défensive simple et bénéfique.</p> |
| 1125 |
| 1126 |
| 1127 <h3><a name="SE_INNER_CLASS">Se: Serializable inner class (SE_INNER_CLASS)</a></
h3> |
| 1128 |
| 1129 |
| 1130 <p> This Serializable class is an inner class. Any attempt to serialize |
| 1131 it will also serialize the associated outer instance. The outer instance is seri
alizable, |
| 1132 so this won't fail, but it might serialize a lot more data than intended. |
| 1133 If possible, making the inner class a static inner class (also known as a nested
class) should solve the |
| 1134 problem. |
| 1135 |
| 1136 |
| 1137 <h3><a name="SE_NONFINAL_SERIALVERSIONID">Se: serialVersionUID n'est pas final (
SE_NONFINAL_SERIALVERSIONID)</a></h3> |
| 1138 |
| 1139 |
| 1140 <p>Cette classe définit un champ <code>serialVersionUID</code> qui n'est pas <co
de>final</code>. Ce champ devrait être rendu <code>final</code> si son but est d
e préciser l'identifiant de version utilisé pour la sérialisation.</p> |
| 1141 |
| 1142 |
| 1143 <h3><a name="SE_NONLONG_SERIALVERSIONID">Se: serialVersionUID n'est pas de type
long (SE_NONLONG_SERIALVERSIONID)</a></h3> |
| 1144 |
| 1145 |
| 1146 <p>Cette classe définit un champ <code>serialVersionUID</code> qui n'est pas de
type <code>long</code>. Ce champ devrait être de type <code>long</code> si son b
ut est de préciser l'identifiant de version utilisé pour la sérialisation.</p> |
| 1147 |
| 1148 |
| 1149 <h3><a name="SE_NONSTATIC_SERIALVERSIONID">Se: serialVersionUID n'est pas static
(SE_NONSTATIC_SERIALVERSIONID)</a></h3> |
| 1150 |
| 1151 |
| 1152 <p>Cette classe définit un champ <code>serialVersionUID</code> qui n'est pas sta
tique. Le champ devrait être rendu statique si son but est de préciser l'identif
iant de version utilisé pour la sérialisation.</p> |
| 1153 |
| 1154 |
| 1155 <h3><a name="SE_NO_SUITABLE_CONSTRUCTOR">Se: La classe est Serializable mais sa
super-classe ne possède pas de constructeur par défaut visible (SE_NO_SUITABLE_C
ONSTRUCTOR)</a></h3> |
| 1156 |
| 1157 |
| 1158 <p>Cette classe implémente l'interface <code>Serializable</code> mais pas sa sup
er-classe. Quand un tel objet est désérialisé, les champs de la classe mère doiv
ent être initialisés en invoquant le constructeur par défaut de la super-classe.
Comme la super-classe n'en a pas, sérialisation et désérialisation échoueront à
l'exécution.</p> |
| 1159 |
| 1160 |
| 1161 <h3><a name="SE_NO_SUITABLE_CONSTRUCTOR_FOR_EXTERNALIZATION">Se: La classe est E
xternalizable mais ne définit pas de constructeur par défaut (SE_NO_SUITABLE_CON
STRUCTOR_FOR_EXTERNALIZATION)</a></h3> |
| 1162 |
| 1163 |
| 1164 <p>Cette classe implémente l'interface <code>Externalizable</code>, mais ne défi
nit pas de constructeur par défaut. Quand les objets <code>Externalizable</code>
sont déserialisés, ils doivent d'abord être construit au moyen du constructeur
par défaut. Cette classe n'en ayant pas, sérialisation et désérialisation échoue
ront à l'exécution.</p> |
| 1165 |
| 1166 |
| 1167 <h3><a name="SE_READ_RESOLVE_MUST_RETURN_OBJECT">Se: La méthode readResolve doit
retourner un Object (SE_READ_RESOLVE_MUST_RETURN_OBJECT)</a></h3> |
| 1168 |
| 1169 |
| 1170 <p>Pour que la méthode <code>readResolve</code> soit prise en compte pas le méca
nisme de sérialisation, elle doit avoir Object comme type de retour.</p> |
| 1171 |
| 1172 |
| 1173 <h3><a name="SE_TRANSIENT_FIELD_NOT_RESTORED">Se: Champ "transient" non position
né lors de la désérialisation (SE_TRANSIENT_FIELD_NOT_RESTORED)</a></h3> |
| 1174 |
| 1175 |
| 1176 <p>Cette classe contient un champ qui est mis-à-jour à de nombreux endrois dans
la classe, et qui semble faire parti du démarrage de la classe. Mais, ce champ é
tant marqué comme <code>transient</code> et n'étant pas alimenté par les méthode
s <code>readObject</code> et <code>readResolve</code>, il contiendra la valeur p
ar défaut dans toutes les instances désérialisées de la classe.</p> |
| 1177 |
| 1178 |
| 1179 <h3><a name="SE_NO_SERIALVERSIONID">SnVI: La classe est Serializable, mais ne dé
finit pas serialVersionUID (SE_NO_SERIALVERSIONID)</a></h3> |
| 1180 |
| 1181 |
| 1182 <p>Cette classe implémente l'interface <code>Serializable</code> mais ne définit
pas de champ <code>serialVersionUID</code>. Une modification aussi simple qu'aj
outer une référence vers un objet <code>.class</code> ajoutera des champs synthé
tiques à la classe, ce qui malheureusement changera la valeur implicite de <code
>serialVersionUID</code> (Ex. : ajouter une référence à <code>String.class</code
> générera un champ statique <code>class$java$lang$String</code>). De plus, diff
érents compilateurs source vers bytecode peuvent utiliser différentes convention
s de nommage pour les variables synthétiques générées pour référencer les objets
classes et les classes internes. Afin de garantir l'interopérabilité de <code>S
erializable</code> suivant les versions, pensez à ajouter un champ <code>serialV
ersionUID</code> explicite.</p> |
| 1183 |
| 1184 |
| 1185 <h3><a name="UI_INHERITANCE_UNSAFE_GETRESOURCE">UI: L'utilisation de GetResource
peut-être instable si la classe est étendue (UI_INHERITANCE_UNSAFE_GETRESOURCE)
</a></h3> |
| 1186 |
| 1187 |
| 1188 <p>Appeler <code>this.getClass().getResource(...)</code> peut rendre des résulta
ts différents de ceux attendus si la classe est étendue par une classe d'un autr
e paquetage.</p> |
| 1189 |
| 1190 |
| 1191 <h3><a name="BC_IMPOSSIBLE_CAST">BC: Transtypage impossible (BC_IMPOSSIBLE_CAST)
</a></h3> |
| 1192 |
| 1193 |
| 1194 <p>Ce trantypage lancera toujours une exception <code>ClassCastException</code>.
</p> |
| 1195 |
| 1196 |
| 1197 <h3><a name="BC_IMPOSSIBLE_DOWNCAST">BC: Impossible downcast (BC_IMPOSSIBLE_DOWN
CAST)</a></h3> |
| 1198 |
| 1199 |
| 1200 <p> |
| 1201 This cast will always throw a ClassCastException. |
| 1202 The analysis believes it knows |
| 1203 the precise type of the value being cast, and the attempt to |
| 1204 downcast it to a subtype will always fail by throwing a ClassCastException. |
| 1205 </p> |
| 1206 |
| 1207 |
| 1208 <h3><a name="BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY">BC: Impossible downcast of toArr
ay() result (BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY)</a></h3> |
| 1209 |
| 1210 |
| 1211 <p> |
| 1212 This code is casting the result of calling <code>toArray()</code> on a collectio
n |
| 1213 to a type more specific than <code>Object[]</code>, as in:</p> |
| 1214 <pre> |
| 1215 String[] getAsArray(Collection<String> c) { |
| 1216 return (String[]) c.toArray(); |
| 1217 } |
| 1218 </pre> |
| 1219 <p>This will usually fail by throwing a ClassCastException. The <code>toArray()<
/code> |
| 1220 of almost all collections return an <code>Object[]</code>. They can't really do
anything else, |
| 1221 since the Collection object has no reference to the declared generic type of the
collection. |
| 1222 <p>The correct way to do get an array of a specific type from a collection is to
use |
| 1223 <code>c.toArray(new String[]);</code> |
| 1224 or <code>c.toArray(new String[c.size()]);</code> (the latter is slightly more
efficient). |
| 1225 <p>There is one common/known exception exception to this. The <code>toArray()</c
ode> |
| 1226 method of lists returned by <code>Arrays.asList(...)</code> will return a covari
antly |
| 1227 typed array. For example, <code>Arrays.asArray(new String[] { "a" }).toArray()</
code> |
| 1228 will return a <code>String []</code>. FindBugs attempts to detect and suppress |
| 1229 such cases, but may miss some. |
| 1230 </p> |
| 1231 |
| 1232 |
| 1233 <h3><a name="BC_IMPOSSIBLE_INSTANCEOF">BC: instanceof renverra toujours faux (BC
_IMPOSSIBLE_INSTANCEOF)</a></h3> |
| 1234 |
| 1235 |
| 1236 <p>Ce test <code>instanceof</code> renverra toujours faux. Même s'il est sûr, as
surez-vous qu'il ne s'agisse pas d'une erreur logique ou d'une mauvaise compréhe
nsion.</p> |
| 1237 |
| 1238 |
| 1239 <h3><a name="BIT_ADD_OF_SIGNED_BYTE">BIT: Bitwise add of signed byte value (BIT_
ADD_OF_SIGNED_BYTE)</a></h3> |
| 1240 |
| 1241 |
| 1242 <p> Adds a byte value and a value which is known to have the 8 lower bits clear. |
| 1243 Values loaded from a byte array are sign extended to 32 bits |
| 1244 before any any bitwise operations are performed on the value. |
| 1245 Thus, if <code>b[0]</code> contains the value <code>0xff</code>, and |
| 1246 <code>x</code> is initially 0, then the code |
| 1247 <code>((x << 8) + b[0])</code> will sign extend <code>0xff</code> |
| 1248 to get <code>0xffffffff</code>, and thus give the value |
| 1249 <code>0xffffffff</code> as the result. |
| 1250 </p> |
| 1251 |
| 1252 <p>In particular, the following code for packing a byte array into an int is bad
ly wrong: </p> |
| 1253 <pre> |
| 1254 int result = 0; |
| 1255 for(int i = 0; i < 4; i++) |
| 1256 result = ((result << 8) + b[i]); |
| 1257 </pre> |
| 1258 |
| 1259 <p>The following idiom will work instead: </p> |
| 1260 <pre> |
| 1261 int result = 0; |
| 1262 for(int i = 0; i < 4; i++) |
| 1263 result = ((result << 8) + (b[i] & 0xff)); |
| 1264 </pre> |
| 1265 |
| 1266 |
| 1267 |
| 1268 <h3><a name="BIT_AND">BIT: Masques binaires incompatibles (BIT_AND)</a></h3> |
| 1269 |
| 1270 |
| 1271 <p>Cette méthode compare une expression de la forme (a <code>&</code> C) ave
c D, qui est toujours inégale en raison des valeurs spécifiques des constantes C
et D. Cela peut indiquer une faute de frappe ou une erreur logique.</p> |
| 1272 |
| 1273 |
| 1274 <h3><a name="BIT_AND_ZZ">BIT: Masques binaires incompatibles (BIT_AND_ZZ)</a></h
3> |
| 1275 |
| 1276 |
| 1277 <p>Cette méthode compare une expression de la forme (a <code>&</code> 0) ave
c 0, qui est toujours égale. Ceci peut indiquer une faute de frappe ou une erreu
r logique.</p> |
| 1278 |
| 1279 |
| 1280 <h3><a name="BIT_IOR">BIT: Masques binaires incompatibles (BIT_IOR)</a></h3> |
| 1281 |
| 1282 |
| 1283 <p>Cette méthode compare une expression de la forme (a <code>|</code> C) avec D,
qui est toujours inégale en raison des valeurs spécifiques des constantes C et
D. Ceci peut indiquer une erreur logique ou une faute de frappe.</p> |
| 1284 <p>Typiquement, ce bogue arrive quand du code essaye d'effectuer un test d'appar
ition d'un bit mais utilise l'opérateur OU ("<code>|</code>") au lieu de l'opéra
teur ET ("<code>&</code>").</p> |
| 1285 |
| 1286 |
| 1287 <h3><a name="BIT_IOR_OF_SIGNED_BYTE">BIT: Ou binaire d'un octet signé (BIT_IOR_O
F_SIGNED_BYTE)</a></h3> |
| 1288 |
| 1289 |
| 1290 <p>Charge une valeur à partir d'un tableau d'octets et effectue un ou binaire su
r cette valeur. Les valeurs venant d'un tableau d'octet sont signées et risquent
donc de ne pas se comporter comme prévue.</p> |
| 1291 |
| 1292 |
| 1293 <h3><a name="BIT_SIGNED_CHECK_HIGH_BIT">BIT: Check for sign of bitwise operation
(BIT_SIGNED_CHECK_HIGH_BIT)</a></h3> |
| 1294 |
| 1295 |
| 1296 <p> This method compares an expression such as</p> |
| 1297 <pre>((event.detail & SWT.SELECTED) > 0)</pre>. |
| 1298 <p>Using bit arithmetic and then comparing with the greater than operator can |
| 1299 lead to unexpected results (of course depending on the value of |
| 1300 SWT.SELECTED). If SWT.SELECTED is a negative number, this is a candidate |
| 1301 for a bug. Even when SWT.SELECTED is not negative, it seems good practice |
| 1302 to use '!= 0' instead of '> 0'. |
| 1303 </p> |
| 1304 <p> |
| 1305 <em>Boris Bokowski</em> |
| 1306 </p> |
| 1307 |
| 1308 |
| 1309 <h3><a name="BOA_BADLY_OVERRIDDEN_ADAPTER">BOA: La classe surcharge mal une méth
ode implémentée dans une superclasse Adapter (BOA_BADLY_OVERRIDDEN_ADAPTER)</a><
/h3> |
| 1310 |
| 1311 |
| 1312 <p>Cette méthode surcharge une méthode provenant d'une classe mère qui est un <c
ode>Adapter</code> qui implémente un <code>Listener</code> défini dans le paquet
age <code>java.awt.event</code> ou <code>javax.swing.event</code>. En conséquenc
e, cette méthode ne sera pas appelée quand l'évènement se produira.</p> |
| 1313 |
| 1314 |
| 1315 <h3><a name="ICAST_BAD_SHIFT_AMOUNT">BSHIFT: Décalage d'un int hors de proportio
n (0..31) (ICAST_BAD_SHIFT_AMOUNT)</a></h3> |
| 1316 |
| 1317 |
| 1318 <p>Un décalage de n bits est effectué avec n hors des limites (0..31). Ceci résu
lte en l'utilisation des 5 bits inférieurs de l'entier pour décider de la valeur
du décalage. Ce n'est sans doute pas l'effet recherché et est pour le moins sou
rce de confusion.</p> |
| 1319 |
| 1320 |
| 1321 <h3><a name="BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR">Bx: Primitive value is
unboxed and coerced for ternary operator (BX_UNBOXED_AND_COERCED_FOR_TERNARY_OP
ERATOR)</a></h3> |
| 1322 |
| 1323 |
| 1324 <p>A wrapped primitive value is unboxed and converted to another primitive typ
e as part of the |
| 1325 evaluation of a conditional ternary operator (the <code> b ? e1 : e2</code> oper
ator). The |
| 1326 semantics of Java mandate that if <code>e1</code> and <code>e2</code> are wrappe
d |
| 1327 numeric values, the values are unboxed and converted/coerced to their common typ
e (e.g, |
| 1328 if <code>e1</code> is of type <code>Integer</code> |
| 1329 and <code>e2</code> is of type <code>Float</code>, then <code>e1</code> is unbox
ed, |
| 1330 converted to a floating point value, and boxed. See JLS Section 15.25. |
| 1331 </p> |
| 1332 |
| 1333 |
| 1334 <h3><a name="CO_COMPARETO_RESULTS_MIN_VALUE">Co: compareTo()/compare() returns I
nteger.MIN_VALUE (CO_COMPARETO_RESULTS_MIN_VALUE)</a></h3> |
| 1335 |
| 1336 |
| 1337 <p> In some situation, this compareTo or compare method returns |
| 1338 the constant Integer.MIN_VALUE, which is an exceptionally bad practice. |
| 1339 The only thing that matters about the return value of compareTo is the sign of
the result. |
| 1340 But people will sometimes negate the return value of compareTo, expecting th
at this will negate |
| 1341 the sign of the result. And it will, except in the case where the value retu
rned is Integer.MIN_VALUE. |
| 1342 So just return -1 rather than Integer.MIN_VALUE. |
| 1343 |
| 1344 |
| 1345 <h3><a name="DLS_DEAD_LOCAL_INCREMENT_IN_RETURN">DLS: Useless increment in retur
n statement (DLS_DEAD_LOCAL_INCREMENT_IN_RETURN)</a></h3> |
| 1346 |
| 1347 |
| 1348 <p>This statement has a return such as <code>return x++;</code>. |
| 1349 A postfix increment/decrement does not impact the value of the expression, |
| 1350 so this increment/decrement has no effect. |
| 1351 Please verify that this statement does the right thing. |
| 1352 </p> |
| 1353 |
| 1354 |
| 1355 <h3><a name="DLS_DEAD_STORE_OF_CLASS_LITERAL">DLS: Dead store of class literal (
DLS_DEAD_STORE_OF_CLASS_LITERAL)</a></h3> |
| 1356 |
| 1357 |
| 1358 <p> |
| 1359 This instruction assigns a class literal to a variable and then never uses it. |
| 1360 <a href="//java.sun.com/j2se/1.5.0/compatibility.html#literal">The behavior of t
his differs in Java 1.4 and in Java 5.</a> |
| 1361 In Java 1.4 and earlier, a reference to <code>Foo.class</code> would force the s
tatic initializer |
| 1362 for <code>Foo</code> to be executed, if it has not been executed already. |
| 1363 In Java 5 and later, it does not. |
| 1364 </p> |
| 1365 <p>See Sun's <a href="//java.sun.com/j2se/1.5.0/compatibility.html#literal">arti
cle on Java SE compatibility</a> |
| 1366 for more details and examples, and suggestions on how to force class initializat
ion in Java 5. |
| 1367 </p> |
| 1368 |
| 1369 |
| 1370 <h3><a name="DLS_OVERWRITTEN_INCREMENT">DLS: Incrémentation annulée (DLS_OVERWRI
TTEN_INCREMENT)</a></h3> |
| 1371 |
| 1372 |
| 1373 <p>Ce code incrémente une valeur (ex., <code>i++</code>) et en annule immédiatem
ent l'effet. Par exemple, <code>i = i++</code> réécrit de façon immédiate la val
eur incrémentée avec la valeur originale.</p> |
| 1374 |
| 1375 |
| 1376 <h3><a name="DMI_ARGUMENTS_WRONG_ORDER">DMI: Reversed method arguments (DMI_ARGU
MENTS_WRONG_ORDER)</a></h3> |
| 1377 |
| 1378 |
| 1379 <p> The arguments to this method call seem to be in the wrong order. |
| 1380 For example, a call <code>Preconditions.checkNotNull("message", message)</code> |
| 1381 has reserved arguments: the value to be checked is the first argument. |
| 1382 </p> |
| 1383 |
| 1384 |
| 1385 <h3><a name="DMI_BAD_MONTH">DMI: Valeur constante pour un mois en dehors de l'in
tervalle attendu de 0 à 11 (DMI_BAD_MONTH)</a></h3> |
| 1386 |
| 1387 |
| 1388 <p>Ce code passe une constante mois en dehors de l'intervalle de 0 à 11.</p> |
| 1389 |
| 1390 |
| 1391 <h3><a name="DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE">DMI: BigDecimal constructed
from double that isn't represented precisely (DMI_BIGDECIMAL_CONSTRUCTED_FROM_D
OUBLE)</a></h3> |
| 1392 |
| 1393 |
| 1394 <p> |
| 1395 This code creates a BigDecimal from a double value that doesn't translate well t
o a |
| 1396 decimal number. |
| 1397 For example, one might assume that writing new BigDecimal(0.1) in Java creates a
BigDecimal which is exactly equal to 0.1 (an unscaled value of 1, with a scale
of 1), but it is actually equal to 0.1000000000000000055511151231257827021181583
404541015625. |
| 1398 You probably want to use the BigDecimal.valueOf(double d) method, which uses the
String representation |
| 1399 of the double to create the BigDecimal (e.g., BigDecimal.valueOf(0.1) gives 0.1)
. |
| 1400 </p> |
| 1401 |
| 1402 |
| 1403 |
| 1404 <h3><a name="DMI_CALLING_NEXT_FROM_HASNEXT">DMI: Méthode hasNext() appelant next
() (DMI_CALLING_NEXT_FROM_HASNEXT)</a></h3> |
| 1405 |
| 1406 |
| 1407 <p>La méthode <code>hasNext()</code> appelle la méthode <code>next()</code>. C'e
st très probablement faux puisque la méthode <code>hasNext()</code> n'est pas ch
anger l'état de l'itérateur tandis que la méthode <code>next()</code> doit chang
er cet état.</p> |
| 1408 |
| 1409 |
| 1410 <h3><a name="DMI_COLLECTIONS_SHOULD_NOT_CONTAIN_THEMSELVES">DMI: Collections sho
uld not contain themselves (DMI_COLLECTIONS_SHOULD_NOT_CONTAIN_THEMSELVES)</a></
h3> |
| 1411 |
| 1412 |
| 1413 <p> This call to a generic collection's method would only make sense if a c
ollection contained |
| 1414 itself (e.g., if <code>s.contains(s)</code> were true). This is unlikely to be t
rue and would cause |
| 1415 problems if it were true (such as the computation of the hash code resulting in
infinite recursion). |
| 1416 It is likely that the wrong value is being passed as a parameter. |
| 1417 </p> |
| 1418 |
| 1419 |
| 1420 <h3><a name="DMI_DOH">DMI: D'oh! A nonsensical method invocation (DMI_DOH)</a></
h3> |
| 1421 |
| 1422 |
| 1423 <p> |
| 1424 This partical method invocation doesn't make sense, for reasons that should be a
pparent from inspection. |
| 1425 </p> |
| 1426 |
| 1427 |
| 1428 |
| 1429 <h3><a name="DMI_INVOKING_HASHCODE_ON_ARRAY">DMI: Invocation of hashCode on an a
rray (DMI_INVOKING_HASHCODE_ON_ARRAY)</a></h3> |
| 1430 |
| 1431 |
| 1432 <p> |
| 1433 The code invokes hashCode on an array. Calling hashCode on |
| 1434 an array returns the same value as System.identityHashCode, and ingores |
| 1435 the contents and length of the array. If you need a hashCode that |
| 1436 depends on the contents of an array <code>a</code>, |
| 1437 use <code>java.util.Arrays.hashCode(a)</code>. |
| 1438 |
| 1439 </p> |
| 1440 |
| 1441 |
| 1442 <h3><a name="DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT">DMI: Double.longBitsToDoubl
e invoked on an int (DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT)</a></h3> |
| 1443 |
| 1444 |
| 1445 <p> The Double.longBitsToDouble method is invoked, but a 32 bit int value is pas
sed |
| 1446 as an argument. This almostly certainly is not intended and is unlikely |
| 1447 to give the intended result. |
| 1448 </p> |
| 1449 |
| 1450 |
| 1451 <h3><a name="DMI_VACUOUS_SELF_COLLECTION_CALL">DMI: Vacuous call to collections
(DMI_VACUOUS_SELF_COLLECTION_CALL)</a></h3> |
| 1452 |
| 1453 |
| 1454 <p> This call doesn't make sense. For any collection <code>c</code>, callin
g <code>c.containsAll(c)</code> should |
| 1455 always be true, and <code>c.retainAll(c)</code> should have no effect. |
| 1456 </p> |
| 1457 |
| 1458 |
| 1459 <h3><a name="DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION">Dm: La réflexion ne pe
ut pas être utilisée pour vérifier la présence d'une annotation avec la rétentio
n par défaut (DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION)</a></h3> |
| 1460 |
| 1461 |
| 1462 <p>A moins qu'une annotation ait elle même été annotée avec une <code>@Retention
</code> différente de la rétention "source uniquement" par défaut, l'annotation
n'est pas conservée dans le fichier .class et ne peut pas être utilisée par réfl
exion (par exemple avec la méthode <code>isAnnotationPresent()</code>).</p> |
| 1463 |
| 1464 |
| 1465 <h3><a name="DMI_FUTILE_ATTEMPT_TO_CHANGE_MAXPOOL_SIZE_OF_SCHEDULED_THREAD_POOL_
EXECUTOR">Dm: Futile attempt to change max pool size of ScheduledThreadPoolExecu
tor (DMI_FUTILE_ATTEMPT_TO_CHANGE_MAXPOOL_SIZE_OF_SCHEDULED_THREAD_POOL_EXECUTOR
)</a></h3> |
| 1466 |
| 1467 |
| 1468 <p>(<a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/Sche
duledThreadPoolExecutor.html">Javadoc</a>) |
| 1469 While ScheduledThreadPoolExecutor inherits from ThreadPoolExecutor, a few of the
inherited tuning methods are not useful for it. In particular, because it acts
as a fixed-sized pool using corePoolSize threads and an unbounded queue, adjustm
ents to maximumPoolSize have no useful effect. |
| 1470 </p> |
| 1471 |
| 1472 |
| 1473 |
| 1474 <h3><a name="DMI_SCHEDULED_THREAD_POOL_EXECUTOR_WITH_ZERO_CORE_THREADS">Dm: Crea
tion of ScheduledThreadPoolExecutor with zero core threads (DMI_SCHEDULED_THREAD
_POOL_EXECUTOR_WITH_ZERO_CORE_THREADS)</a></h3> |
| 1475 |
| 1476 |
| 1477 <p>(<a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/Sche
duledThreadPoolExecutor.html#ScheduledThreadPoolExecutor(int)">Javadoc</a>) |
| 1478 A ScheduledThreadPoolExecutor with zero core threads will never execute anything
; changes to the max pool size are ignored. |
| 1479 </p> |
| 1480 |
| 1481 |
| 1482 |
| 1483 <h3><a name="DMI_VACUOUS_CALL_TO_EASYMOCK_METHOD">Dm: Useless/vacuous call to Ea
syMock method (DMI_VACUOUS_CALL_TO_EASYMOCK_METHOD)</a></h3> |
| 1484 |
| 1485 |
| 1486 <p>This call doesn't pass any objects to the EasyMock method, so the call do
esn't do anything. |
| 1487 </p> |
| 1488 |
| 1489 |
| 1490 |
| 1491 <h3><a name="EC_ARRAY_AND_NONARRAY">EC: Utilisation de equals() pour comparer un
tableau et un objet (EC_ARRAY_AND_NONARRAY)</a></h3> |
| 1492 |
| 1493 |
| 1494 <p>Cette méthode appelle <code>equals(Object o)</code> pour comparer un tableau
et une référence qui ne semble pas être un tableau. Si les choses comparées sont
de type différents, il est garanti qu'elles seront non égales et la comparaison
est probablement une erreur. Même si les deux sont des tableaux, la méthode <co
de>equals()</code> détermine seulement si les deux tableaux sont le même objet.
Pour comparer le contenu de deux tableaux, utilisez <code>java.util.Arrays.equal
s(Object[], Object[])</code>.</p> |
| 1495 |
| 1496 |
| 1497 <h3><a name="EC_BAD_ARRAY_COMPARE">EC: Appel à equals() sur un tableau équivalen
t à == (EC_BAD_ARRAY_COMPARE)</a></h3> |
| 1498 |
| 1499 |
| 1500 <p>Cette méthode invoque la méthode <code>equals(Object o)</code> d'un tableau.
Comme les tableaux ne surchargent pas la méthode <code>equals()</code> de <code>
Object</code>, cet appel revient à comparer les adresses. Pour comparer les cont
enus de tableaux, utilisez <code>java.util.Arrays.equals(Object[], Object[])</co
de>.</p> |
| 1501 |
| 1502 |
| 1503 <h3><a name="EC_INCOMPATIBLE_ARRAY_COMPARE">EC: equals(...) used to compare inco
mpatible arrays (EC_INCOMPATIBLE_ARRAY_COMPARE)</a></h3> |
| 1504 |
| 1505 |
| 1506 <p> |
| 1507 This method invokes the .equals(Object o) to compare two arrays, but the arrays
of |
| 1508 of incompatible types (e.g., String[] and StringBuffer[], or String[] and int[])
. |
| 1509 They will never be equal. In addition, when equals(...) is used to compare array
s it |
| 1510 only checks to see if they are the same array, and ignores the contents of the a
rrays. |
| 1511 </p> |
| 1512 |
| 1513 |
| 1514 <h3><a name="EC_NULL_ARG">EC: Appel de equals() avec un argument à null (EC_NULL
_ARG)</a></h3> |
| 1515 |
| 1516 |
| 1517 <p>Cette méthode appelle <code>equals(Object)</code>, passant une valeur à <code
>null</code> comme argument. D'après le contrat de la méthode <code>equals()</co
de>, cet appel devrait systématiquement renvoyer <code>false</code>.</p> |
| 1518 |
| 1519 |
| 1520 <h3><a name="EC_UNRELATED_CLASS_AND_INTERFACE">EC: Appel de equals() comparant u
ne classe et une interface sans relation (EC_UNRELATED_CLASS_AND_INTERFACE)</a><
/h3> |
| 1521 |
| 1522 |
| 1523 <p>Cette méthode appelle <code>equals(Object)</code> sur deux références, l'une
de classe, l'autre d'interface, alors que ni la classe, ni aucune de ses sous cl
asses abstraites n'implémente l'interface. Les objets comparés ne font donc prob
ablement pas partie de la même hiérarchie de classe à l'exécution (à moins que c
ertaines classes de l'application n'est pas été analysées ou soient chargées dyn
amiquement à l'exécution). En accord avec le contrat de <code>equals()</code>, d
es objets de classes différentes doivent toujours être non égaux, donc le résult
at de cette comparaison par <code>java.lang.Object.equals(Object)</code> renverr
a systèmatiquement <code>false</code> à l'exécution.</p> |
| 1524 |
| 1525 |
| 1526 <h3><a name="EC_UNRELATED_INTERFACES">EC: Appel de equals() comparant différente
s interfaces (EC_UNRELATED_INTERFACES)</a></h3> |
| 1527 |
| 1528 |
| 1529 <p>Cette méthode appelle <code>equals(Object)</code> pour deux références d'inte
rfaces sans rapport, aucune n'étant un sous-type de l'autre et aucune classe non
abstraite implémentant les deux interfaces. Les objets comparés ne sont donc pr
obablement pas de la même classe à l'éxécution (au moins que certaines classes d
e l'application n'aient pas été analysées ou qu'il y ait des chargements dynamiq
ues). D'après le contrat de <code>equals()</code>, les objets de classes différe
ntes devraient toujours être inégaux.</p> |
| 1530 |
| 1531 |
| 1532 <h3><a name="EC_UNRELATED_TYPES">EC: Appel de equals() comparant des types diffé
rents (EC_UNRELATED_TYPES)</a></h3> |
| 1533 |
| 1534 |
| 1535 <p>Cette méthode appelle <code>equals(Object)</code> pour deux références de typ
e différents, sans sous-classe commune. Les objets comparés ne sont donc probabl
ement pas de la même classe à l'éxécution (au moins que certaines classes de l'a
pplication n'aient pas été analysées ou qu'il y ait des chargements dynamiques).
D'après le contrat de <code>equals()</code>, les objets de classes différentes
devraient toujours être inégaux, c'est pourquoi la comparaison a de fortes chanc
es de toujours renvoyer <code>false</code> à l'exécution.</p> |
| 1536 |
| 1537 |
| 1538 <h3><a name="EC_UNRELATED_TYPES_USING_POINTER_EQUALITY">EC: Using pointer equali
ty to compare different types (EC_UNRELATED_TYPES_USING_POINTER_EQUALITY)</a></h
3> |
| 1539 |
| 1540 |
| 1541 <p> This method uses using pointer equality to compare two references that seem
to be of |
| 1542 different types. The result of this comparison will always be false at runtime. |
| 1543 </p> |
| 1544 |
| 1545 |
| 1546 <h3><a name="EQ_ALWAYS_FALSE">Eq: equals method always returns false (EQ_ALWAYS_
FALSE)</a></h3> |
| 1547 |
| 1548 |
| 1549 <p> This class defines an equals method that always returns false. This means
that an object is not equal to itself, and it is impossible to create useful Map
s or Sets of this class. More fundamentally, it means |
| 1550 that equals is not reflexive, one of the requirements of the equals method.</p> |
| 1551 <p>The likely intended semantics are object identity: that an object is equal to
itself. This is the behavior inherited from class <code>Object</code>. If you n
eed to override an equals inherited from a different |
| 1552 superclass, you can use use:</p> |
| 1553 <pre> |
| 1554 public boolean equals(Object o) { return this == o; } |
| 1555 </pre> |
| 1556 |
| 1557 |
| 1558 <h3><a name="EQ_ALWAYS_TRUE">Eq: equals method always returns true (EQ_ALWAYS_TR
UE)</a></h3> |
| 1559 |
| 1560 |
| 1561 <p> This class defines an equals method that always returns true. This is imag
inative, but not very smart. |
| 1562 Plus, it means that the equals method is not symmetric. |
| 1563 </p> |
| 1564 |
| 1565 |
| 1566 <h3><a name="EQ_COMPARING_CLASS_NAMES">Eq: equals method compares class names ra
ther than class objects (EQ_COMPARING_CLASS_NAMES)</a></h3> |
| 1567 |
| 1568 |
| 1569 <p> This method checks to see if two objects are the same class by checking to
see if the names |
| 1570 of their classes are equal. You can have different classes with the same name if
they are loaded by |
| 1571 different class loaders. Just check to see if the class objects are the same. |
| 1572 </p> |
| 1573 |
| 1574 |
| 1575 <h3><a name="EQ_DONT_DEFINE_EQUALS_FOR_ENUM">Eq: Covariant equals() method defin
ed for enum (EQ_DONT_DEFINE_EQUALS_FOR_ENUM)</a></h3> |
| 1576 |
| 1577 |
| 1578 <p> This class defines an enumeration, and equality on enumerations are define
d |
| 1579 using object identity. Defining a covariant equals method for an enumeration |
| 1580 value is exceptionally bad practice, since it would likely result |
| 1581 in having two different enumeration values that compare as equals using |
| 1582 the covariant enum method, and as not equal when compared normally. |
| 1583 Don't do it. |
| 1584 </p> |
| 1585 |
| 1586 |
| 1587 <h3><a name="EQ_OTHER_NO_OBJECT">Eq: equals() method defined that doesn't overri
de equals(Object) (EQ_OTHER_NO_OBJECT)</a></h3> |
| 1588 |
| 1589 |
| 1590 <p> This class defines an <code>equals()</code> |
| 1591 method, that doesn't override the normal <code>equals(Object)</code> method |
| 1592 defined in the base <code>java.lang.Object</code> class. Instead, it |
| 1593 inherits an <code>equals(Object)</code> method from a superclass. |
| 1594 The class should probably define a <code>boolean equals(Object)</code> method. |
| 1595 </p> |
| 1596 |
| 1597 |
| 1598 <h3><a name="EQ_OTHER_USE_OBJECT">Eq: equals() method defined that doesn't overr
ide Object.equals(Object) (EQ_OTHER_USE_OBJECT)</a></h3> |
| 1599 |
| 1600 |
| 1601 <p> This class defines an <code>equals()</code> |
| 1602 method, that doesn't override the normal <code>equals(Object)</code> method |
| 1603 defined in the base <code>java.lang.Object</code> class. |
| 1604 The class should probably define a <code>boolean equals(Object)</code> method. |
| 1605 </p> |
| 1606 |
| 1607 |
| 1608 <h3><a name="EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC">Eq: equals method overrides equ
als in superclass and may not be symmetric (EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC)<
/a></h3> |
| 1609 |
| 1610 |
| 1611 <p> This class defines an equals method that overrides an equals method in a s
uperclass. Both equals methods |
| 1612 methods use <code>instanceof</code> in the determination of whether two objects
are equal. This is fraught with peril, |
| 1613 since it is important that the equals method is symmetrical (in other words, <co
de>a.equals(b) == b.equals(a)</code>). |
| 1614 If B is a subtype of A, and A's equals method checks that the argument is an ins
tanceof A, and B's equals method |
| 1615 checks that the argument is an instanceof B, it is quite likely that the equival
ence relation defined by these |
| 1616 methods is not symmetric. |
| 1617 </p> |
| 1618 |
| 1619 |
| 1620 <h3><a name="EQ_SELF_USE_OBJECT">Eq: Définition d'une méthode equals() covariant
e, Object.equals(Object) est hérité (EQ_SELF_USE_OBJECT)</a></h3> |
| 1621 |
| 1622 |
| 1623 <p>Cette classe définit une version covariante de la méthode <code>equals()</cod
e>, mais appelle la méthode normale <code>equals(Object)</code> définie dans la
classe de base <code>java.lang.Object</code>. La classe devrait probablement déf
inir une version non covariante de <code>equals()</code>. (C'est-à-dire une méth
ode avec la signature <code>boolean equals(java.lang.Object)</code>.</p> |
| 1624 |
| 1625 |
| 1626 <h3><a name="FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER">FE: Test d'égalité avec NaN erron
é (FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER)</a></h3> |
| 1627 |
| 1628 |
| 1629 <p>Ce code vérifie si une valeur flottante est égale à la valeur spéciale "Not A
Number" (Ex. : <code>if (x == Double.NaN)</code>). La sémantique de <code>NaN</
code> fait que, par définition, aucune valeur n'est égale à <code>Nan</code>, y
compris <code>NaN</code>. Donc <code>x == Double.NaN</code> renvoi systématiquem
ent <code>false</code>.</p> |
| 1630 <p>Pour savoir si la valeur contenu dans <code>x</code> est la valeur particuliè
re "Not A Number", utilisez <code>Double.isNaN(x)</code> (ou <code>Float.isNaN(x
)</code> si <code>x</code> est en simple précision).</p> |
| 1631 |
| 1632 |
| 1633 <h3><a name="VA_FORMAT_STRING_BAD_ARGUMENT">FS: Format string placeholder incomp
atible with passed argument (VA_FORMAT_STRING_BAD_ARGUMENT)</a></h3> |
| 1634 |
| 1635 |
| 1636 <p> |
| 1637 The format string placeholder is incompatible with the corresponding |
| 1638 argument. For example, |
| 1639 <code> |
| 1640 System.out.println("%d\n", "hello"); |
| 1641 </code> |
| 1642 <p>The %d placeholder requires a numeric argument, but a string value is |
| 1643 passed instead. |
| 1644 A runtime exception will occur when |
| 1645 this statement is executed. |
| 1646 </p> |
| 1647 |
| 1648 |
| 1649 <h3><a name="VA_FORMAT_STRING_BAD_CONVERSION">FS: The type of a supplied argumen
t doesn't match format specifier (VA_FORMAT_STRING_BAD_CONVERSION)</a></h3> |
| 1650 |
| 1651 |
| 1652 <p> |
| 1653 One of the arguments is uncompatible with the corresponding format string specif
ier. |
| 1654 As a result, this will generate a runtime exception when executed. |
| 1655 For example, <code>String.format("%d", "1")</code> will generate an exception, s
ince |
| 1656 the String "1" is incompatible with the format specifier %d. |
| 1657 </p> |
| 1658 |
| 1659 |
| 1660 <h3><a name="VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED">FS: MessageForma
t supplied where printf style format expected (VA_FORMAT_STRING_EXPECTED_MESSAGE
_FORMAT_SUPPLIED)</a></h3> |
| 1661 |
| 1662 |
| 1663 <p> |
| 1664 A method is called that expects a Java printf format string and a list of argume
nts. |
| 1665 However, the format string doesn't contain any format specifiers (e.g., %s) but |
| 1666 does contain message format elements (e.g., {0}). It is likely |
| 1667 that the code is supplying a MessageFormat string when a printf-style format str
ing |
| 1668 is required. At runtime, all of the arguments will be ignored |
| 1669 and the format string will be returned exactly as provided without any formattin
g. |
| 1670 </p> |
| 1671 |
| 1672 |
| 1673 <h3><a name="VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED">FS: More arguments are pas
sed than are actually used in the format string (VA_FORMAT_STRING_EXTRA_ARGUMENT
S_PASSED)</a></h3> |
| 1674 |
| 1675 |
| 1676 <p> |
| 1677 A format-string method with a variable number of arguments is called, |
| 1678 but more arguments are passed than are actually used by the format string. |
| 1679 This won't cause a runtime exception, but the code may be silently omitting |
| 1680 information that was intended to be included in the formatted string. |
| 1681 </p> |
| 1682 |
| 1683 |
| 1684 <h3><a name="VA_FORMAT_STRING_ILLEGAL">FS: Illegal format string (VA_FORMAT_STRI
NG_ILLEGAL)</a></h3> |
| 1685 |
| 1686 |
| 1687 <p> |
| 1688 The format string is syntactically invalid, |
| 1689 and a runtime exception will occur when |
| 1690 this statement is executed. |
| 1691 </p> |
| 1692 |
| 1693 |
| 1694 <h3><a name="VA_FORMAT_STRING_MISSING_ARGUMENT">FS: Format string references mis
sing argument (VA_FORMAT_STRING_MISSING_ARGUMENT)</a></h3> |
| 1695 |
| 1696 |
| 1697 <p> |
| 1698 Not enough arguments are passed to satisfy a placeholder in the format string. |
| 1699 A runtime exception will occur when |
| 1700 this statement is executed. |
| 1701 </p> |
| 1702 |
| 1703 |
| 1704 <h3><a name="VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT">FS: No previous argument for
format string (VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT)</a></h3> |
| 1705 |
| 1706 |
| 1707 <p> |
| 1708 The format string specifies a relative index to request that the argument for th
e previous format specifier |
| 1709 be reused. However, there is no previous argument. |
| 1710 For example, |
| 1711 </p> |
| 1712 <p><code>formatter.format("%<s %s", "a", "b")</code> |
| 1713 </p> |
| 1714 <p>would throw a MissingFormatArgumentException when executed. |
| 1715 </p> |
| 1716 |
| 1717 |
| 1718 <h3><a name="GC_UNRELATED_TYPES">GC: No relationship between generic parameter a
nd method argument (GC_UNRELATED_TYPES)</a></h3> |
| 1719 |
| 1720 |
| 1721 <p> This call to a generic collection method contains an argument |
| 1722 with an incompatible class from that of the collection's parameter |
| 1723 (i.e., the type of the argument is neither a supertype nor a subtype |
| 1724 of the corresponding generic type argument). |
| 1725 Therefore, it is unlikely that the collection contains any objects |
| 1726 that are equal to the method argument used here. |
| 1727 Most likely, the wrong value is being passed to the method.</p> |
| 1728 <p>In general, instances of two unrelated classes are not equal. |
| 1729 For example, if the <code>Foo</code> and <code>Bar</code> classes |
| 1730 are not related by subtyping, then an instance of <code>Foo</code> |
| 1731 should not be equal to an instance of <code>Bar</code>. |
| 1732 Among other issues, doing so will likely result in an equals method |
| 1733 that is not symmetrical. For example, if you define the <code>Foo</code> cla
ss |
| 1734 so that a <code>Foo</code> can be equal to a <code>String</code>, |
| 1735 your equals method isn't symmetrical since a <code>String</code> can only be
equal |
| 1736 to a <code>String</code>. |
| 1737 </p> |
| 1738 <p>In rare cases, people do define nonsymmetrical equals methods and still m
anage to make |
| 1739 their code work. Although none of the APIs document or guarantee it, it is t
ypically |
| 1740 the case that if you check if a <code>Collection<String></code> contai
ns |
| 1741 a <code>Foo</code>, the equals method of argument (e.g., the equals method o
f the |
| 1742 <code>Foo</code> class) used to perform the equality checks. |
| 1743 </p> |
| 1744 |
| 1745 |
| 1746 <h3><a name="HE_SIGNATURE_DECLARES_HASHING_OF_UNHASHABLE_CLASS">HE: Signature de
clares use of unhashable class in hashed construct (HE_SIGNATURE_DECLARES_HASHIN
G_OF_UNHASHABLE_CLASS)</a></h3> |
| 1747 |
| 1748 |
| 1749 <p> A method, field or class declares a generic signature where a non-hashable
class |
| 1750 is used in context where a hashable class is required. |
| 1751 A class that declares an equals method but inherits a hashCode() method |
| 1752 from Object is unhashable, since it doesn't fulfill the requirement that |
| 1753 equal objects have equal hashCodes. |
| 1754 </p> |
| 1755 |
| 1756 |
| 1757 <h3><a name="HE_USE_OF_UNHASHABLE_CLASS">HE: Use of class without a hashCode() m
ethod in a hashed data structure (HE_USE_OF_UNHASHABLE_CLASS)</a></h3> |
| 1758 |
| 1759 |
| 1760 <p> A class defines an equals(Object) method but not a hashCode() method, |
| 1761 and thus doesn't fulfill the requirement that equal objects have equal hashCodes
. |
| 1762 An instance of this class is used in a hash data structure, making the need to |
| 1763 fix this problem of highest importance. |
| 1764 |
| 1765 |
| 1766 <h3><a name="ICAST_INT_2_LONG_AS_INSTANT">ICAST: int value converted to long and
used as absolute time (ICAST_INT_2_LONG_AS_INSTANT)</a></h3> |
| 1767 |
| 1768 |
| 1769 <p> |
| 1770 This code converts a 32-bit int value to a 64-bit long value, and then |
| 1771 passes that value for a method parameter that requires an absolute time value. |
| 1772 An absolute time value is the number |
| 1773 of milliseconds since the standard base time known as "the epoch", namely Januar
y 1, 1970, 00:00:00 GMT. |
| 1774 For example, the following method, intended to convert seconds since the epoc in
to a Date, is badly |
| 1775 broken:</p> |
| 1776 <pre> |
| 1777 Date getDate(int seconds) { return new Date(seconds * 1000); } |
| 1778 </pre> |
| 1779 <p>The multiplication is done using 32-bit arithmetic, and then converted to a 6
4-bit value. |
| 1780 When a 32-bit value is converted to 64-bits and used to express an absolute time |
| 1781 value, only dates in December 1969 and January 1970 can be represented.</p> |
| 1782 |
| 1783 <p>Correct implementations for the above method are:</p> |
| 1784 |
| 1785 <pre> |
| 1786 // Fails for dates after 2037 |
| 1787 Date getDate(int seconds) { return new Date(seconds * 1000L); } |
| 1788 |
| 1789 // better, works for all dates |
| 1790 Date getDate(long seconds) { return new Date(seconds * 1000); } |
| 1791 </pre> |
| 1792 |
| 1793 |
| 1794 <h3><a name="ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL">ICAST: Valeur entière tran
stypée en nombre flottant passée à Math.ceil (ICAST_INT_CAST_TO_DOUBLE_PASSED_TO
_CEIL)</a></h3> |
| 1795 |
| 1796 |
| 1797 <p>Ce code convertit une valeur entière en nombre flottant à double précision et
passe le résultat à la méthode <code>Math.ceil()</code>, qui arrondit un nombre
flottant à sa valeur entière immédiatement supérieure. Cette opération n'a pas
de raison d'être, puisque le transtypage d'un entier en double donne un nombre s
ans valeur après la virgule. Il est vraissemblable que l'opération qui a créé la
valeur pour la passer à <code>Math.ceil</code> visait l'utilisation de l'arithm
étique sur un nombre flottant en double précision.</p> |
| 1798 |
| 1799 |
| 1800 <h3><a name="ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND">ICAST: Valeur entière tran
stypée en flottant puis transmise à Math.round (ICAST_INT_CAST_TO_FLOAT_PASSED_T
O_ROUND)</a></h3> |
| 1801 |
| 1802 |
| 1803 <p>Ce code converti une valeur entière en flottant simple précision puis la pass
e à la méthode <code>Math.round()</code> qui renvoi l'<code>int</code> ou le <co
de>long</code> le plus proche de son paramètre. Cette opération doit toujours re
venir à ne rien faire, puisque le transtypage d'un entier en un flottant devrait
systématiquement donner un flottant sans partie décimale. Il est probable que l
'opération gérant la valeur passée à <code>Math.round()</code> devrait être effe
ctuée en arithmétique flottante.</p> |
| 1804 |
| 1805 |
| 1806 <h3><a name="IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METHOD">IJU: JUnit assertion in
run method will not be noticed by JUnit (IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METH
OD)</a></h3> |
| 1807 |
| 1808 |
| 1809 <p> A JUnit assertion is performed in a run method. Failed JUnit assertions |
| 1810 just result in exceptions being thrown. |
| 1811 Thus, if this exception occurs in a thread other than the thread that invokes |
| 1812 the test method, the exception will terminate the thread but not result |
| 1813 in the test failing. |
| 1814 </p> |
| 1815 |
| 1816 |
| 1817 <h3><a name="IJU_BAD_SUITE_METHOD">IJU: TestCase declares a bad suite method (I
JU_BAD_SUITE_METHOD)</a></h3> |
| 1818 |
| 1819 |
| 1820 <p> Class is a JUnit TestCase and defines a suite() method. |
| 1821 However, the suite method needs to be declared as either</p> |
| 1822 <pre>public static junit.framework.Test suite()</pre> |
| 1823 or |
| 1824 <pre>public static junit.framework.TestSuite suite()</pre> |
| 1825 |
| 1826 |
| 1827 <h3><a name="IJU_NO_TESTS">IJU: TestCase sans tests (IJU_NO_TESTS)</a></h3> |
| 1828 |
| 1829 |
| 1830 <p>La classe JUnit <code>TestCase</code> n'implémente aucune méthode de test.</p
> |
| 1831 |
| 1832 |
| 1833 <h3><a name="IJU_SETUP_NO_SUPER">IJU: Une classe dérivant de TestCase implémente
setUp() sans appeler super.setUp() (IJU_SETUP_NO_SUPER)</a></h3> |
| 1834 |
| 1835 |
| 1836 <p>La classe dérive de la classe <code>TestCase</code> de JUnit est implémente l
a méthode <code>setUp()</code>. La méthode <code>setUp()</code> devrait appeler
<code>super.setUp()</code>, mais ne le fait pas.</p> |
| 1837 |
| 1838 |
| 1839 <h3><a name="IJU_SUITE_NOT_STATIC">IJU: Une classe dérivant de TestCase implémen
te une méthode suite() non statique (IJU_SUITE_NOT_STATIC)</a></h3> |
| 1840 |
| 1841 |
| 1842 <p>La classe dérive de <code>TestCase</code> de JUnit et implémente une méthode
<code>suite()</code>. La méthode <code>suite()</code> devrait-être déclarée comm
e étant <code>static</code>, ce qui n'est pas fait.</p> |
| 1843 |
| 1844 |
| 1845 <h3><a name="IJU_TEARDOWN_NO_SUPER">IJU: Une classe dérivant de TestCase impléme
nte tearDown() sans appeler super.tearDown() (IJU_TEARDOWN_NO_SUPER)</a></h3> |
| 1846 |
| 1847 |
| 1848 <p>La classe dérive de la classe <code>TestCase</code> de JUnit et implémente la
méthode <code>tearDown()</code>. La méthode <code>tearDown()</code> devrait app
eler <code>super.tearDown()</code>, mais ne le fait pas.</p> |
| 1849 |
| 1850 |
| 1851 <h3><a name="IL_CONTAINER_ADDED_TO_ITSELF">IL: Un conteneur est ajouté à lui-mêm
e (IL_CONTAINER_ADDED_TO_ITSELF)</a></h3> |
| 1852 |
| 1853 |
| 1854 <p>Un conteneur est ajouté à lui-même. Il en résulte que le calcul du code de ha
chage de cet ensemble provequera une <code>StackOverflowEception</code>.</p> |
| 1855 |
| 1856 |
| 1857 <h3><a name="IL_INFINITE_LOOP">IL: Boucle apparemment inifinie (IL_INFINITE_LOOP
)</a></h3> |
| 1858 |
| 1859 |
| 1860 <p>Cette boucle ne semble pas avoir un moyen de se terminer (autrement que, peut
être, en déclenchant une exception).</p> |
| 1861 |
| 1862 |
| 1863 <h3><a name="IL_INFINITE_RECURSIVE_LOOP">IL: Boucle récursive infinie (IL_INFINI
TE_RECURSIVE_LOOP)</a></h3> |
| 1864 |
| 1865 |
| 1866 <p>Cette méthode s'appelle elle-même sans condition. Cela semble indiquer une bo
ucle récursive infinie qui se terminera sur un débordement de la pile.</p> |
| 1867 |
| 1868 |
| 1869 <h3><a name="IM_MULTIPLYING_RESULT_OF_IREM">IM: Multiplication d'un entier avec
le résulat entier d'un modulo (IM_MULTIPLYING_RESULT_OF_IREM)</a></h3> |
| 1870 |
| 1871 |
| 1872 <p>Ce code mutilplie le résultat d'un modulo avec une constante entière. Faîtes
attention à la précédence des opérateurs. Par exemple, <code>i % 60 * 1000</code
> correspond à <code>(i % 60) * 1000</code>, non à <code>i % (60 * 1000)</code>.
</p> |
| 1873 |
| 1874 |
| 1875 <h3><a name="INT_BAD_COMPARISON_WITH_INT_VALUE">INT: Bad comparison of int value
with long constant (INT_BAD_COMPARISON_WITH_INT_VALUE)</a></h3> |
| 1876 |
| 1877 |
| 1878 <p> This code compares an int value with a long constant that is outside |
| 1879 the range of values that can be represented as an int value. |
| 1880 This comparison is vacuous and possibily to be incorrect. |
| 1881 </p> |
| 1882 |
| 1883 |
| 1884 <h3><a name="INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE">INT: Bad comparison of n
onnegative value with negative constant (INT_BAD_COMPARISON_WITH_NONNEGATIVE_VAL
UE)</a></h3> |
| 1885 |
| 1886 |
| 1887 <p> This code compares a value that is guaranteed to be non-negative with a nega
tive constant. |
| 1888 </p> |
| 1889 |
| 1890 |
| 1891 <h3><a name="INT_BAD_COMPARISON_WITH_SIGNED_BYTE">INT: Bad comparison of signed
byte (INT_BAD_COMPARISON_WITH_SIGNED_BYTE)</a></h3> |
| 1892 |
| 1893 |
| 1894 <p> Signed bytes can only have a value in the range -128 to 127. Comparing |
| 1895 a signed byte with a value outside that range is vacuous and likely to be incorr
ect. |
| 1896 To convert a signed byte <code>b</code> to an unsigned value in the range 0..255
, |
| 1897 use <code>0xff & b</code> |
| 1898 </p> |
| 1899 |
| 1900 |
| 1901 <h3><a name="IO_APPENDING_TO_OBJECT_OUTPUT_STREAM">IO: Doomed attempt to append
to an object output stream (IO_APPENDING_TO_OBJECT_OUTPUT_STREAM)</a></h3> |
| 1902 |
| 1903 |
| 1904 <p> |
| 1905 This code opens a file in append mode and then wraps the result in an objec
t output stream. |
| 1906 This won't allow you to append to an existing object output stream stored i
n a file. If you want to be |
| 1907 able to append to an object output stream, you need to keep the object outp
ut stream open. |
| 1908 </p> |
| 1909 <p>The only situation in which opening a file in append mode and the writi
ng an object output stream |
| 1910 could work is if on reading the file you plan to open it in random access
mode and seek to the byte offset |
| 1911 where the append started. |
| 1912 </p> |
| 1913 |
| 1914 <p> |
| 1915 TODO: example. |
| 1916 </p> |
| 1917 |
| 1918 |
| 1919 <h3><a name="IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN">IP: Un paramètre est ré-écrit
avant d'être utilisé (IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN)</a></h3> |
| 1920 |
| 1921 |
| 1922 <p>La valeur initiale de ce paramètre est ignorée, et le paramètre est écrasé. C
eci indique généralement une erreur provenant de la croyance infondée qu'une écr
iture sur ce paramètre sera transmise à l'appelant.</p> |
| 1923 |
| 1924 |
| 1925 <h3><a name="MF_CLASS_MASKS_FIELD">MF: La classe définit un champ qui masque un
champ d'une classe mère (MF_CLASS_MASKS_FIELD)</a></h3> |
| 1926 |
| 1927 |
| 1928 <p>Cette classe définit un champ avec le même nom qu'un champ visible d'instance
d'une classe mère. C'est ambigu et peut entraîner une erreur si des méthodes me
ttent à jour ou accèdent à un des champs alors qu'elles souhaitaient utiliser l'
autre.</p> |
| 1929 |
| 1930 |
| 1931 <h3><a name="MF_METHOD_MASKS_FIELD">MF: La méthode définit une variable qui masq
ue un champ (MF_METHOD_MASKS_FIELD)</a></h3> |
| 1932 |
| 1933 |
| 1934 <p>Cette méthode définit une variable locale ayant le même nom qu'un champ de la
classe ou d'une classe mère. Ceci peut pousser la méthode à lire une valeur non
initialisée dans le champs, à le laisser non initialisé ou les deux.</p> |
| 1935 |
| 1936 |
| 1937 <h3><a name="NP_ALWAYS_NULL">NP: Déréférencement d'un pointeur null dans la méth
ode (NP_ALWAYS_NULL)</a></h3> |
| 1938 |
| 1939 |
| 1940 <p>Un pointeur à <code>null</code> est déréférencé ici. Ceci va mener à une <cod
e>NullPointerException</code> quand le code sera exécuté.</p> |
| 1941 |
| 1942 |
| 1943 <h3><a name="NP_ALWAYS_NULL_EXCEPTION">NP: Déréférencement d'un pointeur null da
ns le chemin d'exception d'une méthode (NP_ALWAYS_NULL_EXCEPTION)</a></h3> |
| 1944 |
| 1945 |
| 1946 <p>Un pointeur à <code>null</code> dans le chemin d'exception est déréférencé ic
i. Cela va mener à une <code>NullPointerException</code> quand le code sera exéc
uté. Notez que puisque FindBugs ne détecte pas les chemins d'exception irréalisa
bles, il est possible que cette alarme soit injustifiée.</p> |
| 1947 <p>Notez aussi que FindBugs considère le choix par défaut d'un <code>switch</cod
e> comme étant dans le chemin d'exception, puisque ce choix est souvent irréalis
able.</p> |
| 1948 |
| 1949 |
| 1950 <h3><a name="NP_ARGUMENT_MIGHT_BE_NULL">NP: Méthode ne testant pas les paramètre
s à null (NP_ARGUMENT_MIGHT_BE_NULL)</a></h3> |
| 1951 |
| 1952 |
| 1953 <p>Un paramètre de cette méthode a été identifié comme une valeur pouvant être à
<code>null</code>, mais qui est déréférencée sans test de nullité.</p> |
| 1954 |
| 1955 |
| 1956 <h3><a name="NP_CLOSING_NULL">NP: close() invoked on a value that is always null
(NP_CLOSING_NULL)</a></h3> |
| 1957 |
| 1958 |
| 1959 <p> close() is being invoked on a value that is always null. If this statement i
s executed, |
| 1960 a null pointer exception will occur. But the big risk here you never close |
| 1961 something that should be closed. |
| 1962 |
| 1963 |
| 1964 <h3><a name="NP_GUARANTEED_DEREF">NP: Null déréférencé (NP_GUARANTEED_DEREF)</a>
</h3> |
| 1965 |
| 1966 |
| 1967 <p>Cette méthode contient une valeur à <code>null</code> qui est déréférencée (s
auf dans les chemins impliquant une RuntimeException).</p> |
| 1968 |
| 1969 |
| 1970 <h3><a name="NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH">NP: Value is null and guaran
teed to be dereferenced on exception path (NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH
)</a></h3> |
| 1971 |
| 1972 |
| 1973 <p> |
| 1974 There is a statement or branch on an exception path |
| 1975 that if executed guarantees that |
| 1976 a value is null at this point, and that |
| 1977 value that is guaranteed to be dereferenced |
| 1978 (except on forward paths involving runtime exceptions). |
| 1979 </p> |
| 1980 |
| 1981 |
| 1982 <h3><a name="NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR">NP: Nonnull field
is not initialized (NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR)</a></h3> |
| 1983 |
| 1984 |
| 1985 <p> The field is marked as nonnull, but isn't written to by the construct
or. |
| 1986 The field might be initialized elsewhere during constructor, or might always |
| 1987 be initialized before use. |
| 1988 </p> |
| 1989 |
| 1990 |
| 1991 <h3><a name="NP_NONNULL_PARAM_VIOLATION">NP: Appel de méthode transmettant null
à un paramètre déclaré @NonNull (NP_NONNULL_PARAM_VIOLATION)</a></h3> |
| 1992 |
| 1993 |
| 1994 <p>Cette méthode passe une valeur à <code>null</code> en paramètre d'une méthode
qui a déclaré ce paramètre comme <code>@NonNull</code>.</p> |
| 1995 <p>Notez que la méthode avec l'annotation <code>@NonNull</code> peut être dans u
ne sous-classe de l'objet appelé.</p> |
| 1996 |
| 1997 |
| 1998 <h3><a name="NP_NONNULL_RETURN_VIOLATION">NP: Méthode renvoyer null mais déclaré
e @NonNull (NP_NONNULL_RETURN_VIOLATION)</a></h3> |
| 1999 |
| 2000 |
| 2001 <p>Cette méthode peut renvoyer une valeur à <code>null</code> alors que cette mé
thode (ou une méthode dérivée d'une de ses classes mère) est déclarée comme renv
oyant <code>@NonNull</code>.</p> |
| 2002 |
| 2003 |
| 2004 <h3><a name="NP_NULL_INSTANCEOF">NP: A known null value is checked to see if it
is an instance of a type (NP_NULL_INSTANCEOF)</a></h3> |
| 2005 |
| 2006 |
| 2007 <p> |
| 2008 This instanceof test will always return false, since the value being checked is
guaranteed to be null. |
| 2009 Although this is safe, make sure it isn't |
| 2010 an indication of some misunderstanding or some other logic error. |
| 2011 </p> |
| 2012 |
| 2013 |
| 2014 <h3><a name="NP_NULL_ON_SOME_PATH">NP: Possible déréférencement d'un pointeur nu
ll dans une méthode (NP_NULL_ON_SOME_PATH)</a></h3> |
| 2015 |
| 2016 |
| 2017 <p>Une valeur par référence déréférencée ici peut-être à <code>null</code> à l'e
xécution. Cela peut conduire à une <code>NullPointerException</code> quand le co
de est exécuté.</p> |
| 2018 |
| 2019 |
| 2020 <h3><a name="NP_NULL_ON_SOME_PATH_EXCEPTION">NP: Possible déréférencement d'un p
ointeur null dans le chemin d'exception d'une méthode (NP_NULL_ON_SOME_PATH_EXCE
PTION)</a></h3> |
| 2021 |
| 2022 |
| 2023 <p>Une valeur par référence qui est à <code>null</code> dans un des chemins d'ex
ception est déréférencée ici. Ceci peut conduire à une <code>NullPointerExceptio
n</code> à l'exécution du code. Notez que comme FindBugs ne repère pas les chemi
ns d'exception irréalisables, il est possible que cette alarme soit injustifiée.
</p> |
| 2024 <p>Notez également que FindBugs considère le cas par défaut d'un <code>switch</c
ode> comme faisant partie du chemin d'exception puisque ce cas est souvent inatt
endu.</p> |
| 2025 |
| 2026 |
| 2027 <h3><a name="NP_NULL_PARAM_DEREF">NP: Méthode passant null à un paramètre déréfé
rencé inconditionnellement (NP_NULL_PARAM_DEREF)</a></h3> |
| 2028 |
| 2029 |
| 2030 <p>Cet appel de méthode envoie <code>null</code> à une méthode qui peut déréfére
ncer ce paramètre de façon inconditionnelle.</p> |
| 2031 |
| 2032 |
| 2033 <h3><a name="NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS">NP: Appel de méthode pas
sant null à un paramètre déréférencé inconditionnellement (NP_NULL_PARAM_DEREF_A
LL_TARGETS_DANGEROUS)</a></h3> |
| 2034 |
| 2035 |
| 2036 <p>Une valeur pouvant être à <code>null</code> est passée lors d'un appel alors
que toutes les méthodes cibles possibles le déréférence inconditionnellement. Ce
la a de fortes chances de provoquer une <code>NullPointerException</code>.</p> |
| 2037 |
| 2038 |
| 2039 <h3><a name="NP_NULL_PARAM_DEREF_NONVIRTUAL">NP: Appel à une méthode non virtuel
le passant null à un paramètre déréférencé de façon inconditionnelle (NP_NULL_PA
RAM_DEREF_NONVIRTUAL)</a></h3> |
| 2040 |
| 2041 |
| 2042 <p>Une valeur pouvant être à <code>null</code> est passée à une méthode qui déré
férence ce paramètre de façon inconditionnelle. Cela peut se terminer en <code>N
ullPointerException</code>.</p> |
| 2043 |
| 2044 |
| 2045 <h3><a name="NP_OPTIONAL_RETURN_NULL">NP: Method with Optional return type retur
ns explicit null (NP_OPTIONAL_RETURN_NULL)</a></h3> |
| 2046 |
| 2047 |
| 2048 <p> |
| 2049 The usage of Optional return type always mean that explicit null returns wer
e not desired by design. |
| 2050 Returning a null value in such case is a contract violation and will most li
kely break clients code. |
| 2051 </p> |
| 2052 |
| 2053 |
| 2054 <h3><a name="NP_STORE_INTO_NONNULL_FIELD">NP: Stocke une valeur null dans un cha
mp annoté NonNull (NP_STORE_INTO_NONNULL_FIELD)</a></h3> |
| 2055 |
| 2056 |
| 2057 <p>Une valeur qui pourrait être à <code>null</code> est stockée dans un champ qu
i a été annoté comme <code>NonNull</code>.</p> |
| 2058 |
| 2059 |
| 2060 <h3><a name="NP_UNWRITTEN_FIELD">NP: Lecture d'un champ jamais écrit (NP_UNWRITT
EN_FIELD)</a></h3> |
| 2061 |
| 2062 |
| 2063 <p>Le programme déréférence un champ qui ne semble jamais alimenté par une valeu
r non nulle. Déréférencer cette valeur provoquera une <code>NullPointerException
</code>.</p> |
| 2064 |
| 2065 |
| 2066 <h3><a name="NM_BAD_EQUAL">Nm: La classe définit equal() ; ne devrait-ce pas êtr
e equals() ? (NM_BAD_EQUAL)</a></h3> |
| 2067 |
| 2068 |
| 2069 <p>Cette classe définit une méthode <code>equal(Object)</code>. Cette méthode ne
surcharge pas la méthode <code>equals(Object)</code> de <code>java.lang.Object<
/code>, surchage qui était pourtant sans doute le but visé.</p> |
| 2070 |
| 2071 |
| 2072 <h3><a name="NM_LCASE_HASHCODE">Nm: La classe définit hashcode() ; ne devrait-ce
pas être hashCode() ? (NM_LCASE_HASHCODE)</a></h3> |
| 2073 |
| 2074 |
| 2075 <p>Cette classe définit une méthode nommée <code>hashcode()</code>. Cette méthod
e ne surcharge pas la méthode <code>hashCode()</code> de <code>java.lang.Object<
/code>, surchage qui était pourtant sans doute le but visé.</p> |
| 2076 |
| 2077 |
| 2078 <h3><a name="NM_LCASE_TOSTRING">Nm: La classe définit tostring() ; ne devrait-ce
pas être toString() ? (NM_LCASE_TOSTRING)</a></h3> |
| 2079 |
| 2080 |
| 2081 <p>Cette classe définit une méthode appelée <code>tostring()</code>. Cette métho
de ne surcharge pas la méthode <code>toString()</code> de <code>java.lang.Object
</code>, surchage qui était pourtant sans doute le but visé.</p> |
| 2082 |
| 2083 |
| 2084 <h3><a name="NM_METHOD_CONSTRUCTOR_CONFUSION">Nm: Confusion apparente entre une
méthode et un constructeur (NM_METHOD_CONSTRUCTOR_CONFUSION)</a></h3> |
| 2085 |
| 2086 |
| 2087 <p>Cette méthode a le même nom que la classe dans laquelle elle est déclarée. Il
est probable qu'elle devait être un constructeur. |
| 2088 Si c'est bien le cas, retirez la déclaration d'une valeur de retour.</p> |
| 2089 |
| 2090 |
| 2091 <h3><a name="NM_VERY_CONFUSING">Nm: Noms de méthodes très ambigus (NM_VERY_CONFU
SING)</a></h3> |
| 2092 |
| 2093 |
| 2094 <p>Les méthodes indiquées ont des noms qui ne diffèrent que par les majuscules.
C'est d'autant plus ambigu que les classes comportant ces méthodes sont liées pa
r héritage.</p> |
| 2095 |
| 2096 |
| 2097 <h3><a name="NM_WRONG_PACKAGE">Nm: Method doesn't override method in superclass
due to wrong package for parameter (NM_WRONG_PACKAGE)</a></h3> |
| 2098 |
| 2099 |
| 2100 <p> The method in the subclass doesn't override a similar method in a supercla
ss because the type of a parameter doesn't exactly match |
| 2101 the type of the corresponding parameter in the superclass. For example, if you h
ave:</p> |
| 2102 |
| 2103 <blockquote> |
| 2104 <pre> |
| 2105 import alpha.Foo; |
| 2106 public class A { |
| 2107 public int f(Foo x) { return 17; } |
| 2108 } |
| 2109 ---- |
| 2110 import beta.Foo; |
| 2111 public class B extends A { |
| 2112 public int f(Foo x) { return 42; } |
| 2113 } |
| 2114 </pre> |
| 2115 </blockquote> |
| 2116 |
| 2117 <p>The <code>f(Foo)</code> method defined in class <code>B</code> doesn't |
| 2118 override the |
| 2119 <code>f(Foo)</code> method defined in class <code>A</code>, because the argument |
| 2120 types are <code>Foo</code>'s from different packages. |
| 2121 </p> |
| 2122 |
| 2123 |
| 2124 <h3><a name="QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT">QBA: Méthode assignant une val
eur boléenne fixe dans une expression booléenne (QBA_QUESTIONABLE_BOOLEAN_ASSIGN
MENT)</a></h3> |
| 2125 |
| 2126 |
| 2127 <p>Cette méthode assigne une valeur booléenne fixe (<code>true</code> ou <code>f
alse</code>) à une variable booléenne dans une expression <code>if</code> ou <co
de>while</code>. Il est probable que le but était d'effectuer une comparaison bo
oléenne utilisant <code>==</code> et non pas une affectation avec <code>=</code>
.</p> |
| 2128 |
| 2129 |
| 2130 <h3><a name="RC_REF_COMPARISON">RC: Comparaison de références suspecte (RC_REF_C
OMPARISON)</a></h3> |
| 2131 |
| 2132 |
| 2133 <p>Cette méthode compare deux références avec l'opérateur <code>==</code> ou <co
de>!=</code>, alors que la façon correcte de comparer les instances de ce type e
st généralement d'utiliser la méthode <code>equals()</code>. Des exemples de cla
sses qui ne doivent généralement pas être comparées par référence sont <code>jav
a.lang.Integer</code>, <code>java.lang.Float</code>, etc...</p> |
| 2134 |
| 2135 |
| 2136 <h3><a name="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE">RCN: Test de nullité
d'une valeur préalablement déréférencée (RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEE
N_A_NPE)</a></h3> |
| 2137 |
| 2138 |
| 2139 <p>Une valeur est testée ici pour savoir si elle est à <code>null</code> alors q
ue cette valeur ne peut pas être à <code>null</code> puisqu'elle a été déréféren
cée et qu'une <code>NullPointerException</code> se serait alors produite à ce mo
ment. Ce code est en contradiction avec le déréférencement préalable au sujet de
la capacité de cette valeur d'être à <code>null</code>. Soit le test est redond
ant, soit le déréférencement préalable est erroné.</p> |
| 2140 |
| 2141 |
| 2142 <h3><a name="RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION">RE: Syntaxe d'expression régu
lière invalide (RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION)</a></h3> |
| 2143 |
| 2144 |
| 2145 <p>Le code utilise une expression régulière qui est invalide selon la syntaxe de
s expressions régulières. Lors de l'exécution, une exception <code>PatternSyntax
Exception</code> sera lancée.</p> |
| 2146 |
| 2147 |
| 2148 <h3><a name="RE_CANT_USE_FILE_SEPARATOR_AS_REGULAR_EXPRESSION">RE: File.separato
r used for regular expression (RE_CANT_USE_FILE_SEPARATOR_AS_REGULAR_EXPRESSION)
</a></h3> |
| 2149 |
| 2150 |
| 2151 <p> |
| 2152 The code here uses <code>File.separator</code> |
| 2153 where a regular expression is required. This will fail on Windows |
| 2154 platforms, where the <code>File.separator</code> is a backslash, which is interp
reted in a |
| 2155 regular expression as an escape character. Amoung other options, you can just us
e |
| 2156 <code>File.separatorChar=='\\' ? "\\\\" : File.separator</code> instead of |
| 2157 <code>File.separator</code> |
| 2158 |
| 2159 </p> |
| 2160 |
| 2161 |
| 2162 <h3><a name="RE_POSSIBLE_UNINTENDED_PATTERN">RE: "." utilisé dans une expression
régulière (RE_POSSIBLE_UNINTENDED_PATTERN)</a></h3> |
| 2163 |
| 2164 |
| 2165 <p>Une fonction <code>String</code> attendant une expression régulière reçoit ".
" en paramètre. Est-ce voulu ? Par exemple, <code>s.replaceAll(".", "/")</code>
renverra une chaine dont <b>chaque</b> caractère aura été remplacé par le caract
ère '/'.</p> |
| 2166 |
| 2167 |
| 2168 <h3><a name="RV_01_TO_INT">RV: Les valeurs aléatoires entre 0 et 1 sont réduites
à l'entier 0 (RV_01_TO_INT)</a></h3> |
| 2169 |
| 2170 |
| 2171 <p>Une valeur aléatoire comprise entre 0 et 1 est réduite à la valeur entière 0.
Vous souhaitez probablement multiplier cette valeur aléatoire par quelque chose
avant de la réduire à un entier, ou utiliser la méthode <code>Random.nextInt(n)
</code>.</p> |
| 2172 |
| 2173 |
| 2174 <h3><a name="RV_ABSOLUTE_VALUE_OF_HASHCODE">RV: Bad attempt to compute absolute
value of signed 32-bit hashcode (RV_ABSOLUTE_VALUE_OF_HASHCODE)</a></h3> |
| 2175 |
| 2176 |
| 2177 <p> This code generates a hashcode and then computes |
| 2178 the absolute value of that hashcode. If the hashcode |
| 2179 is <code>Integer.MIN_VALUE</code>, then the result will be negative as well (sin
ce |
| 2180 <code>Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE</code>). |
| 2181 </p> |
| 2182 <p>One out of 2^32 strings have a hashCode of Integer.MIN_VALUE, |
| 2183 including "polygenelubricants" "GydZG_" and ""DESIGNING WORKHOUSES". |
| 2184 </p> |
| 2185 |
| 2186 |
| 2187 <h3><a name="RV_ABSOLUTE_VALUE_OF_RANDOM_INT">RV: Bad attempt to compute absolut
e value of signed random integer (RV_ABSOLUTE_VALUE_OF_RANDOM_INT)</a></h3> |
| 2188 |
| 2189 |
| 2190 <p> This code generates a random signed integer and then computes |
| 2191 the absolute value of that random integer. If the number returned by the random
number |
| 2192 generator is <code>Integer.MIN_VALUE</code>, then the result will be negative as
well (since |
| 2193 <code>Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE</code>). (Same problem ar
ised for long values as well). |
| 2194 </p> |
| 2195 |
| 2196 |
| 2197 <h3><a name="RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE">RV: Code checks for s
pecific values returned by compareTo (RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VAL
UE)</a></h3> |
| 2198 |
| 2199 |
| 2200 <p> This code invoked a compareTo or compare method, and checks to see if the
return value is a specific value, |
| 2201 such as 1 or -1. When invoking these methods, you should only check the sign of
the result, not for any specific |
| 2202 non-zero value. While many or most compareTo and compare methods only return -1,
0 or 1, some of them |
| 2203 will return other values. |
| 2204 |
| 2205 |
| 2206 <h3><a name="RV_EXCEPTION_NOT_THROWN">RV: Exception created and dropped rather t
han thrown (RV_EXCEPTION_NOT_THROWN)</a></h3> |
| 2207 |
| 2208 |
| 2209 <p> This code creates an exception (or error) object, but doesn't do anything
with it. For example, |
| 2210 something like </p> |
| 2211 <blockquote> |
| 2212 <pre> |
| 2213 if (x < 0) |
| 2214 new IllegalArgumentException("x must be nonnegative"); |
| 2215 </pre> |
| 2216 </blockquote> |
| 2217 <p>It was probably the intent of the programmer to throw the created exception:<
/p> |
| 2218 <blockquote> |
| 2219 <pre> |
| 2220 if (x < 0) |
| 2221 throw new IllegalArgumentException("x must be nonnegative"); |
| 2222 </pre> |
| 2223 </blockquote> |
| 2224 |
| 2225 |
| 2226 <h3><a name="RV_RETURN_VALUE_IGNORED">RV: La méthode ignore une valeur de retour
(RV_RETURN_VALUE_IGNORED)</a></h3> |
| 2227 |
| 2228 |
| 2229 <p>La valeur renvoyée par cette méthode devrait-être vérifiée. Une cause habitue
lle de cette alarme est d'invoquer une méthode sur un objet constant en pensant
que cela modifiera l'objet. Par exemple :</p> |
| 2230 <blockquote> |
| 2231 <pre> |
| 2232 String dateString = getHeaderField(name); |
| 2233 dateString.trim(); |
| 2234 </pre> |
| 2235 </blockquote> |
| 2236 <p>Le programmeur semble croire que la méthode <code>trim()</code> mettra à jour
l'objet <code>String</code> référencé par <code>dateString</code>. Mais, les ob
jets <code>String</code> étant constants, la fonction renvoi une nouvelle valeur
qui est ici ignorée. Le code devrait être corrigé en :</p> |
| 2237 <blockquote> |
| 2238 <pre> |
| 2239 String dateString = getHeaderField(name); |
| 2240 dateString = dateString.trim(); |
| 2241 </pre> |
| 2242 </blockquote> |
| 2243 |
| 2244 |
| 2245 <h3><a name="RpC_REPEATED_CONDITIONAL_TEST">RpC: Repeated conditional tests (RpC
_REPEATED_CONDITIONAL_TEST)</a></h3> |
| 2246 |
| 2247 |
| 2248 <p>The code contains a conditional test is performed twice, one right after the
other |
| 2249 (e.g., <code>x == 0 || x == 0</code>). Perhaps the second occurrence is intended
to be something else |
| 2250 (e.g., <code>x == 0 || y == 0</code>). |
| 2251 </p> |
| 2252 |
| 2253 |
| 2254 <h3><a name="SA_FIELD_SELF_ASSIGNMENT">SA: Auto-alimentation d'un champs (SA_FIE
LD_SELF_ASSIGNMENT)</a></h3> |
| 2255 |
| 2256 |
| 2257 <p>Cette méthode contient un champ s'auto-alimentant; par exemple :</p> |
| 2258 <pre> |
| 2259 int x; |
| 2260 public void foo() { |
| 2261 x = x; |
| 2262 } |
| 2263 </pre> |
| 2264 <p>De telles affectations sont inutiles et peuvent indiquer une faute de frappe
ou une erreur logique.</p> |
| 2265 |
| 2266 |
| 2267 <h3><a name="SA_FIELD_SELF_COMPARISON">SA: Self comparison of field with itself
(SA_FIELD_SELF_COMPARISON)</a></h3> |
| 2268 |
| 2269 |
| 2270 <p> This method compares a field with itself, and may indicate a typo or |
| 2271 a logic error. Make sure that you are comparing the right things. |
| 2272 </p> |
| 2273 |
| 2274 |
| 2275 <h3><a name="SA_FIELD_SELF_COMPUTATION">SA: Nonsensical self computation involvi
ng a field (e.g., x & x) (SA_FIELD_SELF_COMPUTATION)</a></h3> |
| 2276 |
| 2277 |
| 2278 <p> This method performs a nonsensical computation of a field with another |
| 2279 reference to the same field (e.g., x&x or x-x). Because of the nature |
| 2280 of the computation, this operation doesn't seem to make sense, |
| 2281 and may indicate a typo or |
| 2282 a logic error. Double check the computation. |
| 2283 </p> |
| 2284 |
| 2285 |
| 2286 <h3><a name="SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD">SA: Self assignment of l
ocal rather than assignment to field (SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD)
</a></h3> |
| 2287 |
| 2288 |
| 2289 <p> This method contains a self assignment of a local variable, and there |
| 2290 is a field with an identical name. |
| 2291 assignment appears to have been ; e.g.</p> |
| 2292 <pre> |
| 2293 int foo; |
| 2294 public void setFoo(int foo) { |
| 2295 foo = foo; |
| 2296 } |
| 2297 </pre> |
| 2298 <p>The assignment is useless. Did you mean to assign to the field instead?</p> |
| 2299 |
| 2300 |
| 2301 <h3><a name="SA_LOCAL_SELF_COMPARISON">SA: Self comparison of value with itself
(SA_LOCAL_SELF_COMPARISON)</a></h3> |
| 2302 |
| 2303 |
| 2304 <p> This method compares a local variable with itself, and may indicate a typo o
r |
| 2305 a logic error. Make sure that you are comparing the right things. |
| 2306 </p> |
| 2307 |
| 2308 |
| 2309 <h3><a name="SA_LOCAL_SELF_COMPUTATION">SA: Nonsensical self computation involvi
ng a variable (e.g., x & x) (SA_LOCAL_SELF_COMPUTATION)</a></h3> |
| 2310 |
| 2311 |
| 2312 <p> This method performs a nonsensical computation of a local variable with anot
her |
| 2313 reference to the same variable (e.g., x&x or x-x). Because of the nature |
| 2314 of the computation, this operation doesn't seem to make sense, |
| 2315 and may indicate a typo or |
| 2316 a logic error. Double check the computation. |
| 2317 </p> |
| 2318 |
| 2319 |
| 2320 <h3><a name="SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH">SF: Dead store due to swit
ch statement fall through (SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH)</a></h3> |
| 2321 |
| 2322 |
| 2323 <p> A value stored in the previous switch case is overwritten here due to a sw
itch fall through. It is likely that |
| 2324 you forgot to put a break or return at the end of the previous case. |
| 2325 </p> |
| 2326 |
| 2327 |
| 2328 <h3><a name="SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_THROW">SF: Dead store du
e to switch statement fall through to throw (SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHR
OUGH_TO_THROW)</a></h3> |
| 2329 |
| 2330 |
| 2331 <p> A value stored in the previous switch case is ignored here due to a switch
fall through to a place where |
| 2332 an exception is thrown. It is likely that |
| 2333 you forgot to put a break or return at the end of the previous case. |
| 2334 </p> |
| 2335 |
| 2336 |
| 2337 <h3><a name="SIC_THREADLOCAL_DEADLY_EMBRACE">SIC: Deadly embrace of non-static i
nner class and thread local (SIC_THREADLOCAL_DEADLY_EMBRACE)</a></h3> |
| 2338 |
| 2339 |
| 2340 <p> This class is an inner class, but should probably be a static inner class. |
| 2341 As it is, there is a serious danger of a deadly embrace between the inner clas
s |
| 2342 and the thread local in the outer class. Because the inner class isn't static, |
| 2343 it retains a reference to the outer class. |
| 2344 If the thread local contains a reference to an instance of the inner |
| 2345 class, the inner and outer instance will both be reachable |
| 2346 and not eligible for garbage collection. |
| 2347 </p> |
| 2348 |
| 2349 |
| 2350 <h3><a name="SIO_SUPERFLUOUS_INSTANCEOF">SIO: Vérification de type inutile avec
l'opérateur instanceof (SIO_SUPERFLUOUS_INSTANCEOF)</a></h3> |
| 2351 |
| 2352 |
| 2353 <p>Vérification de type effectuée avec l'opérateur <code>instanceof</code> alors
que cela pourrait-être déterminé statiquement.</p> |
| 2354 |
| 2355 |
| 2356 <h3><a name="SQL_BAD_PREPARED_STATEMENT_ACCESS">SQL: Méthode essayant au paramêt
re d'indice 0 d'un PreparedStatement (SQL_BAD_PREPARED_STATEMENT_ACCESS)</a></h3
> |
| 2357 |
| 2358 |
| 2359 <p>Un appel à une méthode <code>setXXX</code> d'un <code>PreparedStatement</cod
e> est réalisé sur l'indice 0. Puisque les indices des paramêtres d'un <code>Pre
paredStatement</code> commencent à 1, c'est toujours une erreur.</p> |
| 2360 |
| 2361 |
| 2362 <h3><a name="SQL_BAD_RESULTSET_ACCESS">SQL: Méthode essayant d'accèder à un cham
p de ResultSet d'indice 0 (SQL_BAD_RESULTSET_ACCESS)</a></h3> |
| 2363 |
| 2364 |
| 2365 <p>Un appel à une méthode <code>getXXX</code> ou <code>updateXXX</code> d'un <co
de>ResultSet</code> est réalisé pour l'indice 0. Puisque les indices de <code>Re
sultSet</code> commencent à 1, c'est toujours une erreur.</p> |
| 2366 |
| 2367 |
| 2368 <h3><a name="STI_INTERRUPTED_ON_CURRENTTHREAD">STI: Utilisation superflue d'un a
ppel à currentThread() pour appeler interrupted() (STI_INTERRUPTED_ON_CURRENTTHR
EAD)</a></h3> |
| 2369 |
| 2370 |
| 2371 <p>Cette méthode invoque <code>Thread.currentThread()</code> juste pour appeler
la méthode <code>interrupted()</code>. Comme <code>interrupted()</code> est une
méthode statique, il est plus simple et facile d'utiliser <code>Thread.interrupt
ed()</code>.</p> |
| 2372 |
| 2373 |
| 2374 <h3><a name="STI_INTERRUPTED_ON_UNKNOWNTHREAD">STI: Thread.interrupted() appelée
par erreur sur un objet Thread arbitraire (STI_INTERRUPTED_ON_UNKNOWNTHREAD)</a
></h3> |
| 2375 |
| 2376 |
| 2377 <p>Cette méthode invoque <code>Thread.interrupted()</code> sur un objet <code>Th
read</code> qui n'est pas le thread actif. Pusique la méthode <code>interrupted(
)</code> est statique, la méthode <code>interrupted()</code> sera appelée sur un
objet différent de celui auquel l'auteur du code pensait.</p> |
| 2378 |
| 2379 |
| 2380 <h3><a name="SE_METHOD_MUST_BE_PRIVATE">Se: Méthode devant être privée pour que
la sérialisation fonctionne (SE_METHOD_MUST_BE_PRIVATE)</a></h3> |
| 2381 |
| 2382 |
| 2383 <p>Cette classe implémente l'interface <code>Serializable</code> et défini une m
éthode pour personnaliser la sérialisation/désérialisation. Mais cette méthode n
'étant pas déclarée privée elle sera ignorée silencieusement par les API de séri
alisation/désérialisation.</p> |
| 2384 |
| 2385 |
| 2386 <h3><a name="SE_READ_RESOLVE_IS_STATIC">Se: The readResolve method must not be d
eclared as a static method. (SE_READ_RESOLVE_IS_STATIC)</a></h3> |
| 2387 |
| 2388 |
| 2389 <p> In order for the readResolve method to be recognized by the serialization |
| 2390 mechanism, it must not be declared as a static method. |
| 2391 </p> |
| 2392 |
| 2393 |
| 2394 <h3><a name="TQ_ALWAYS_VALUE_USED_WHERE_NEVER_REQUIRED">TQ: Value annotated as c
arrying a type qualifier used where a value that must not carry that qualifier i
s required (TQ_ALWAYS_VALUE_USED_WHERE_NEVER_REQUIRED)</a></h3> |
| 2395 |
| 2396 |
| 2397 <p> |
| 2398 A value specified as carrying a type qualifier annotation is |
| 2399 consumed in a location or locations requiring that the value not |
| 2400 carry that annotation. |
| 2401 </p> |
| 2402 |
| 2403 <p> |
| 2404 More precisely, a value annotated with a type qualifier specifying when=
ALWAYS |
| 2405 is guaranteed to reach a use or uses where the same type qualifier speci
fies when=NEVER. |
| 2406 </p> |
| 2407 |
| 2408 <p> |
| 2409 For example, say that @NonNegative is a nickname for |
| 2410 the type qualifier annotation @Negative(when=When.NEVER). |
| 2411 The following code will generate this warning because |
| 2412 the return statement requires a @NonNegative value, |
| 2413 but receives one that is marked as @Negative. |
| 2414 </p> |
| 2415 <blockquote> |
| 2416 <pre> |
| 2417 public @NonNegative Integer example(@Negative Integer value) { |
| 2418 return value; |
| 2419 } |
| 2420 </pre> |
| 2421 </blockquote> |
| 2422 |
| 2423 |
| 2424 <h3><a name="TQ_COMPARING_VALUES_WITH_INCOMPATIBLE_TYPE_QUALIFIERS">TQ: Comparin
g values with incompatible type qualifiers (TQ_COMPARING_VALUES_WITH_INCOMPATIBL
E_TYPE_QUALIFIERS)</a></h3> |
| 2425 |
| 2426 |
| 2427 <p> |
| 2428 A value specified as carrying a type qualifier annotation is |
| 2429 compared with a value that doesn't ever carry that qualifier. |
| 2430 </p> |
| 2431 |
| 2432 <p> |
| 2433 More precisely, a value annotated with a type qualifier specifying when=
ALWAYS |
| 2434 is compared with a value that where the same type qualifier specifies wh
en=NEVER. |
| 2435 </p> |
| 2436 |
| 2437 <p> |
| 2438 For example, say that @NonNegative is a nickname for |
| 2439 the type qualifier annotation @Negative(when=When.NEVER). |
| 2440 The following code will generate this warning because |
| 2441 the return statement requires a @NonNegative value, |
| 2442 but receives one that is marked as @Negative. |
| 2443 </p> |
| 2444 <blockquote> |
| 2445 <pre> |
| 2446 public boolean example(@Negative Integer value1, @NonNegative Integer value2) { |
| 2447 return value1.equals(value2); |
| 2448 } |
| 2449 </pre> |
| 2450 </blockquote> |
| 2451 |
| 2452 |
| 2453 <h3><a name="TQ_MAYBE_SOURCE_VALUE_REACHES_ALWAYS_SINK">TQ: Value that might not
carry a type qualifier is always used in a way requires that type qualifier (TQ
_MAYBE_SOURCE_VALUE_REACHES_ALWAYS_SINK)</a></h3> |
| 2454 |
| 2455 |
| 2456 <p> |
| 2457 A value that is annotated as possibility not being an instance of |
| 2458 the values denoted by the type qualifier, and the value is guaranteed to be
used |
| 2459 in a way that requires values denoted by that type qualifier. |
| 2460 </p> |
| 2461 |
| 2462 |
| 2463 <h3><a name="TQ_MAYBE_SOURCE_VALUE_REACHES_NEVER_SINK">TQ: Value that might carr
y a type qualifier is always used in a way prohibits it from having that type qu
alifier (TQ_MAYBE_SOURCE_VALUE_REACHES_NEVER_SINK)</a></h3> |
| 2464 |
| 2465 |
| 2466 <p> |
| 2467 A value that is annotated as possibility being an instance of |
| 2468 the values denoted by the type qualifier, and the value is guaranteed to be
used |
| 2469 in a way that prohibits values denoted by that type qualifier. |
| 2470 </p> |
| 2471 |
| 2472 |
| 2473 <h3><a name="TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED">TQ: Value annotated as n
ever carrying a type qualifier used where value carrying that qualifier is requi
red (TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED)</a></h3> |
| 2474 |
| 2475 |
| 2476 <p> |
| 2477 A value specified as not carrying a type qualifier annotation is guarant
eed |
| 2478 to be consumed in a location or locations requiring that the value does |
| 2479 carry that annotation. |
| 2480 </p> |
| 2481 |
| 2482 <p> |
| 2483 More precisely, a value annotated with a type qualifier specifying when=
NEVER |
| 2484 is guaranteed to reach a use or uses where the same type qualifier speci
fies when=ALWAYS. |
| 2485 </p> |
| 2486 |
| 2487 <p> |
| 2488 TODO: example |
| 2489 </p> |
| 2490 |
| 2491 |
| 2492 <h3><a name="TQ_UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED">TQ: Value wit
hout a type qualifier used where a value is required to have that qualifier (TQ_
UNKNOWN_VALUE_USED_WHERE_ALWAYS_STRICTLY_REQUIRED)</a></h3> |
| 2493 |
| 2494 |
| 2495 <p> |
| 2496 A value is being used in a way that requires the value be annotation wit
h a type qualifier. |
| 2497 The type qualifier is strict, so the tool rejects any values that do not hav
e |
| 2498 the appropriate annotation. |
| 2499 </p> |
| 2500 |
| 2501 <p> |
| 2502 To coerce a value to have a strict annotation, define an identity functi
on where the return value is annotated |
| 2503 with the strict annotation. |
| 2504 This is the only way to turn a non-annotated value into a value with a stric
t type qualifier annotation. |
| 2505 </p> |
| 2506 |
| 2507 |
| 2508 |
| 2509 <h3><a name="UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS">UMAC: Méthode non appela
ble définie dans une classe anonyme (UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS)<
/a></h3> |
| 2510 |
| 2511 |
| 2512 <p>Cette classe anonyme définie une méthode qui n'est pas directement appelée et
qui ne surcharge pas une méthode de la classe mère. Puisque les méthodes des au
tres classes ne peuvent pas directement invoquer les méthodes des classes anonym
es, il apparaît que cette méthode est inaccessible. Cette méthode est probableme
nt du code mort, mais il est aussi possible qu'elle essaye de surcharger une mét
hode déclarée dans la classe mère et échoue à le faire en raison d'une erreur de
type ou autre.</p> |
| 2513 |
| 2514 |
| 2515 <h3><a name="UR_UNINIT_READ">UR: Lecture d'un champ non initialisé dans un const
ructeur (UR_UNINIT_READ)</a></h3> |
| 2516 |
| 2517 |
| 2518 <p>Ce constructeur lit un champ qui n'a pas encore été initialisé. Une des cause
s les plus fréquentes est l'utilisation accidentelle par le développeur du champ
au lieu d'un des paramètres du constructeur.</p> |
| 2519 |
| 2520 |
| 2521 <h3><a name="UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR">UR: Uninitialized rea
d of field method called from constructor of superclass (UR_UNINIT_READ_CALLED_F
ROM_SUPER_CONSTRUCTOR)</a></h3> |
| 2522 |
| 2523 |
| 2524 <p> This method is invoked in the constructor of of the superclass. At this po
int, |
| 2525 the fields of the class have not yet initialized.</p> |
| 2526 <p>To make this more concrete, consider the following classes:</p> |
| 2527 <pre>abstract class A { |
| 2528 int hashCode; |
| 2529 abstract Object getValue(); |
| 2530 A() { |
| 2531 hashCode = getValue().hashCode(); |
| 2532 } |
| 2533 } |
| 2534 class B extends A { |
| 2535 Object value; |
| 2536 B(Object v) { |
| 2537 this.value = v; |
| 2538 } |
| 2539 Object getValue() { |
| 2540 return value; |
| 2541 } |
| 2542 }</pre> |
| 2543 <p>When a <code>B</code> is constructed, |
| 2544 the constructor for the <code>A</code> class is invoked |
| 2545 <em>before</em> the constructor for <code>B</code> sets <code>value</code>. |
| 2546 Thus, when the constructor for <code>A</code> invokes <code>getValue</code>, |
| 2547 an uninitialized value is read for <code>value</code> |
| 2548 </p> |
| 2549 |
| 2550 |
| 2551 <h3><a name="DMI_INVOKING_TOSTRING_ON_ANONYMOUS_ARRAY">USELESS_STRING: Invocatio
n of toString on an unnamed array (DMI_INVOKING_TOSTRING_ON_ANONYMOUS_ARRAY)</a>
</h3> |
| 2552 |
| 2553 |
| 2554 <p> |
| 2555 The code invokes toString on an (anonymous) array. Calling toString on an array
generates a fairly useless result |
| 2556 such as [C@16f0472. Consider using Arrays.toString to convert the array into a r
eadable |
| 2557 String that gives the contents of the array. See Programming Puzzlers, chapter 3
, puzzle 12. |
| 2558 </p> |
| 2559 |
| 2560 |
| 2561 <h3><a name="DMI_INVOKING_TOSTRING_ON_ARRAY">USELESS_STRING: Invocation de toStr
ing sur un tableau (DMI_INVOKING_TOSTRING_ON_ARRAY)</a></h3> |
| 2562 |
| 2563 |
| 2564 <p>Le code invoque <code>toString</code> sur un tableau, ce qui va générer un ré
sultat assez inutile du genre <code>[C@16f0472</code>. Envisagez d'utiliser <cod
e>String.valueOf</code> pour convertir un tableau en une chaine lisible contenan
t les valeurs du tableau. Cf Programming Puzzlers, chapitre 3, problème 12.</p> |
| 2565 |
| 2566 |
| 2567 <h3><a name="VA_FORMAT_STRING_BAD_CONVERSION_FROM_ARRAY">USELESS_STRING: Array f
ormatted in useless way using format string (VA_FORMAT_STRING_BAD_CONVERSION_FRO
M_ARRAY)</a></h3> |
| 2568 |
| 2569 |
| 2570 <p> |
| 2571 One of the arguments being formatted with a format string is an array. This will
be formatted |
| 2572 using a fairly useless format, such as [I@304282, which doesn't actually show th
e contents |
| 2573 of the array. |
| 2574 Consider wrapping the array using <code>Arrays.asList(...)</code> before handlin
g it off to a formatted. |
| 2575 </p> |
| 2576 |
| 2577 |
| 2578 <h3><a name="UWF_NULL_FIELD">UwF: Champ uniquement mis à null (UWF_NULL_FIELD)</
a></h3> |
| 2579 |
| 2580 |
| 2581 <p>Ce champ est uniquement alimenté par la constante <code>null</code> et donc t
outes les lectures de ce champ renverront <code>null</code>. Vérifiez si c'est u
ne erreur ou alors supprimez ce champ qui est inutile.</p> |
| 2582 |
| 2583 |
| 2584 <h3><a name="UWF_UNWRITTEN_FIELD">UwF: Champ jamais écrit (UWF_UNWRITTEN_FIELD)<
/a></h3> |
| 2585 |
| 2586 |
| 2587 <p>Ce champ n'est jamais alimenté. Toutes les lectures vont renvoyer sa valeur p
ar défaut. Recherchez les erreurs (devrait-il avoir été initialisé ?) ou supprim
ez le s'il est inutile.</p> |
| 2588 |
| 2589 |
| 2590 <h3><a name="VA_PRIMITIVE_ARRAY_PASSED_TO_OBJECT_VARARG">VA: Tableau de primitiv
es passé à une fonction attendant un nombre variable d'objets en argument (VA_PR
IMITIVE_ARRAY_PASSED_TO_OBJECT_VARARG)</a></h3> |
| 2591 |
| 2592 |
| 2593 <p>Ce code envoie un tableau de primitives à une fonction qui attend un nombre v
ariable d'objets en arguments. Ceci créé un tableau de longueur 1 pour contenir
le tableau de primitives puis le passe à la fonction.</p> |
| 2594 |
| 2595 |
| 2596 <h3><a name="LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE">LG: Potential lost logger cha
nges due to weak reference in OpenJDK (LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE)</a>
</h3> |
| 2597 |
| 2598 |
| 2599 <p>OpenJDK introduces a potential incompatibility. |
| 2600 In particular, the java.util.logging.Logger behavior has |
| 2601 changed. Instead of using strong references, it now uses weak references |
| 2602 internally. That's a reasonable change, but unfortunately some code relies on |
| 2603 the old behavior - when changing logger configuration, it simply drops the |
| 2604 logger reference. That means that the garbage collector is free to reclaim |
| 2605 that memory, which means that the logger configuration is lost. For example, |
| 2606 consider: |
| 2607 </p> |
| 2608 |
| 2609 <pre>public static void initLogging() throws Exception { |
| 2610 Logger logger = Logger.getLogger("edu.umd.cs"); |
| 2611 logger.addHandler(new FileHandler()); // call to change logger configuration |
| 2612 logger.setUseParentHandlers(false); // another call to change logger configurat
ion |
| 2613 }</pre> |
| 2614 |
| 2615 <p>The logger reference is lost at the end of the method (it doesn't |
| 2616 escape the method), so if you have a garbage collection cycle just |
| 2617 after the call to initLogging, the logger configuration is lost |
| 2618 (because Logger only keeps weak references).</p> |
| 2619 |
| 2620 <pre>public static void main(String[] args) throws Exception { |
| 2621 initLogging(); // adds a file handler to the logger |
| 2622 System.gc(); // logger configuration lost |
| 2623 Logger.getLogger("edu.umd.cs").info("Some message"); // this isn't logged to th
e file as expected |
| 2624 }</pre> |
| 2625 <p><em>Ulf Ochsenfahrt and Eric Fellheimer</em></p> |
| 2626 |
| 2627 |
| 2628 <h3><a name="OBL_UNSATISFIED_OBLIGATION">OBL: Method may fail to clean up stream
or resource (OBL_UNSATISFIED_OBLIGATION)</a></h3> |
| 2629 |
| 2630 |
| 2631 <p> |
| 2632 This method may fail to clean up (close, dispose of) a stream, |
| 2633 database object, or other |
| 2634 resource requiring an explicit cleanup operation. |
| 2635 </p> |
| 2636 |
| 2637 <p> |
| 2638 In general, if a method opens a stream or other resource, |
| 2639 the method should use a try/finally block to ensure that |
| 2640 the stream or resource is cleaned up before the method |
| 2641 returns. |
| 2642 </p> |
| 2643 |
| 2644 <p> |
| 2645 This bug pattern is essentially the same as the |
| 2646 OS_OPEN_STREAM and ODR_OPEN_DATABASE_RESOURCE |
| 2647 bug patterns, but is based on a different |
| 2648 (and hopefully better) static analysis technique. |
| 2649 We are interested is getting feedback about the |
| 2650 usefulness of this bug pattern. |
| 2651 To send feedback, either: |
| 2652 </p> |
| 2653 <ul> |
| 2654 <li>send email to findbugs@cs.umd.edu</li> |
| 2655 <li>file a bug report: <a href="http://findbugs.sourceforge.net/repo
rtingBugs.html">http://findbugs.sourceforge.net/reportingBugs.html</a></li> |
| 2656 </ul> |
| 2657 |
| 2658 <p> |
| 2659 In particular, |
| 2660 the false-positive suppression heuristics for this |
| 2661 bug pattern have not been extensively tuned, so |
| 2662 reports about false positives are helpful to us. |
| 2663 </p> |
| 2664 |
| 2665 <p> |
| 2666 See Weimer and Necula, <i>Finding and Preventing Run-Time Error Handli
ng Mistakes</i>, for |
| 2667 a description of the analysis technique. |
| 2668 </p> |
| 2669 |
| 2670 |
| 2671 <h3><a name="OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE">OBL: Method may fail to
clean up stream or resource on checked exception (OBL_UNSATISFIED_OBLIGATION_EXC
EPTION_EDGE)</a></h3> |
| 2672 |
| 2673 |
| 2674 <p> |
| 2675 This method may fail to clean up (close, dispose of) a stream, |
| 2676 database object, or other |
| 2677 resource requiring an explicit cleanup operation. |
| 2678 </p> |
| 2679 |
| 2680 <p> |
| 2681 In general, if a method opens a stream or other resource, |
| 2682 the method should use a try/finally block to ensure that |
| 2683 the stream or resource is cleaned up before the method |
| 2684 returns. |
| 2685 </p> |
| 2686 |
| 2687 <p> |
| 2688 This bug pattern is essentially the same as the |
| 2689 OS_OPEN_STREAM and ODR_OPEN_DATABASE_RESOURCE |
| 2690 bug patterns, but is based on a different |
| 2691 (and hopefully better) static analysis technique. |
| 2692 We are interested is getting feedback about the |
| 2693 usefulness of this bug pattern. |
| 2694 To send feedback, either: |
| 2695 </p> |
| 2696 <ul> |
| 2697 <li>send email to findbugs@cs.umd.edu</li> |
| 2698 <li>file a bug report: <a href="http://findbugs.sourceforge.net/repo
rtingBugs.html">http://findbugs.sourceforge.net/reportingBugs.html</a></li> |
| 2699 </ul> |
| 2700 |
| 2701 <p> |
| 2702 In particular, |
| 2703 the false-positive suppression heuristics for this |
| 2704 bug pattern have not been extensively tuned, so |
| 2705 reports about false positives are helpful to us. |
| 2706 </p> |
| 2707 |
| 2708 <p> |
| 2709 See Weimer and Necula, <i>Finding and Preventing Run-Time Error Handli
ng Mistakes</i>, for |
| 2710 a description of the analysis technique. |
| 2711 </p> |
| 2712 |
| 2713 |
| 2714 <h3><a name="DM_CONVERT_CASE">Dm: La méthode appelle les String.toUpperCase() ou
String.toLowerCase ; utilisez plutôt la version paramètrée par une Locale (DM_C
ONVERT_CASE)</a></h3> |
| 2715 |
| 2716 |
| 2717 <p>Une chaîne est mise en majuscules ou minuscules en fonction de jeu de caractè
res par défaut de la machine. Ceci peut entraîner des conversions erronées sur l
es caractères internationaux. Utilisez <code>String.toUpperCase(Locale l)</code>
ou <code>String.toLowerCase(Locale l)</code> à la place.</p> |
| 2718 |
| 2719 |
| 2720 <h3><a name="DM_DEFAULT_ENCODING">Dm: Reliance on default encoding (DM_DEFAULT_E
NCODING)</a></h3> |
| 2721 |
| 2722 |
| 2723 <p> Found a call to a method which will perform a byte to String (or String to b
yte) conversion, and will assume that the default platform encoding is suitable.
This will cause the application behaviour to vary between platforms. Use an alt
ernative API and specify a charset name or Charset object explicitly. </p> |
| 2724 |
| 2725 |
| 2726 <h3><a name="DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED">DP: Les chargeurs de cl
asses ne doivent être créés qu'à partir de block doPrivileged (DP_CREATE_CLASSLO
ADER_INSIDE_DO_PRIVILEGED)</a></h3> |
| 2727 |
| 2728 |
| 2729 <p>Ce code créé un chargeur de classes, ce qui nécessite un test de sécurité. Mê
me si ce code possède des droits suffisants, la création du chargeur de classes
devrait être effectuée dans un block <code>doPrivileged</code> au cas ou il sera
it appelé par du code ne possédant pas les droits requis.</p> |
| 2730 |
| 2731 |
| 2732 <h3><a name="DP_DO_INSIDE_DO_PRIVILEGED">DP: Méthode invoquée alors qu'elle ne d
evrait l'être qu'à partir d'un block doPrivileged (DP_DO_INSIDE_DO_PRIVILEGED)</
a></h3> |
| 2733 |
| 2734 |
| 2735 <p>Ce code invoque une méthode qui nécessite un test de sécurité sur les permiss
ions. Si ce code, bien qu'ayant les droits suffisants, peut être invoqué par du
code n'ayant pas les droits requis l'appel doit alors être effectué à l'intérieu
r d'un block <code>doPrivileged</code>.</p> |
| 2736 |
| 2737 |
| 2738 <h3><a name="EI_EXPOSE_REP">EI: Une méthode peut exposer sa représentation inter
ne en renvoyant une référence à un objet modifiable (EI_EXPOSE_REP)</a></h3> |
| 2739 |
| 2740 |
| 2741 <p>Renvoyer une référence à un objet modifiable stocké dans les champs d'un obje
t expose la représentation interne de l'objet. Si des instances sont accédées pa
r du code non fiable, et que des modifications non vérifiées peuvent compromettr
e la sécurité ou d'autres propriétés importantes, vous devez faire autre chose.
Renvoyer une nouvelle copie de l'objet est une meilleur approche dans de nombreu
ses situations.</p> |
| 2742 |
| 2743 |
| 2744 <h3><a name="EI_EXPOSE_REP2">EI2: Une méthode expose sa représentation interne e
n incorporant une référence à un objet modifiable (EI_EXPOSE_REP2)</a></h3> |
| 2745 |
| 2746 |
| 2747 <p>Ce code stocke une référence à un objet externe modifiable dans la représenta
tion interne de l'objet. Si des instances sont accédées par du code non fiable,
et que des modifications non vérifiées peuvent compromettre la sécurité ou d'aut
res propriétés importantes, vous devez faire autre chose. Stocker une copie de l
'objet est une meilleur approche dans de nombreuses situations.</p> |
| 2748 |
| 2749 |
| 2750 <h3><a name="FI_PUBLIC_SHOULD_BE_PROTECTED">FI: Un finaliseur devrait être proté
gé, pas public (FI_PUBLIC_SHOULD_BE_PROTECTED)</a></h3> |
| 2751 |
| 2752 |
| 2753 <p>La méthode <code>finalize()</code> d'une classe devrait avoir un accès protég
é, pas public.</p> |
| 2754 |
| 2755 |
| 2756 <h3><a name="EI_EXPOSE_STATIC_REP2">MS: Une méthode peut exposer un état interne
statique en stockant un objet modifiable dans un champs statique (EI_EXPOSE_STA
TIC_REP2)</a></h3> |
| 2757 |
| 2758 |
| 2759 <p>Ce code stocke une référence à un objet modifiable externe dans un champs sta
tique. Si des modifications non vérifiées de l'objet modifiable peuvent comprome
ttre la sécurité ou d'autres propriétés importantes, vous devez faire autre chos
e. Stocker une copie de l'objet est souvent une meilleur approche.</p> |
| 2760 |
| 2761 |
| 2762 <h3><a name="MS_CANNOT_BE_FINAL">MS: Un champ n'est pas final et ne peut pas êtr
e protégé face à du code malveillant (MS_CANNOT_BE_FINAL)</a></h3> |
| 2763 |
| 2764 |
| 2765 <p>Un champ statique modifiable peut-être modifié par accident ou par du code ma
lveillant. Malheureusement, la façon dont ce champ est utilisé ne permet une cor
rection aisée de ce problème.</p> |
| 2766 |
| 2767 |
| 2768 <h3><a name="MS_EXPOSE_REP">MS: Une méthode statique publique risque d'exposer u
ne représentation interne en renvoyant un tableau (MS_EXPOSE_REP)</a></h3> |
| 2769 |
| 2770 |
| 2771 <p>Une méthode statique publique renvoit une référence à un tableau faisant part
ie de l'état statique de la classe. Tout code appelant cette méthode peut librem
ent modifier le tableau sous-jacent. Une correction possible serait de renvoyer
une copie du tableau.</p> |
| 2772 |
| 2773 |
| 2774 <h3><a name="MS_FINAL_PKGPROTECT">MS: Le champ devrait être à la fois final et p
ackage protected (MS_FINAL_PKGPROTECT)</a></h3> |
| 2775 |
| 2776 |
| 2777 <p>Un champ statique modifiable peut-être changé par accident ou par du code mal
veillant d'un autre paquetage. Le champ devrait être package protected et/ou fin
al pour éviter cette vulnérabilité.</p> |
| 2778 |
| 2779 |
| 2780 <h3><a name="MS_MUTABLE_ARRAY">MS: Un champ est un tableau modifiable (MS_MUTABL
E_ARRAY)</a></h3> |
| 2781 |
| 2782 |
| 2783 <p>Le champ est une référence final static à un tableau et peut-être modifié par
accident ou par du code malveillant d'un autre paquetage. Ce code peut libremen
t modifier le contenu du tableau.</p> |
| 2784 |
| 2785 |
| 2786 <h3><a name="MS_MUTABLE_HASHTABLE">MS: Un champ modifiable est une Hashtable (MS
_MUTABLE_HASHTABLE)</a></h3> |
| 2787 |
| 2788 |
| 2789 <p>Le champ est une référence final static à une <code>Hashtable</code> et peut-
être modifié par accident ou par du code malveillant d'un autre paquetage. Ce co
de peut librement modifier le contenu de la <code>Hashtable</code>.</p> |
| 2790 |
| 2791 |
| 2792 <h3><a name="MS_OOI_PKGPROTECT">MS: Le champ devrait être sorti de l'interface e
t mis en package protected (MS_OOI_PKGPROTECT)</a></h3> |
| 2793 |
| 2794 |
| 2795 <p>Un champ final static défini dans une interface référence un objet modifiable
tel qu'un tableau ou une table de hachage. Cet objet pourrait être modifié par
accident ou par du code sournois d'un autre paquetage. Pour résoudre cela et évi
ter cette vulnérabilité, le champ doit être intégré dans une classe et sa visibi
lité modifiée en package protected.</p> |
| 2796 |
| 2797 |
| 2798 <h3><a name="MS_PKGPROTECT">MS: Un champ devrait être package protected (MS_PKGP
ROTECT)</a></h3> |
| 2799 |
| 2800 |
| 2801 <p>Un champ statique modifiable peut-être changé par accident ou par du code mal
veillant d'un autre paquetage. Le champ devrait être package protected pour évit
er cette vulnérabilité.</p> |
| 2802 |
| 2803 |
| 2804 <h3><a name="MS_SHOULD_BE_FINAL">MS: Un champ n'est pas final alors qu'il devrai
t l'être (MS_SHOULD_BE_FINAL)</a></h3> |
| 2805 |
| 2806 |
| 2807 <p>Un champ statique modifiable peut-être changé par accident ou par du code mal
veillant d'un autre paquetage. Le champ devrait être final pour éviter cette vul
nérabilité.</p> |
| 2808 |
| 2809 |
| 2810 <h3><a name="MS_SHOULD_BE_REFACTORED_TO_BE_FINAL">MS: Field isn't final but shou
ld be refactored to be so (MS_SHOULD_BE_REFACTORED_TO_BE_FINAL)</a></h3> |
| 2811 |
| 2812 |
| 2813 <p> |
| 2814 This static field public but not final, and |
| 2815 could be changed by malicious code or |
| 2816 by accident from another package. |
| 2817 The field could be made final to avoid |
| 2818 this vulnerability. However, the static initializer contains more than one write |
| 2819 to the field, so doing so will require some refactoring. |
| 2820 </p> |
| 2821 |
| 2822 |
| 2823 <h3><a name="AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION">AT: Sequence of ca
lls to concurrent abstraction may not be atomic (AT_OPERATION_SEQUENCE_ON_CONCUR
RENT_ABSTRACTION)</a></h3> |
| 2824 |
| 2825 |
| 2826 <p>This code contains a sequence of calls to a concurrent abstraction |
| 2827 (such as a concurrent hash map). |
| 2828 These calls will not be executed atomically. |
| 2829 |
| 2830 |
| 2831 <h3><a name="DC_DOUBLECHECK">DC: Possible double vérification d'un champ (DC_DOU
BLECHECK)</a></h3> |
| 2832 |
| 2833 |
| 2834 <p>Cette méthode contient peut-être une instance de verrou par double vérificati
on. Cet idiome n'est pas correct vis-à-vis de la sémantique du modèle de mémoire
Java. Pour plus d'informations, cf. la page <a href="http://www.cs.umd.edu/~pug
h/java/memoryModel/DoubleCheckedLocking.html">http://www.cs.umd.edu/~pugh/java/m
emoryModel/DoubleCheckedLocking.html</a>.</p> |
| 2835 |
| 2836 |
| 2837 <h3><a name="DL_SYNCHRONIZATION_ON_BOOLEAN">DL: Synchronization on Boolean (DL_S
YNCHRONIZATION_ON_BOOLEAN)</a></h3> |
| 2838 |
| 2839 |
| 2840 <p> The code synchronizes on a boxed primitive constant, such as an Boolean.</
p> |
| 2841 <pre> |
| 2842 private static Boolean inited = Boolean.FALSE; |
| 2843 ... |
| 2844 synchronized(inited) { |
| 2845 if (!inited) { |
| 2846 init(); |
| 2847 inited = Boolean.TRUE; |
| 2848 } |
| 2849 } |
| 2850 ... |
| 2851 </pre> |
| 2852 <p>Since there normally exist only two Boolean objects, this code could be synch
ronizing on the same object as other, unrelated code, leading to unresponsivenes
s |
| 2853 and possible deadlock</p> |
| 2854 <p>See CERT <a href="https://www.securecoding.cert.org/confluence/display/java/C
ON08-J.+Do+not+synchronize+on+objects+that+may+be+reused">CON08-J. Do not synchr
onize on objects that may be reused</a> for more information.</p> |
| 2855 |
| 2856 |
| 2857 <h3><a name="DL_SYNCHRONIZATION_ON_BOXED_PRIMITIVE">DL: Synchronization on boxed
primitive (DL_SYNCHRONIZATION_ON_BOXED_PRIMITIVE)</a></h3> |
| 2858 |
| 2859 |
| 2860 <p> The code synchronizes on a boxed primitive constant, such as an Integer.</
p> |
| 2861 <pre> |
| 2862 private static Integer count = 0; |
| 2863 ... |
| 2864 synchronized(count) { |
| 2865 count++; |
| 2866 } |
| 2867 ... |
| 2868 </pre> |
| 2869 <p>Since Integer objects can be cached and shared, |
| 2870 this code could be synchronizing on the same object as other, unrelated code, le
ading to unresponsiveness |
| 2871 and possible deadlock</p> |
| 2872 <p>See CERT <a href="https://www.securecoding.cert.org/confluence/display/java/C
ON08-J.+Do+not+synchronize+on+objects+that+may+be+reused">CON08-J. Do not synchr
onize on objects that may be reused</a> for more information.</p> |
| 2873 |
| 2874 |
| 2875 <h3><a name="DL_SYNCHRONIZATION_ON_SHARED_CONSTANT">DL: Synchronization on inter
ned String (DL_SYNCHRONIZATION_ON_SHARED_CONSTANT)</a></h3> |
| 2876 |
| 2877 |
| 2878 <p> The code synchronizes on interned String.</p> |
| 2879 <pre> |
| 2880 private static String LOCK = "LOCK"; |
| 2881 ... |
| 2882 synchronized(LOCK) { ...} |
| 2883 ... |
| 2884 </pre> |
| 2885 <p>Constant Strings are interned and shared across all other classes loaded by t
he JVM. Thus, this could |
| 2886 is locking on something that other code might also be locking. This could result
in very strange and hard to diagnose |
| 2887 blocking and deadlock behavior. See <a href="http://www.javalobby.org/java/forum
s/t96352.html">http://www.javalobby.org/java/forums/t96352.html</a> and <a href=
"http://jira.codehaus.org/browse/JETTY-352">http://jira.codehaus.org/browse/JETT
Y-352</a>. |
| 2888 </p> |
| 2889 <p>See CERT <a href="https://www.securecoding.cert.org/confluence/display/java/C
ON08-J.+Do+not+synchronize+on+objects+that+may+be+reused">CON08-J. Do not synchr
onize on objects that may be reused</a> for more information.</p> |
| 2890 |
| 2891 |
| 2892 <h3><a name="DL_SYNCHRONIZATION_ON_UNSHARED_BOXED_PRIMITIVE">DL: Synchronization
on boxed primitive values (DL_SYNCHRONIZATION_ON_UNSHARED_BOXED_PRIMITIVE)</a><
/h3> |
| 2893 |
| 2894 |
| 2895 <p> The code synchronizes on an apparently unshared boxed primitive, |
| 2896 such as an Integer.</p> |
| 2897 <pre> |
| 2898 private static final Integer fileLock = new Integer(1); |
| 2899 ... |
| 2900 synchronized(fileLock) { |
| 2901 .. do something .. |
| 2902 } |
| 2903 ... |
| 2904 </pre> |
| 2905 <p>It would be much better, in this code, to redeclare fileLock as</p> |
| 2906 <pre> |
| 2907 private static final Object fileLock = new Object(); |
| 2908 </pre> |
| 2909 <p> |
| 2910 The existing code might be OK, but it is confusing and a |
| 2911 future refactoring, such as the "Remove Boxing" refactoring in IntelliJ, |
| 2912 might replace this with the use of an interned Integer object shared |
| 2913 throughout the JVM, leading to very confusing behavior and potential deadlock. |
| 2914 </p> |
| 2915 |
| 2916 |
| 2917 <h3><a name="DM_MONITOR_WAIT_ON_CONDITION">Dm: Wait() appelé sur une Condition (
DM_MONITOR_WAIT_ON_CONDITION)</a></h3> |
| 2918 |
| 2919 |
| 2920 <p>Cette méthode appelle <code>wait()</code> sur un objet <code>java.util.concur
rent.locks.Condition</code>. L'attente d'une <code>Condition</code> devrait être
faite en utilisant l'une des méthodes <code>await()</code> définies dans l'inte
rface <code>Condition</code>.</p> |
| 2921 |
| 2922 |
| 2923 <h3><a name="DM_USELESS_THREAD">Dm: Thread créé avec la méthode run vide par déf
aut (DM_USELESS_THREAD)</a></h3> |
| 2924 |
| 2925 |
| 2926 <p>Cette méthode crée un thread sans spécifier de méthode <code>run</code>, soit
par dérivation de la classe <code>Thread</code>, soit en transmettant un objet
<code>Runnable</code>. Ce thread ne fait donc rien sauf perdre du temps.</p> |
| 2927 |
| 2928 |
| 2929 <h3><a name="ESync_EMPTY_SYNC">ESync: Bloc synchronisé vide (ESync_EMPTY_SYNC)</
a></h3> |
| 2930 |
| 2931 |
| 2932 <p>Présence d'un bloc synchronisé vide:</p> |
| 2933 <pre> |
| 2934 synchronized() {} |
| 2935 </pre> |
| 2936 <p>L'utilisation de blocs synchronisés vides est bien plus subtile et dure à réa
liser correctement que bien des gens ne le reconnaissent, et de plus ne correspo
nd que rarement à la meilleure des solutions.</p> |
| 2937 |
| 2938 |
| 2939 <h3><a name="IS2_INCONSISTENT_SYNC">IS: Synchronisation incohérente (IS2_INCONSI
STENT_SYNC)</a></h3> |
| 2940 |
| 2941 |
| 2942 <p>Les champs de cette classe semblent être accédés de façon incohérente vis-à-v
is de la synchronisation. Le détecteur de bogue juge que :</p> |
| 2943 <ol> |
| 2944 <li>la classe contient un mélange d'accès verrouillés et non verrouillés,</li> |
| 2945 <li>au moins un des accès verrouillés est effectué par une des propres méthode
s de la classe,</li> |
| 2946 <li>le nombre d'accès (lectures et écritures) non synchronisés ne représente p
as plus d'un tiers de tous les accès, avec plus de deux fois plus d'écritures qu
e de lectures.</li> |
| 2947 </ol> |
| 2948 <p>Un bogue typique déclenchant ce détecteur est l'oubli de la synchronisation s
ur l'une des méthodes d'une classe qui essaye d'être sûre vis-à-vis des threads.
</p> |
| 2949 <p>Vous pouvez sélectionner les noeuds nommés "Accès non synchronisés" pour avoi
r la position exacte dans le code où le détecteur pense qu'un champ est accédé s
ans synchronisation.</p> |
| 2950 <p>Notez qu'il y a diverses sources d'inexactitude dans ce détecteur ; par exemp
le, le détecteur ne peut pas repérer statiquement toutes les situations dans les
quelles un verrou est obtenu. En fait, même lorsque le détecteur repère effectiv
ement des accès avec et sans verrou, le code concerné peut quand même être corre
ct.</p> |
| 2951 <p>Cette description se réfère à la version "IS2" du détecteur, qui est plus pré
cise pour détecter les accès avec et sans verrous que l'ancien détecteur "IS".</
p> |
| 2952 |
| 2953 |
| 2954 <h3><a name="IS_FIELD_NOT_GUARDED">IS: Champ non protégé contre les accès concur
rents (IS_FIELD_NOT_GUARDED)</a></h3> |
| 2955 |
| 2956 |
| 2957 <p>Ce champ est annoté avec <code>net.jcip.annotations.GuardedBy</code>, mais pe
ut être utilisé d'une façon qui contredit l'annotation.</p> |
| 2958 |
| 2959 |
| 2960 <h3><a name="JLM_JSR166_LOCK_MONITORENTER">JLM: Synchronisation effectuée sur un
Lock java.util.concurrent (JLM_JSR166_LOCK_MONITORENTER)</a></h3> |
| 2961 |
| 2962 |
| 2963 <p>Cette méthode se synchronise au moyen d'une implémentation de <code>java.util
.concurrent.locks.Lock</code>. Vous devriez plutôt utiliser les méthodes <code>l
ock()</code> et <code>unlock()</code>.</p> |
| 2964 |
| 2965 |
| 2966 <h3><a name="JLM_JSR166_UTILCONCURRENT_MONITORENTER">JLM: Synchronization perfor
med on util.concurrent instance (JLM_JSR166_UTILCONCURRENT_MONITORENTER)</a></h3
> |
| 2967 |
| 2968 |
| 2969 <p> This method performs synchronization an object that is an instance of |
| 2970 a class from the java.util.concurrent package (or its subclasses). Instances |
| 2971 of these classes have their own concurrency control mechanisms that are orthogon
al to |
| 2972 the synchronization provided by the Java keyword <code>synchronized</code>. For
example, |
| 2973 synchronizing on an <code>AtomicBoolean</code> will not prevent other threads |
| 2974 from modifying the <code>AtomicBoolean</code>.</p> |
| 2975 <p>Such code may be correct, but should be carefully reviewed and documented, |
| 2976 and may confuse people who have to maintain the code at a later date. |
| 2977 </p> |
| 2978 |
| 2979 |
| 2980 <h3><a name="JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT">JLM: Using monitor style
wait methods on util.concurrent abstraction (JML_JSR166_CALLING_WAIT_RATHER_THA
N_AWAIT)</a></h3> |
| 2981 |
| 2982 |
| 2983 <p> This method calls |
| 2984 <code>wait()</code>, |
| 2985 <code>notify()</code> or |
| 2986 <code>notifyAll()()</code> |
| 2987 on an object that also provides an |
| 2988 <code>await()</code>, |
| 2989 <code>signal()</code>, |
| 2990 <code>signalAll()</code> method (such as util.concurrent Condition objects). |
| 2991 This probably isn't what you want, and even if you do want it, you should consid
er changing |
| 2992 your design, as other developers will find it exceptionally confusing. |
| 2993 </p> |
| 2994 |
| 2995 |
| 2996 <h3><a name="LI_LAZY_INIT_STATIC">LI: Initialisation paresseuse incorrecte d'un
champ statique (LI_LAZY_INIT_STATIC)</a></h3> |
| 2997 |
| 2998 |
| 2999 <p>Cette méthode contient une initialisation paresseuse non synchronisée d'un ch
amp statique non <code>volatile</code>. Comme le compilateur ou le processeur pe
uvent réordonner les instructions, les threads ne sont pas certains de voir un o
bjet complètement initialisé, <em>si la méthode peut-être appelée par de multipl
es threads</em>. Vous pouvez rendre le champs <code>volatile</code> pour corrige
r le problème. Pour plus d'informations, cf. <a href="http://www.cs.umd.edu/~pug
h/java/memoryModel/">site Web sur le modèle mémoire de Java</a>.</p> |
| 3000 |
| 3001 |
| 3002 <h3><a name="LI_LAZY_INIT_UPDATE_STATIC">LI: Incorrect lazy initialization and u
pdate of static field (LI_LAZY_INIT_UPDATE_STATIC)</a></h3> |
| 3003 |
| 3004 |
| 3005 <p> This method contains an unsynchronized lazy initialization of a static field
. |
| 3006 After the field is set, the object stored into that location is further updated
or accessed. |
| 3007 The setting of the field is visible to other threads as soon as it is set. If th
e |
| 3008 futher accesses in the method that set the field serve to initialize the object,
then |
| 3009 you have a <em>very serious</em> multithreading bug, unless something else preve
nts |
| 3010 any other thread from accessing the stored object until it is fully initialized. |
| 3011 </p> |
| 3012 <p>Even if you feel confident that the method is never called by multiple |
| 3013 threads, it might be better to not set the static field until the value |
| 3014 you are setting it to is fully populated/initialized. |
| 3015 |
| 3016 |
| 3017 <h3><a name="ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD">ML: Synchronization
on field in futile attempt to guard that field (ML_SYNC_ON_FIELD_TO_GUARD_CHANGI
NG_THAT_FIELD)</a></h3> |
| 3018 |
| 3019 |
| 3020 <p> This method synchronizes on a field in what appears to be an attempt |
| 3021 to guard against simultaneous updates to that field. But guarding a field |
| 3022 gets a lock on the referenced object, not on the field. This may not |
| 3023 provide the mutual exclusion you need, and other threads might |
| 3024 be obtaining locks on the referenced objects (for other purposes). An example |
| 3025 of this pattern would be:</p> |
| 3026 <pre> |
| 3027 private Long myNtfSeqNbrCounter = new Long(0); |
| 3028 private Long getNotificationSequenceNumber() { |
| 3029 Long result = null; |
| 3030 synchronized(myNtfSeqNbrCounter) { |
| 3031 result = new Long(myNtfSeqNbrCounter.longValue() + 1); |
| 3032 myNtfSeqNbrCounter = new Long(result.longValue()); |
| 3033 } |
| 3034 return result; |
| 3035 } |
| 3036 </pre> |
| 3037 |
| 3038 |
| 3039 <h3><a name="ML_SYNC_ON_UPDATED_FIELD">ML: La méthode se synchronise sur un cham
p mis à jour (ML_SYNC_ON_UPDATED_FIELD)</a></h3> |
| 3040 |
| 3041 |
| 3042 <p>Cette méthode se synchronise sur le champ modifiable d'une référence objet. I
l y a peu de chances que cela ait un sens puisque les différents threads se sync
hroniserons par rapport à différents objets.</p> |
| 3043 |
| 3044 |
| 3045 <h3><a name="MSF_MUTABLE_SERVLET_FIELD">MSF: Mutable servlet field (MSF_MUTABLE_
SERVLET_FIELD)</a></h3> |
| 3046 |
| 3047 |
| 3048 <p>A web server generally only creates one instance of servlet or jsp class (i.e
., treats |
| 3049 the class as a Singleton), |
| 3050 and will |
| 3051 have multiple threads invoke methods on that instance to service multiple |
| 3052 simultaneous requests. |
| 3053 Thus, having a mutable instance field generally creates race conditions. |
| 3054 |
| 3055 |
| 3056 <h3><a name="MWN_MISMATCHED_NOTIFY">MWN: notify() non appareillé (MWN_MISMATCHED
_NOTIFY)</a></h3> |
| 3057 |
| 3058 |
| 3059 <p>Cette méthode appelle <code>Object.notify()</code> ou <code>Object.notifyAll(
)</code> sans détenir, visiblement, de verrou sur l'objet. Appeler <code>notify(
)</code> ou <code>notifyAll()</code> sans détenir de verrou entraîne le déclench
ement d'une <code>IllegalMonitorStateException</code>.</p> |
| 3060 |
| 3061 |
| 3062 <h3><a name="MWN_MISMATCHED_WAIT">MWN: wait() non appareillé (MWN_MISMATCHED_WAI
T)</a></h3> |
| 3063 |
| 3064 |
| 3065 <p>Cette méthode appelle <code>Object.wait()</code> sans détenir, visiblement, d
e verrou sur l'objet. Appeler <code>wait()</code> sans détenir de verrou entraîn
e le déclenchement d'une <code>IllegalMonitorStateException</code>.</p> |
| 3066 |
| 3067 |
| 3068 <h3><a name="NN_NAKED_NOTIFY">NN: Appel notify() isolé dans une méthode (NN_NAKE
D_NOTIFY)</a></h3> |
| 3069 |
| 3070 |
| 3071 <p>Un appel à <code>notify()</code> ou <code>notifyAll()</code> est effectué san
s aucun changement (apparent) de l'état d'un objet modifiable. En général, appel
er une méthode <code>notify()</code> dans un moniteur est effectué parce qu'une
condition quelconque attendue par un autre thread est devenue vraie. Dans tous l
es cas, pour que la condition ait un sens, elle doit porter sur un objet visible
des deux threads.</p> |
| 3072 <p>Ce bogue n'indique pas nécessairement une erreur puisque la modification de l
'état de l'objet peut avoir eu lieu dans une méthode qui appelle la méthode cont
enant la notification.</p> |
| 3073 |
| 3074 |
| 3075 <h3><a name="NP_SYNC_AND_NULL_CHECK_FIELD">NP: Synchronize and null check on the
same field. (NP_SYNC_AND_NULL_CHECK_FIELD)</a></h3> |
| 3076 |
| 3077 |
| 3078 <p>Since the field is synchronized on, it seems not likely to be null. |
| 3079 If it is null and then synchronized on a NullPointerException will be |
| 3080 thrown and the check would be pointless. Better to synchronize on |
| 3081 another field.</p> |
| 3082 |
| 3083 |
| 3084 |
| 3085 <h3><a name="NO_NOTIFY_NOT_NOTIFYALL">No: Utilisation de notify() plutôt que not
ifyAll() dans une méthode (NO_NOTIFY_NOT_NOTIFYALL)</a></h3> |
| 3086 |
| 3087 |
| 3088 <p>Cette méthode appelle <code>notify()</code> plutôt que <code>notifyAll()</cod
e>. Le moniteur Java est souvent utilisé pour de multiples conditions. Appeler <
code>notify()</code> ne réveille qu'un thread, ce qui signifie que le thread rév
eillé peut ne pas être celui qui attend la condition que l'appelant vient de rem
plir.</p> |
| 3089 |
| 3090 |
| 3091 <h3><a name="RS_READOBJECT_SYNC">RS: Seule la méthode readObject() est synchroni
sée (RS_READOBJECT_SYNC)</a></h3> |
| 3092 |
| 3093 |
| 3094 <p>Cette classe <code>Serializable</code> définit une méthode <code>readObject()
</code> qui est synchronisée. Par définition, un objet créé par désérialisation
n'est accessible que par un unique thread, donc il n'y a aucun intérêt à synchro
niser <code>readObject()</code>. Si la méthode <code>readObject()</code> en elle
-même rend l'objet visible d'un autre thread, vous avez un exemple de style de c
ode très douteux.</p> |
| 3095 |
| 3096 |
| 3097 <h3><a name="RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED">RV: Return value of putIfAb
sent ignored, value passed to putIfAbsent reused (RV_RETURN_VALUE_OF_PUTIFABSENT
_IGNORED)</a></h3> |
| 3098 |
| 3099 |
| 3100 The <code>putIfAbsent</code> method is typically used to ensure that a |
| 3101 single value is associated with a given key (the first value for which p
ut |
| 3102 if absent succeeds). |
| 3103 If you ignore the return value and retain a reference to the value passe
d in, |
| 3104 you run the risk of retaining a value that is not the one that is associ
ated with the key in the map. |
| 3105 If it matters which one you use and you use the one that isn't stored in
the map, |
| 3106 your program will behave incorrectly. |
| 3107 |
| 3108 |
| 3109 <h3><a name="RU_INVOKE_RUN">Ru: Invocation de run() sur un thread (Vouliez-vous
plutôt dire start() ?) (RU_INVOKE_RUN)</a></h3> |
| 3110 |
| 3111 |
| 3112 <p>Cette méthode appelle explicitement <code>run()</code> sur un objet. En génér
al, les classes implémentent l'interface <code>Runnable</code> parce qu'elles vo
nt avoir leur méthode <code>run()</code> invoquée dans un nouveau thread, auquel
cas <code>Thread.start()</code> est la bonne méthode à appeler.</p> |
| 3113 |
| 3114 |
| 3115 <h3><a name="SC_START_IN_CTOR">SC: Un constructeur invoque Thread.start() (SC_ST
ART_IN_CTOR)</a></h3> |
| 3116 |
| 3117 |
| 3118 <p>Le constructeur lance un thread. Il y a de fortes chances que ce soit une err
eur si cette classe est un jour dérivée ou étendue puisque que le thread sera al
ors lancé avant que le constructeur de la classe dérivée ne soit appelé.</p> |
| 3119 |
| 3120 |
| 3121 <h3><a name="SP_SPIN_ON_FIELD">SP: Méthode bouclant sur un champ (SP_SPIN_ON_FIE
LD)</a></h3> |
| 3122 |
| 3123 |
| 3124 <p>Cette méthode tourne en rond sur une boucle qui lit un champ. Le compilateur
est autorisé à sortir la lecture de la boucle, créant ainsi une boucle infinie.
La classe devrait être modifiée afin d'être correctement synchronisée (avec des
appels à <code>wait()</code> et <code>notify()</code>).</p> |
| 3125 |
| 3126 |
| 3127 <h3><a name="STCAL_INVOKE_ON_STATIC_CALENDAR_INSTANCE">STCAL: Call to static Cal
endar (STCAL_INVOKE_ON_STATIC_CALENDAR_INSTANCE)</a></h3> |
| 3128 |
| 3129 |
| 3130 <p>Even though the JavaDoc does not contain a hint about it, Calendars are inher
ently unsafe for multihtreaded use. |
| 3131 The detector has found a call to an instance of Calendar that has been obtained
via a static |
| 3132 field. This looks suspicous.</p> |
| 3133 <p>For more information on this see <a href="http://bugs.sun.com/bugdatabase/vie
w_bug.do?bug_id=6231579">Sun Bug #6231579</a> |
| 3134 and <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6178997">Sun Bug
#6178997</a>.</p> |
| 3135 |
| 3136 |
| 3137 <h3><a name="STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE">STCAL: Call to static
DateFormat (STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE)</a></h3> |
| 3138 |
| 3139 |
| 3140 <p>As the JavaDoc states, DateFormats are inherently unsafe for multithreaded us
e. |
| 3141 The detector has found a call to an instance of DateFormat that has been obtaine
d via a static |
| 3142 field. This looks suspicous.</p> |
| 3143 <p>For more information on this see <a href="http://bugs.sun.com/bugdatabase/vie
w_bug.do?bug_id=6231579">Sun Bug #6231579</a> |
| 3144 and <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6178997">Sun Bug
#6178997</a>.</p> |
| 3145 |
| 3146 |
| 3147 <h3><a name="STCAL_STATIC_CALENDAR_INSTANCE">STCAL: Static Calendar field (STCAL
_STATIC_CALENDAR_INSTANCE)</a></h3> |
| 3148 |
| 3149 |
| 3150 <p>Even though the JavaDoc does not contain a hint about it, Calendars are inher
ently unsafe for multihtreaded use. |
| 3151 Sharing a single instance across thread boundaries without proper synchronizatio
n will result in erratic behavior of the |
| 3152 application. Under 1.4 problems seem to surface less often than under Java 5 whe
re you will probably see |
| 3153 random ArrayIndexOutOfBoundsExceptions or IndexOutOfBoundsExceptions in sun.util
.calendar.BaseCalendar.getCalendarDateFromFixedDate().</p> |
| 3154 <p>You may also experience serialization problems.</p> |
| 3155 <p>Using an instance field is recommended.</p> |
| 3156 <p>For more information on this see <a href="http://bugs.sun.com/bugdatabase/vie
w_bug.do?bug_id=6231579">Sun Bug #6231579</a> |
| 3157 and <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6178997">Sun Bug
#6178997</a>.</p> |
| 3158 |
| 3159 |
| 3160 <h3><a name="STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE">STCAL: Static DateFormat
(STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE)</a></h3> |
| 3161 |
| 3162 |
| 3163 <p>As the JavaDoc states, DateFormats are inherently unsafe for multithreaded us
e. |
| 3164 Sharing a single instance across thread boundaries without proper synchronizatio
n will result in erratic behavior of the |
| 3165 application.</p> |
| 3166 <p>You may also experience serialization problems.</p> |
| 3167 <p>Using an instance field is recommended.</p> |
| 3168 <p>For more information on this see <a href="http://bugs.sun.com/bugdatabase/vie
w_bug.do?bug_id=6231579">Sun Bug #6231579</a> |
| 3169 and <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6178997">Sun Bug
#6178997</a>.</p> |
| 3170 |
| 3171 |
| 3172 <h3><a name="SWL_SLEEP_WITH_LOCK_HELD">SWL: Appel de la méthode Thread.sleep() a
vec un verrou (SWL_SLEEP_WITH_LOCK_HELD)</a></h3> |
| 3173 |
| 3174 |
| 3175 <p>Cette méthode appelle <code>Thread.sleep()</code> en tenant un verrou. Ceci p
eut résulter en de faibles performances, peu de capacité à monter en charge ou u
n inter-blocage puisque d'autres processus pourraient être en attente du verrou.
C'est une meilleure idée d'appeler <code>wait()</code> sur le verrou, afin de l
e libérer et de permettre à d'autre processus de tourner.</p> |
| 3176 |
| 3177 |
| 3178 <h3><a name="TLW_TWO_LOCK_WAIT">TLW: wait() avec deux verrous en attente (TLW_TW
O_LOCK_WAIT)</a></h3> |
| 3179 |
| 3180 |
| 3181 <p>Attendre sur on moniteur alors que deux verrous sont détenus peut entraîner u
n blocage fatal (deadlock). Exécuter un <code>wait()</code> ne libère que le ver
rou sur l'objet accueillant le <code>wait()</code>, mais aucun autre verrou. Ce
n'est pas obligatoirement un bogue, mais il vaut mieux examiner ça en détails.</
p> |
| 3182 |
| 3183 |
| 3184 <h3><a name="UG_SYNC_SET_UNSYNC_GET">UG: Méthode getXXX non synchronisée, méthod
e setXXX synchronisée (UG_SYNC_SET_UNSYNC_GET)</a></h3> |
| 3185 |
| 3186 |
| 3187 <p>Cette classe contient des méthodes <code>getXXX</code> et <code>setXXX</code>
similaires dont la méthode <code>setXXX</code> est synchronisée tandis que la m
éthode <code>getXXX</code> ne l'est pas. Ceci peut entraîner un comportement inc
orrect à l'exécution car l'appelant de la méthode <code>getXXX</code> ne verra p
as obligatoirement l'objet dans un état consistant. La méthode <code>getXXX</cod
e> devrait être synchronisée.</p> |
| 3188 |
| 3189 |
| 3190 <h3><a name="UL_UNRELEASED_LOCK">UL: La méthode ne libère pas un verrou dans tou
s les chemins d'exécution (UL_UNRELEASED_LOCK)</a></h3> |
| 3191 |
| 3192 |
| 3193 <p>Cette méthode acquière un verrou JSR-166 (<code>java.util.concurrent</code>),
mais ne le libère pas dans tous les chemins d'exécution. En général, l'idiome c
orrect pour utiliser un verrou JSR-166 est :</p> |
| 3194 <pre> |
| 3195 Lock l = ...; |
| 3196 l.lock(); |
| 3197 try { |
| 3198 // do something |
| 3199 } finally { |
| 3200 l.unlock(); |
| 3201 } |
| 3202 </pre> |
| 3203 |
| 3204 |
| 3205 <h3><a name="UL_UNRELEASED_LOCK_EXCEPTION_PATH">UL: La méthode ne libère pas un
verrou dans tous les chemins d'exception (UL_UNRELEASED_LOCK_EXCEPTION_PATH)</a>
</h3> |
| 3206 |
| 3207 |
| 3208 <p>Cette méthode acquière un verrou JSR-166 (<code>java.util.concurrent</code>),
mais ne le libère pas dans tous les chemins d'exception. En général, l'idiome c
orrect pour utiliser un verrou JSR-166 est :</p> |
| 3209 <pre> |
| 3210 Lock l = ...; |
| 3211 l.lock(); |
| 3212 try { |
| 3213 // do something |
| 3214 } finally { |
| 3215 l.unlock(); |
| 3216 } |
| 3217 </pre> |
| 3218 |
| 3219 |
| 3220 <h3><a name="UW_UNCOND_WAIT">UW: Méthode contenant un wait() non conditionné (UW
_UNCOND_WAIT)</a></h3> |
| 3221 |
| 3222 |
| 3223 <p>Cette méthode contient un appel à <code>java.lang.Object.wait()</code> qui n'
est pas protégé par une condition. Si la condition que la méthode essaye d'atten
dre a déjà été remplie, le thread risque d'attendre indéfiniment.</p> |
| 3224 |
| 3225 |
| 3226 <h3><a name="VO_VOLATILE_INCREMENT">VO: An increment to a volatile field isn't a
tomic (VO_VOLATILE_INCREMENT)</a></h3> |
| 3227 |
| 3228 |
| 3229 <p>This code increments a volatile field. Increments of volatile fields aren't |
| 3230 atomic. If more than one thread is incrementing the field at the same time, |
| 3231 increments could be lost. |
| 3232 </p> |
| 3233 |
| 3234 |
| 3235 <h3><a name="VO_VOLATILE_REFERENCE_TO_ARRAY">VO: Une référence volatile à un tab
leau ne traite pas les éléments du tableau comme volatiles (VO_VOLATILE_REFERENC
E_TO_ARRAY)</a></h3> |
| 3236 |
| 3237 |
| 3238 <p>Ceci déclare une référence volatile à un tableau, ce qui n'est peut-être pas
ce que vous voulez. Avec une référence volatile à un tableau, les lectures et éc
ritures de la référence au tableau sont traitées comme volatiles, mais les éléme
nts ne sont pas volatiles. Pour obtenir des éléments volatiles, vous devez utili
ser l'une des classes de tableaux atomiques de <code>java.util.concurrent</code>
(inclus dans Java 5.0).</p> |
| 3239 |
| 3240 |
| 3241 <h3><a name="WL_USING_GETCLASS_RATHER_THAN_CLASS_LITERAL">WL: Synchronization on
getClass rather than class literal (WL_USING_GETCLASS_RATHER_THAN_CLASS_LITERAL
)</a></h3> |
| 3242 |
| 3243 |
| 3244 <p> |
| 3245 This instance method synchronizes on <code>this.getClass()</code>. If this
class is subclassed, |
| 3246 subclasses will synchronize on the class object for the subclass, which isn
't likely what was intended. |
| 3247 For example, consider this code from java.awt.Label:</p> |
| 3248 <pre> |
| 3249 private static final String base = "label"; |
| 3250 private static int nameCounter = 0; |
| 3251 String constructComponentName() { |
| 3252 synchronized (getClass()) { |
| 3253 return base + nameCounter++; |
| 3254 } |
| 3255 } |
| 3256 </pre> |
| 3257 <p>Subclasses of <code>Label</code> won't synchronize on the same subclass,
giving rise to a datarace. |
| 3258 Instead, this code should be synchronizing on <code>Label.class</code></p> |
| 3259 <pre> |
| 3260 private static final String base = "label"; |
| 3261 private static int nameCounter = 0; |
| 3262 String constructComponentName() { |
| 3263 synchronized (Label.class) { |
| 3264 return base + nameCounter++; |
| 3265 } |
| 3266 } |
| 3267 </pre> |
| 3268 <p>Bug pattern contributed by Jason Mehrens</p> |
| 3269 |
| 3270 |
| 3271 <h3><a name="WS_WRITEOBJECT_SYNC">WS: Seule la méthode writeObject() est synchro
nisée (WS_WRITEOBJECT_SYNC)</a></h3> |
| 3272 |
| 3273 |
| 3274 <p>Cette classe a une méthode <code>writeObject()</code> qui est synchronisée ;
mais aucune autre méthode de cette classe n'est synchronisée.</p> |
| 3275 |
| 3276 |
| 3277 <h3><a name="WA_AWAIT_NOT_IN_LOOP">Wa: Condition.await() en dehors d'une boucle
(WA_AWAIT_NOT_IN_LOOP)</a></h3> |
| 3278 |
| 3279 |
| 3280 <p>Cette méthode contient un appel à <code>java.util.concurrent.await()</code> (
ou une variante) qui n'est pas dans une boucle. Si cet objet est utilisé pour de
multiples conditions, la condition que l'appelant espère réveiller pourra être
ou ne pas être celle qui le sera effectivement.</p> |
| 3281 |
| 3282 |
| 3283 <h3><a name="WA_NOT_IN_LOOP">Wa: Méthode contenant un wait() en dehors d'une bou
cle (WA_NOT_IN_LOOP)</a></h3> |
| 3284 |
| 3285 |
| 3286 <p>Cette méthode contient un appel à <code>java.lang.Object.wait()</code> qui n'
est pas dans une boucle. Si le moniteur est utilisé pour des conditions multiple
s, la condition que l'appelant attend peut ne pas être celle qui s'est réellemen
t déclenchée.</p> |
| 3287 |
| 3288 |
| 3289 <h3><a name="BX_BOXING_IMMEDIATELY_UNBOXED">Bx: Primitive value is boxed and the
n immediately unboxed (BX_BOXING_IMMEDIATELY_UNBOXED)</a></h3> |
| 3290 |
| 3291 |
| 3292 <p>A primitive is boxed, and then immediately unboxed. This probably is due to
a manual |
| 3293 boxing in a place where an unboxed value is required, thus forcing the compi
ler |
| 3294 to immediately undo the work of the boxing. |
| 3295 </p> |
| 3296 |
| 3297 |
| 3298 <h3><a name="BX_BOXING_IMMEDIATELY_UNBOXED_TO_PERFORM_COERCION">Bx: Primitive va
lue is boxed then unboxed to perform primitive coercion (BX_BOXING_IMMEDIATELY_U
NBOXED_TO_PERFORM_COERCION)</a></h3> |
| 3299 |
| 3300 |
| 3301 <p>A primitive boxed value constructed and then immediately converted into a d
ifferent primitive type |
| 3302 (e.g., <code>new Double(d).intValue()</code>). Just perform direct primitive coe
rcion (e.g., <code>(int) d</code>).</p> |
| 3303 |
| 3304 |
| 3305 <h3><a name="BX_UNBOXING_IMMEDIATELY_REBOXED">Bx: Boxed value is unboxed and the
n immediately reboxed (BX_UNBOXING_IMMEDIATELY_REBOXED)</a></h3> |
| 3306 |
| 3307 |
| 3308 <p>A boxed value is unboxed and then immediately reboxed. |
| 3309 </p> |
| 3310 |
| 3311 |
| 3312 <h3><a name="DM_BOXED_PRIMITIVE_FOR_PARSING">Bx: Boxing/unboxing to parse a prim
itive (DM_BOXED_PRIMITIVE_FOR_PARSING)</a></h3> |
| 3313 |
| 3314 |
| 3315 <p>A boxed primitive is created from a String, just to extract the unboxed pri
mitive value. |
| 3316 It is more efficient to just call the static parseXXX method.</p> |
| 3317 |
| 3318 |
| 3319 <h3><a name="DM_BOXED_PRIMITIVE_TOSTRING">Bx: Méthode allouant une primitive box
ed pour appeler toString (DM_BOXED_PRIMITIVE_TOSTRING)</a></h3> |
| 3320 |
| 3321 |
| 3322 <p>Une primitive "boxed" est allouée juste pour appeler <code>toString()</code>.
Il est plus efficace de simplement utiliser la forme statique de <code>toString
</code> qui accepte la valeur primitive. Donc,</p> |
| 3323 <table> |
| 3324 <tr><th>Remplacer...</th><th>Avec...</th></tr> |
| 3325 <tr><td><code>new Integer(1).toString()</code></td><td><code>Integer.toStri
ng(1)</code></td></tr> |
| 3326 <tr><td><code>new Long(1).toString()</code></td><td><code>Long.toString(1)<
/code></td></tr> |
| 3327 <tr><td><code>new Float(1.0).toString()</code></td><td><code>Float.toString
(1.0)</code></td></tr> |
| 3328 <tr><td><code>new Double(1.0).toString()</code></td><td><code>Double.toStri
ng(1.0)</code></td></tr> |
| 3329 <tr><td><code>new Byte(1).toString()</code></td><td><code>Byte.toString(1)<
/code></td></tr> |
| 3330 <tr><td><code>new Short(1).toString()</code></td><td><code>Short.toString(1
)</code></td></tr> |
| 3331 <tr><td><code>Boolean.valueOf(true).toString()</code></td><td><code>Boolean
.toString(true)</code></td></tr> |
| 3332 </table> |
| 3333 |
| 3334 |
| 3335 <h3><a name="DM_FP_NUMBER_CTOR">Bx: Method invokes inefficient floating-point Nu
mber constructor; use static valueOf instead (DM_FP_NUMBER_CTOR)</a></h3> |
| 3336 |
| 3337 |
| 3338 <p> |
| 3339 Using <code>new Double(double)</code> is guaranteed to always result in a
new object whereas |
| 3340 <code>Double.valueOf(double)</code> allows caching of values to be done by
the compiler, class library, or JVM. |
| 3341 Using of cached values avoids object allocation and the code will be faste
r. |
| 3342 </p> |
| 3343 <p> |
| 3344 Unless the class must be compatible with JVMs predating Java 1.5, |
| 3345 use either autoboxing or the <code>valueOf()</code> method when creating i
nstances of <code>Double</code> and <code>Float</code>. |
| 3346 </p> |
| 3347 |
| 3348 |
| 3349 <h3><a name="DM_NUMBER_CTOR">Bx: Method invokes inefficient Number constructor;
use static valueOf instead (DM_NUMBER_CTOR)</a></h3> |
| 3350 |
| 3351 |
| 3352 <p> |
| 3353 Using <code>new Integer(int)</code> is guaranteed to always result in a ne
w object whereas |
| 3354 <code>Integer.valueOf(int)</code> allows caching of values to be done by t
he compiler, class library, or JVM. |
| 3355 Using of cached values avoids object allocation and the code will be faste
r. |
| 3356 </p> |
| 3357 <p> |
| 3358 Values between -128 and 127 are guaranteed to have corresponding cached in
stances |
| 3359 and using <code>valueOf</code> is approximately 3.5 times faster than usin
g constructor. |
| 3360 For values outside the constant range the performance of both styles is th
e same. |
| 3361 </p> |
| 3362 <p> |
| 3363 Unless the class must be compatible with JVMs predating Java 1.5, |
| 3364 use either autoboxing or the <code>valueOf()</code> method when creating i
nstances of |
| 3365 <code>Long</code>, <code>Integer</code>, <code>Short</code>, <code>Charact
er</code>, and <code>Byte</code>. |
| 3366 </p> |
| 3367 |
| 3368 |
| 3369 <h3><a name="DMI_BLOCKING_METHODS_ON_URL">Dm: The equals and hashCode methods of
URL are blocking (DMI_BLOCKING_METHODS_ON_URL)</a></h3> |
| 3370 |
| 3371 |
| 3372 <p> The equals and hashCode |
| 3373 method of URL perform domain name resolution, this can result in a big performan
ce hit. |
| 3374 See <a href="http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hash
code-make.html">http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-h
ashcode-make.html</a> for more information. |
| 3375 Consider using <code>java.net.URI</code> instead. |
| 3376 </p> |
| 3377 |
| 3378 |
| 3379 <h3><a name="DMI_COLLECTION_OF_URLS">Dm: Maps and sets of URLs can be performanc
e hogs (DMI_COLLECTION_OF_URLS)</a></h3> |
| 3380 |
| 3381 |
| 3382 <p> This method or field is or uses a Map or Set of URLs. Since both the equal
s and hashCode |
| 3383 method of URL perform domain name resolution, this can result in a big performan
ce hit. |
| 3384 See <a href="http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hash
code-make.html">http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-h
ashcode-make.html</a> for more information. |
| 3385 Consider using <code>java.net.URI</code> instead. |
| 3386 </p> |
| 3387 |
| 3388 |
| 3389 <h3><a name="DM_BOOLEAN_CTOR">Dm: La méthode invoque le constructeur inutile Boo
lean() ; utilisez Boolean.valueOf(...) à la place (DM_BOOLEAN_CTOR)</a></h3> |
| 3390 |
| 3391 |
| 3392 <p>Créer de nouvelles instances de <code>java.lang.Boolean</code> gaspille la mé
moire puisque les objets <code>Boolean</code> sont immuables et qu'il n'y a que
deux valeurs utiles de ce type. Utilisez à la place la méthode <code>Boolean.val
ueOf()</code> pour créer des objets <code>Boolean</code>.</p> |
| 3393 |
| 3394 |
| 3395 <h3><a name="DM_GC">Dm: Ramasse-miettes explicite ; extrêmement douteux sauf dan
s du code de banc d'essai (DM_GC)</a></h3> |
| 3396 |
| 3397 |
| 3398 <p>Le code appelle explicitement le ramasse-miettes. Mis à part l'emploi spécifi
que dans un banc d'essai, c'est très douteux.</p> |
| 3399 <p>Dans le passé, les cas où des personnes ont explicitement invoqué le ramasse-
miettes dans des méthodes telles que <code>close()</code> ou <code>finalize()</c
ode> ont creusés des gouffres dans les performances. Le ramasse-miettes peut-êtr
e très coûteux. Toute situation qui force des centaines ou des milliers de ramas
se-miettes mettra à genoux une machine.</p> |
| 3400 |
| 3401 |
| 3402 <h3><a name="DM_NEW_FOR_GETCLASS">Dm: Méthode allouant un objet juste pour obten
ir la classe (DM_NEW_FOR_GETCLASS)</a></h3> |
| 3403 |
| 3404 |
| 3405 <p>Cette méthode alloue un objet juste pour appeler sa méthode <code>getClass()<
/code> afin d'obtenir l'objet <code>Class</code> correspondant. Il est plus simp
le d'accèder directement à la propriété <code>.class</code> de la classe.</p> |
| 3406 |
| 3407 |
| 3408 <h3><a name="DM_NEXTINT_VIA_NEXTDOUBLE">Dm: Utiliser la méthode nextInt de Rando
m plutôt que nextDouble pour générer un entier aléatoire (DM_NEXTINT_VIA_NEXTDOU
BLE)</a></h3> |
| 3409 |
| 3410 |
| 3411 <p>Si <code>r</code> est un <code>java.util.Random</code>, vous pouvez générer u
n nombre aléatoire entre 0 et n-1 en utilisant <code>r.nextInt(n)</code> plutôt
que <code>(int)(r.nextDouble() * n)</code>.</p> |
| 3412 |
| 3413 |
| 3414 <h3><a name="DM_STRING_CTOR">Dm: La méthode invoque le constructeur inutile Stri
ng(String) ; utilisez juste l'argument (DM_STRING_CTOR)</a></h3> |
| 3415 |
| 3416 |
| 3417 <p>Utiliser le constructeur <code>java.lang.String(String)</code> gaspille de la
mémoire puisque l'objet ainsi construit serait fonctionnellement identique à la
chaîne passée en paramètre. Utilisez juste la chaîne en argument directement.</
p> |
| 3418 |
| 3419 |
| 3420 <h3><a name="DM_STRING_TOSTRING">Dm: La méthode appel toString() sur un objet St
ring ; utilisez directement l'objet String (DM_STRING_TOSTRING)</a></h3> |
| 3421 |
| 3422 |
| 3423 <p>Appeler <code>String.toString()</code> est juste une opération redondante. Ut
ilisez directement l'objet <code>String</code>.</p> |
| 3424 |
| 3425 |
| 3426 <h3><a name="DM_STRING_VOID_CTOR">Dm: La méthode invoque le constructeur inutile
String() ; utilisez juste "" (DM_STRING_VOID_CTOR)</a></h3> |
| 3427 |
| 3428 |
| 3429 <p>Créer un nouveau objet <code>java.lang.String</code> en utilisant le construc
teur sans argument gaspille de la mémoire parce que l'objet ainsi créé serait fo
nctionnellement identique à la constante de chaîne vide "". Java garantie que le
s chaînes constantes identiques seront représentées par le même objet <code>Stri
ng</code>. C'est pourquoi vous devriez directement utiliser la constante de chaî
ne vide.</p> |
| 3430 |
| 3431 |
| 3432 <h3><a name="HSC_HUGE_SHARED_STRING_CONSTANT">HSC: Huge string constants is dupl
icated across multiple class files (HSC_HUGE_SHARED_STRING_CONSTANT)</a></h3> |
| 3433 |
| 3434 |
| 3435 <p> |
| 3436 A large String constant is duplicated across multiple class files. |
| 3437 This is likely because a final field is initialized to a String constant, an
d the Java language |
| 3438 mandates that all references to a final field from other classes be inlined
into |
| 3439 that classfile. See <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=
6447475">JDK bug 6447475</a> |
| 3440 for a description of an occurrence of this bug in the JDK and how resolving
it reduced |
| 3441 the size of the JDK by 1 megabyte. |
| 3442 </p> |
| 3443 |
| 3444 |
| 3445 <h3><a name="IIO_INEFFICIENT_INDEX_OF">IIO: Inefficient use of String.indexOf(St
ring) (IIO_INEFFICIENT_INDEX_OF)</a></h3> |
| 3446 |
| 3447 |
| 3448 <p> This code passes a constant string of length 1 to String.indexOf(). |
| 3449 It is more efficient to use the integer implementations of String.indexOf(). |
| 3450 f. e. call <code>myString.indexOf('.')</code> instead of <code>myString.indexOf(
".")</code></p> |
| 3451 |
| 3452 |
| 3453 <h3><a name="IIO_INEFFICIENT_LAST_INDEX_OF">IIO: Inefficient use of String.lastI
ndexOf(String) (IIO_INEFFICIENT_LAST_INDEX_OF)</a></h3> |
| 3454 |
| 3455 |
| 3456 <p> This code passes a constant string of length 1 to String.lastIndexOf(). |
| 3457 It is more efficient to use the integer implementations of String.lastIndexOf(). |
| 3458 f. e. call <code>myString.lastIndexOf('.')</code> instead of <code>myString.last
IndexOf(".")</code></p> |
| 3459 |
| 3460 |
| 3461 <h3><a name="ITA_INEFFICIENT_TO_ARRAY">ITA: La méthode utilise toArray() avec un
tableau vide en paramètre (ITA_INEFFICIENT_TO_ARRAY)</a></h3> |
| 3462 |
| 3463 |
| 3464 <p>Cette méthode utilise la méthode <code>toArray()</code> d'une classe dérivant
de <code>Collection</code>, en lui passant en paramètre un tableau vide. Il est
plus efficace d'utiliser <code>myCollection.toArray(new Foo[myCollection.size()
])</code>. Si le tableau transmis est assez grand pour stocker tous les éléments
de la collection, alors il est alimenté et renvoyé directement. Ceci évite la n
écessité de créer un nouveau tableau (par réflexion) pour renvoyer le résultat.<
/p> |
| 3465 |
| 3466 |
| 3467 <h3><a name="SBSC_USE_STRINGBUFFER_CONCATENATION">SBSC: La méthode concatène des
chaînes au moyen de + en boucle (SBSC_USE_STRINGBUFFER_CONCATENATION)</a></h3> |
| 3468 |
| 3469 |
| 3470 <p>Cette méthode semble construire une <ocde>String</code> en utilisant une conc
aténation en boucle. A chaque itération, l'objet <code>String</code> est convert
i en <code>StringBuffer</code>/<code>StringBuilder</code>, complété, puis de nou
veau converti en <code>String</code>. Ceci a un coût exponentiel en fonction du
nombre d'itérations, puisque la chaîne est recopiée à chaque itération.</p> |
| 3471 <p>De meilleurs performances peuvent être obtenues en utilisant explicitement <c
ode>StringBuffer</code> (ou <code>StringBuilder</code> en Java 5).</p> |
| 3472 <p>Par exemple :</p> |
| 3473 <pre> |
| 3474 // C'est mal ! |
| 3475 String s = ""; |
| 3476 for (int i = 0; i < field.length; ++i) { |
| 3477 s = s + field[i]; |
| 3478 } |
| 3479 |
| 3480 // C'est mieux... |
| 3481 StringBuffer buf = new StringBuffer(); |
| 3482 for (int i = 0; i < field.length; ++i) { |
| 3483 buf.append(field[i]); |
| 3484 } |
| 3485 String s = buf.toString(); |
| 3486 </pre> |
| 3487 |
| 3488 |
| 3489 <h3><a name="SIC_INNER_SHOULD_BE_STATIC">SIC: Devrait être une classe interne st
atique (SIC_INNER_SHOULD_BE_STATIC)</a></h3> |
| 3490 |
| 3491 |
| 3492 <p>Cette classe est une classe interne, mais n'utilise pas sa référence vers l'o
bjet qui l'a créée. Cette référence rend les instances de cette classe plus gros
ses et peut garder active la référence à l'objet créateur plus longtemps que néc
essaire. Si possible, la classe devrait être transformée en classe interne <code
>static</code>.</p> |
| 3493 |
| 3494 |
| 3495 <h3><a name="SIC_INNER_SHOULD_BE_STATIC_ANON">SIC: Peut-être transformée en clas
se interne statique nommée (SIC_INNER_SHOULD_BE_STATIC_ANON)</a></h3> |
| 3496 |
| 3497 |
| 3498 <p>Cette classe est une classe interne qui n'utilise pas sa référence vers l'obj
et qui l'a créée. Cette référence rend l'objet plus gros et peut garder active l
a référence de l'objet créateur plus longtemps que nécessaire. Si possible, la c
lasse devrait être transformée en classe interne <code>static</code>. Puisque le
s classes anonymes ne peuvent pas être marquées comme <code>static</code>, il fa
udrait également nommer cette classe.</p> |
| 3499 |
| 3500 |
| 3501 <h3><a name="SIC_INNER_SHOULD_BE_STATIC_NEEDS_THIS">SIC: Pourrait-être transform
ée en classe interne statique (SIC_INNER_SHOULD_BE_STATIC_NEEDS_THIS)</a></h3> |
| 3502 |
| 3503 |
| 3504 <p>Cette classe est une classe interne mais elle n'utilise pas sa référence vers
l'objet qui l'a créée, à part durant la création de l'objet interne. Cette réfé
rence rend les instances de cette classe plus grosses et peut forcer à garder ac
tive la référence de l'objet créateur plus longtemps que nécessaire. Si possible
, la classe devrait-être transformée en classe interne <code>static</code>. Puis
que la référence à l'objet créateur est requise durant la construction de la cla
sse interne, le constructeur de celle-ci devrait-être modifié afin d'accepter en
argument cette référence.</p> |
| 3505 |
| 3506 |
| 3507 <h3><a name="SS_SHOULD_BE_STATIC">SS: Champ non lu : devrait-il être statique ?
(SS_SHOULD_BE_STATIC)</a></h3> |
| 3508 |
| 3509 |
| 3510 <p>Cette classe contient un champ d'instance <code>final</code> qui est initiali
sé par une valeur statique déterminée à la compilation. Envisagez de rendre ce c
hamp <code>static</code>.</p> |
| 3511 |
| 3512 |
| 3513 <h3><a name="UM_UNNECESSARY_MATH">UM: Appel d'une méthode statique de la classe
Math sur une valeur constante (UM_UNNECESSARY_MATH)</a></h3> |
| 3514 |
| 3515 |
| 3516 <p>Cette méthode utilise une méthode statique de <code>java.lang.Math</code> sur
une valeur constante. Dans ce cas, le résultat de cet appel peut être déterminé
statiquement, ce qui est plus rapide et souvent plus précis. Les méthodes détec
tées sont :</p> |
| 3517 <table> |
| 3518 <tr><th>Méthode</th><th>Paramètre</th></tr> |
| 3519 <tr><td>abs</td><td>-tous-</td></tr> |
| 3520 <tr><td>acos</td><td>0.0 ou 1.0</td></tr> |
| 3521 <tr><td>asin</td><td>0.0 ou 1.0</td></tr> |
| 3522 <tr><td>atan</td><td>0.0 ou 1.0</td></tr> |
| 3523 <tr><td>atan2</td><td>0.0</td></tr> |
| 3524 <tr><td>cbrt</td><td>0.0 ou 1.0</td></tr> |
| 3525 <tr><td>ceil</td><td>-tous-</td></tr> |
| 3526 <tr><td>cos</td><td>0.0</td></tr> |
| 3527 <tr><td>cosh</td><td>0.0</td></tr> |
| 3528 <tr><td>exp</td><td>0.0 ou 1.0</td></tr> |
| 3529 <tr><td>expm1</td><td>0.0</td></tr> |
| 3530 <tr><td>floor</td><td>-tous-</td></tr> |
| 3531 <tr><td>log</td><td>0.0 ou 1.0</td></tr> |
| 3532 <tr><td>log10</td><td>0.0 ou 1.0</td></tr> |
| 3533 <tr><td>rint</td><td>-tous-</td></tr> |
| 3534 <tr><td>round</td><td>-tous-</td></tr> |
| 3535 <tr><td>sin</td><td>0.0</td></tr> |
| 3536 <tr><td>sinh</td><td>0.0</td></tr> |
| 3537 <tr><td>sqrt</td><td>0.0 ou 1.0</td></tr> |
| 3538 <tr><td>tan</td><td>0.0</td></tr> |
| 3539 <tr><td>tanh</td><td>0.0</td></tr> |
| 3540 <tr><td>toDegrees</td><td>0.0 ou 1.0</td></tr> |
| 3541 <tr><td>toRadians</td><td>0.0</td></tr> |
| 3542 </table> |
| 3543 |
| 3544 |
| 3545 <h3><a name="UPM_UNCALLED_PRIVATE_METHOD">UPM: Méthode privée jamais appelée (UP
M_UNCALLED_PRIVATE_METHOD)</a></h3> |
| 3546 |
| 3547 |
| 3548 <p>Cette méthode privée n'est jamais appelée. Bien qu'il soit possible que cette
méthode soit appelée par réflexion, il y a plus de chances qu'elle ne soit jama
is utilisée et qu'elle puisse être supprimée.</p> |
| 3549 |
| 3550 |
| 3551 <h3><a name="URF_UNREAD_FIELD">UrF: Champ inutilisé (URF_UNREAD_FIELD)</a></h3> |
| 3552 |
| 3553 |
| 3554 <p>Ce champ n'est jamais lu. Envisagez de le supprimer de la classe.</p> |
| 3555 |
| 3556 |
| 3557 <h3><a name="UUF_UNUSED_FIELD">UuF: Champ inutilisé (UUF_UNUSED_FIELD)</a></h3> |
| 3558 |
| 3559 |
| 3560 <p>Ce champ n'est jamais utilisé. Envisagez de le supprimer de la classe.</p> |
| 3561 |
| 3562 |
| 3563 <h3><a name="WMI_WRONG_MAP_ITERATOR">WMI: Utilisation inefficace d'un itérateur
sur keySet au lieu de entrySet (WMI_WRONG_MAP_ITERATOR)</a></h3> |
| 3564 |
| 3565 |
| 3566 <p>Cette méthode accède à la valeur d'une entrée de <code>Map</code> au moyen d'
une clé provenant d'un itérateur sur <code>keySet</code>. Il est plus efficace d
'utiliser un itérateur sur l'<code>entrySet</code> de la <code>Map</code>, pour
éviter la recherche par <code>Map.get(clé)</code>.</p> |
| 3567 |
| 3568 |
| 3569 <h3><a name="DMI_CONSTANT_DB_PASSWORD">Dm: Hardcoded constant database password
(DMI_CONSTANT_DB_PASSWORD)</a></h3> |
| 3570 |
| 3571 |
| 3572 <p>This code creates a database connect using a hardcoded, constant password
. Anyone with access to either the source code or the compiled code can |
| 3573 easily learn the password. |
| 3574 </p> |
| 3575 |
| 3576 |
| 3577 |
| 3578 <h3><a name="DMI_EMPTY_DB_PASSWORD">Dm: Empty database password (DMI_EMPTY_DB_PA
SSWORD)</a></h3> |
| 3579 |
| 3580 |
| 3581 <p>This code creates a database connect using a blank or empty password. Thi
s indicates that the database is not protected by a password. |
| 3582 </p> |
| 3583 |
| 3584 |
| 3585 |
| 3586 <h3><a name="HRS_REQUEST_PARAMETER_TO_COOKIE">HRS: HTTP cookie formed from untru
sted input (HRS_REQUEST_PARAMETER_TO_COOKIE)</a></h3> |
| 3587 |
| 3588 |
| 3589 <p>This code constructs an HTTP Cookie using an untrusted HTTP parameter. If
this cookie is added to an HTTP response, it will allow a HTTP response splitti
ng |
| 3590 vulnerability. See <a href="http://en.wikipedia.org/wiki/HTTP_response_splitting
">http://en.wikipedia.org/wiki/HTTP_response_splitting</a> |
| 3591 for more information.</p> |
| 3592 <p>FindBugs looks only for the most blatant, obvious cases of HTTP response spli
tting. |
| 3593 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more |
| 3594 vulnerabilities that FindBugs doesn't report. If you are concerned about HTTP re
sponse splitting, you should seriously |
| 3595 consider using a commercial static analysis or pen-testing tool. |
| 3596 </p> |
| 3597 |
| 3598 |
| 3599 |
| 3600 <h3><a name="HRS_REQUEST_PARAMETER_TO_HTTP_HEADER">HRS: HTTP Response splitting
vulnerability (HRS_REQUEST_PARAMETER_TO_HTTP_HEADER)</a></h3> |
| 3601 |
| 3602 |
| 3603 <p>This code directly writes an HTTP parameter to an HTTP header, which allo
ws for a HTTP response splitting |
| 3604 vulnerability. See <a href="http://en.wikipedia.org/wiki/HTTP_response_splitting
">http://en.wikipedia.org/wiki/HTTP_response_splitting</a> |
| 3605 for more information.</p> |
| 3606 <p>FindBugs looks only for the most blatant, obvious cases of HTTP response spli
tting. |
| 3607 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more |
| 3608 vulnerabilities that FindBugs doesn't report. If you are concerned about HTTP re
sponse splitting, you should seriously |
| 3609 consider using a commercial static analysis or pen-testing tool. |
| 3610 </p> |
| 3611 |
| 3612 |
| 3613 |
| 3614 <h3><a name="PT_ABSOLUTE_PATH_TRAVERSAL">PT: Absolute path traversal in servlet
(PT_ABSOLUTE_PATH_TRAVERSAL)</a></h3> |
| 3615 |
| 3616 |
| 3617 <p>The software uses an HTTP request parameter to construct a pathname that
should be within a restricted directory, |
| 3618 but it does not properly neutralize absolute path sequences such as "/abs/path"
that can resolve to a location that is outside of that directory. |
| 3619 |
| 3620 See <a href="http://cwe.mitre.org/data/definitions/36.html">http://cwe.mitre.org
/data/definitions/36.html</a> |
| 3621 for more information.</p> |
| 3622 <p>FindBugs looks only for the most blatant, obvious cases of absolute path trav
ersal. |
| 3623 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more |
| 3624 vulnerabilities that FindBugs doesn't report. If you are concerned about absolut
e path traversal, you should seriously |
| 3625 consider using a commercial static analysis or pen-testing tool. |
| 3626 </p> |
| 3627 |
| 3628 |
| 3629 |
| 3630 <h3><a name="PT_RELATIVE_PATH_TRAVERSAL">PT: Relative path traversal in servlet
(PT_RELATIVE_PATH_TRAVERSAL)</a></h3> |
| 3631 |
| 3632 |
| 3633 <p>The software uses an HTTP request parameter to construct a pathname that
should be within a restricted directory, but it does not properly neutralize seq
uences such as ".." that can resolve to a location that is outside of that direc
tory. |
| 3634 |
| 3635 See <a href="http://cwe.mitre.org/data/definitions/23.html">http://cwe.mitre.org
/data/definitions/23.html</a> |
| 3636 for more information.</p> |
| 3637 <p>FindBugs looks only for the most blatant, obvious cases of relative path trav
ersal. |
| 3638 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more |
| 3639 vulnerabilities that FindBugs doesn't report. If you are concerned about relativ
e path traversal, you should seriously |
| 3640 consider using a commercial static analysis or pen-testing tool. |
| 3641 </p> |
| 3642 |
| 3643 |
| 3644 |
| 3645 <h3><a name="SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE">SQL: Une chaîne non const
ante est passée à la méthode execute d'une commande SQL (SQL_NONCONSTANT_STRING_
PASSED_TO_EXECUTE)</a></h3> |
| 3646 |
| 3647 |
| 3648 <p>Cette méthode invoque la méthode <code>execute</code> d'une commande SQL (sta
tement) avec une chaîne qui semble générée dynamiquement. Préférer la préparatio
n de la commande avec un <code>PreparedStatement</code>, c'est plus efficace et
bien moins vulnérable aux attaques par injection SQL (insertion de code SQL malv
eillant au sein d'une requête).</p> |
| 3649 |
| 3650 |
| 3651 <h3><a name="SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING">SQL: Une
requète est préparée à partir d'une chaine non constante (SQL_PREPARED_STATEMENT
_GENERATED_FROM_NONCONSTANT_STRING)</a></h3> |
| 3652 |
| 3653 |
| 3654 <p>Ce code créé une requète SQL préparée à partir d'une chaine non constante. Le
s données qui permettent de construire cette chaine venant de l'utilisateur, ell
es pourraient, sans vérification, servir à faire de l'injection de SQL et ainsi
modifier la requète afin qu'elle produise des résultats inattendus et indésirabl
es.</p> |
| 3655 |
| 3656 |
| 3657 <h3><a name="XSS_REQUEST_PARAMETER_TO_JSP_WRITER">XSS: JSP reflected cross site
scripting vulnerability (XSS_REQUEST_PARAMETER_TO_JSP_WRITER)</a></h3> |
| 3658 |
| 3659 |
| 3660 <p>This code directly writes an HTTP parameter to JSP output, which allows f
or a cross site scripting |
| 3661 vulnerability. See <a href="http://en.wikipedia.org/wiki/Cross-site_scripting">h
ttp://en.wikipedia.org/wiki/Cross-site_scripting</a> |
| 3662 for more information.</p> |
| 3663 <p>FindBugs looks only for the most blatant, obvious cases of cross site scripti
ng. |
| 3664 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more cross si
te scripting |
| 3665 vulnerabilities that FindBugs doesn't report. If you are concerned about cross s
ite scripting, you should seriously |
| 3666 consider using a commercial static analysis or pen-testing tool. |
| 3667 </p> |
| 3668 |
| 3669 |
| 3670 <h3><a name="XSS_REQUEST_PARAMETER_TO_SEND_ERROR">XSS: Servlet reflected cross s
ite scripting vulnerability in error page (XSS_REQUEST_PARAMETER_TO_SEND_ERROR)<
/a></h3> |
| 3671 |
| 3672 |
| 3673 <p>This code directly writes an HTTP parameter to a Server error page (using
HttpServletResponse.sendError). Echoing this untrusted input allows |
| 3674 for a reflected cross site scripting |
| 3675 vulnerability. See <a href="http://en.wikipedia.org/wiki/Cross-site_scripting">h
ttp://en.wikipedia.org/wiki/Cross-site_scripting</a> |
| 3676 for more information.</p> |
| 3677 <p>FindBugs looks only for the most blatant, obvious cases of cross site scripti
ng. |
| 3678 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more cross si
te scripting |
| 3679 vulnerabilities that FindBugs doesn't report. If you are concerned about cross s
ite scripting, you should seriously |
| 3680 consider using a commercial static analysis or pen-testing tool. |
| 3681 </p> |
| 3682 |
| 3683 |
| 3684 |
| 3685 <h3><a name="XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER">XSS: Servlet reflected cro
ss site scripting vulnerability (XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER)</a></h
3> |
| 3686 |
| 3687 |
| 3688 <p>This code directly writes an HTTP parameter to Servlet output, which allo
ws for a reflected cross site scripting |
| 3689 vulnerability. See <a href="http://en.wikipedia.org/wiki/Cross-site_scripting">h
ttp://en.wikipedia.org/wiki/Cross-site_scripting</a> |
| 3690 for more information.</p> |
| 3691 <p>FindBugs looks only for the most blatant, obvious cases of cross site scripti
ng. |
| 3692 If FindBugs found <em>any</em>, you <em>almost certainly</em> have more cross si
te scripting |
| 3693 vulnerabilities that FindBugs doesn't report. If you are concerned about cross s
ite scripting, you should seriously |
| 3694 consider using a commercial static analysis or pen-testing tool. |
| 3695 </p> |
| 3696 |
| 3697 |
| 3698 |
| 3699 <h3><a name="BC_BAD_CAST_TO_ABSTRACT_COLLECTION">BC: Transtypage douteux d'un ty
pe Collection vers une classe abstraite (BC_BAD_CAST_TO_ABSTRACT_COLLECTION)</a>
</h3> |
| 3700 |
| 3701 |
| 3702 <p>Ce code transtype un object de type <code>Collection</code> vers un type de c
ollection abstrait (tel que <code>Collection</code>). Assurez vous que l'objet e
st bien du type précisé. Si vous désirez par exemple faire une itération sur une
collection, le transtypage vers <code>Set</code> ou <code>List</code> est inuti
le.</p> |
| 3703 |
| 3704 |
| 3705 <h3><a name="BC_BAD_CAST_TO_CONCRETE_COLLECTION">BC: Transtypage douteux vers un
e collection concrète (BC_BAD_CAST_TO_CONCRETE_COLLECTION)</a></h3> |
| 3706 |
| 3707 |
| 3708 <p>Ce code transtype une collection abstraite (telles que <code>Collection</code
>, <code>List</code>, ou <code>Set</code>) vers une implémentation concrète spéc
ifique (telles que <code>ArrayList</code> ou <code>HashSet</code>). Ceci n'est p
as forcément correct, et peut rendre votre code plus fragile, puisqu'il un évent
uel refactoring futur avec une autre implémentation concrète plus difficile. A d
éfaut d'une raison valable, l'utilisation des classes abstraites est recommandée
.</p> |
| 3709 |
| 3710 |
| 3711 <h3><a name="BC_UNCONFIRMED_CAST">BC: Transtypage non vérifié/non confirmé (BC_U
NCONFIRMED_CAST)</a></h3> |
| 3712 |
| 3713 |
| 3714 <p>La faisablité du transtypage n'est pas vérifiée, et tous les objets candidats
au transtypage ne sont pas légitimes. Assurez vous que la logique du programme
est correcte et que le transtypage n'échouera pas.</p> |
| 3715 |
| 3716 |
| 3717 <h3><a name="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE">BC: Unchecked/unconfirmed cast
of return value from method (BC_UNCONFIRMED_CAST_OF_RETURN_VALUE)</a></h3> |
| 3718 |
| 3719 |
| 3720 <p> |
| 3721 This code performs an unchecked cast of the return value of a method. |
| 3722 The code might be calling the method in such a way that the cast is guaranteed t
o be |
| 3723 safe, but FindBugs is unable to verify that the cast is safe. Check that your p
rogram logic ensures that this |
| 3724 cast will not fail. |
| 3725 </p> |
| 3726 |
| 3727 |
| 3728 <h3><a name="BC_VACUOUS_INSTANCEOF">BC: instanceof renverra toujours vrai (BC_VA
CUOUS_INSTANCEOF)</a></h3> |
| 3729 |
| 3730 |
| 3731 <p>Ce test <code>instanceof</code> renverra toujours vrai. Même s'il est sûr, as
surez-vous qu'il ne s'agit pas d'une erreur logique ou d'une mauvaise compréhens
ion.</p> |
| 3732 |
| 3733 |
| 3734 <h3><a name="ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT">BSHIFT: Décalage à droite
non signé et transtypage short/byte (ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT)</a
></h3> |
| 3735 |
| 3736 |
| 3737 <p>Le code effectue un décalage à droite non signé, dont le résultat est transty
pé vers un <code>short</code> ou un <code>byte</code>, ce qui élimine les bits s
upérieurs du résultat. Puisque les bits supérieurs sont éliminés, il peut ne pas
y avoir de différence entre un décalage à droite signé ou non signé (ceci dépen
d de la taille du décalage)</p> |
| 3738 |
| 3739 |
| 3740 <h3><a name="CI_CONFUSED_INHERITANCE">CI: Classe finale déclarant un champ proté
gé (CI_CONFUSED_INHERITANCE)</a></h3> |
| 3741 |
| 3742 |
| 3743 <p>Cette classe est déclarée <code>final</code> mais comporte des champs <code>p
rotected</code>. Cette classe étant finale, elle ne pourra jamais être dérivée e
t donc l'utilisation de <code>protected</code> est troublante. Le modificateur d
'accès devrait être modifié à <code>private</code> ou <code>public</code> pour m
ettre en évidence la véritable utilisation du champ.</p> |
| 3744 |
| 3745 |
| 3746 <h3><a name="DB_DUPLICATE_BRANCHES">DB: Méthode utilsant le même code pour deux
branches (DB_DUPLICATE_BRANCHES)</a></h3> |
| 3747 |
| 3748 |
| 3749 <p>Cette méthode utilise le même code pour implémenter deux branches d'une condi
tion. Vérifiez pour vous assurer que ce n'est pas une erreur de codage.</p> |
| 3750 |
| 3751 |
| 3752 <h3><a name="DB_DUPLICATE_SWITCH_CLAUSES">DB: Méthode utilisant le même code pou
r deux clauses switch (DB_DUPLICATE_SWITCH_CLAUSES)</a></h3> |
| 3753 |
| 3754 |
| 3755 <p>Cette méthode utilise le même code pour implémenter deux cas différents d'un
<code>switch</code>. Ce peut être normal mais il vaut mieux vérifier que ce n'es
t pas une erreur de codage.</p> |
| 3756 |
| 3757 |
| 3758 <h3><a name="DLS_DEAD_LOCAL_STORE">DLS: Alimentation à perte d'une variable loca
le (DLS_DEAD_LOCAL_STORE)</a></h3> |
| 3759 |
| 3760 |
| 3761 <p>Cette instruction assigne une valeur à une variable locale mais cette variabl
e n'est pas lue par la suite. Ceci indique souvent une erreur puisque la valeur
calculée n'est jamais utilisée.</p> |
| 3762 <p>Notez que le compilateur javac de Sun génère fréquemment ce genre d'affectati
ons à perte. FindBugs analysant le byte-code généré, il n'y a pas de façon simpl
e d'éliminer ces fausses alarmes.</p> |
| 3763 |
| 3764 |
| 3765 <h3><a name="DLS_DEAD_LOCAL_STORE_IN_RETURN">DLS: Useless assignment in return s
tatement (DLS_DEAD_LOCAL_STORE_IN_RETURN)</a></h3> |
| 3766 |
| 3767 |
| 3768 <p> |
| 3769 This statement assigns to a local variable in a return statement. This assignmen
t |
| 3770 has effect. Please verify that this statement does the right thing. |
| 3771 </p> |
| 3772 |
| 3773 |
| 3774 <h3><a name="DLS_DEAD_LOCAL_STORE_OF_NULL">DLS: Alimentation à null d'une variab
le (DLS_DEAD_LOCAL_STORE_OF_NULL)</a></h3> |
| 3775 |
| 3776 |
| 3777 <p>Le code alimente une variable locale avec null, la valeur n'étant jamais lue
par la suite. Cette alimentation a pu être introduite pour faciliter le travail
du ramasse-miettes, mais cela n'a plus aucun intérêt avec Java SE 6.</p> |
| 3778 |
| 3779 |
| 3780 <h3><a name="DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD">DLS: Dead store to local variab
le that shadows field (DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD)</a></h3> |
| 3781 |
| 3782 |
| 3783 <p> |
| 3784 This instruction assigns a value to a local variable, |
| 3785 but the value is not read or used in any subsequent instruction. |
| 3786 Often, this indicates an error, because the value computed is never |
| 3787 used. There is a field with the same name as the local variable. Did you |
| 3788 mean to assign to that variable instead? |
| 3789 </p> |
| 3790 |
| 3791 |
| 3792 <h3><a name="DMI_HARDCODED_ABSOLUTE_FILENAME">DMI: Chemin absolu codé en dur dan
s le code (DMI_HARDCODED_ABSOLUTE_FILENAME)</a></h3> |
| 3793 |
| 3794 |
| 3795 <p>Ce code construit un objet <code>File</code> en utilisant un chemin absolu de
fichier codé en dur (Ex. : <code>new File("/home/dannyc/workspace/j2ee/src/shar
e/com/sun/enterprise/deployment");)</code>.</p> |
| 3796 |
| 3797 |
| 3798 <h3><a name="DMI_NONSERIALIZABLE_OBJECT_WRITTEN">DMI: Objet non sérialisable écr
it dans un ObjectOutput (DMI_NONSERIALIZABLE_OBJECT_WRITTEN)</a></h3> |
| 3799 |
| 3800 |
| 3801 <p>Ce code semble transmettre un objet non sérialisable à la méthode <code>Objec
tOutput.writeObject</code>. Une erreur se produira si cet objet est effectivemen
t non sérialisable.</p> |
| 3802 |
| 3803 |
| 3804 <h3><a name="DMI_USELESS_SUBSTRING">DMI: Appel de substring(0) qui retourne la v
aleur originale (DMI_USELESS_SUBSTRING)</a></h3> |
| 3805 |
| 3806 |
| 3807 <p>Ce code appelle <code>substring(0)</code> sur une chaine, ce qui renvoit la v
aleur originale.</p> |
| 3808 |
| 3809 |
| 3810 <h3><a name="DMI_THREAD_PASSED_WHERE_RUNNABLE_EXPECTED">Dm: Thread passed where
Runnable expected (DMI_THREAD_PASSED_WHERE_RUNNABLE_EXPECTED)</a></h3> |
| 3811 |
| 3812 |
| 3813 <p> A Thread object is passed as a parameter to a method where |
| 3814 a Runnable is expected. This is rather unusual, and may indicate a logic error |
| 3815 or cause unexpected behavior. |
| 3816 </p> |
| 3817 |
| 3818 |
| 3819 <h3><a name="EQ_DOESNT_OVERRIDE_EQUALS">Eq: Class doesn't override equals in sup
erclass (EQ_DOESNT_OVERRIDE_EQUALS)</a></h3> |
| 3820 |
| 3821 |
| 3822 <p> This class extends a class that defines an equals method and adds fields,
but doesn't |
| 3823 define an equals method itself. Thus, equality on instances of this class will |
| 3824 ignore the identity of the subclass and the added fields. Be sure this is what i
s intended, |
| 3825 and that you don't need to override the equals method. Even if you don't need to
override |
| 3826 the equals method, consider overriding it anyway to document the fact |
| 3827 that the equals method for the subclass just return the result of |
| 3828 invoking super.equals(o). |
| 3829 </p> |
| 3830 |
| 3831 |
| 3832 <h3><a name="EQ_UNUSUAL">Eq: Unusual equals method (EQ_UNUSUAL)</a></h3> |
| 3833 |
| 3834 |
| 3835 <p> This class doesn't do any of the patterns we recognize for checking that t
he type of the argument |
| 3836 is compatible with the type of the <code>this</code> object. There might not be
anything wrong with |
| 3837 this code, but it is worth reviewing. |
| 3838 </p> |
| 3839 |
| 3840 |
| 3841 <h3><a name="FE_FLOATING_POINT_EQUALITY">FE: Test d'égalité en virgule flottante
. (FE_FLOATING_POINT_EQUALITY)</a></h3> |
| 3842 |
| 3843 |
| 3844 <p>Cette opération teste l'égalité de deux valeurs en virgule flottante. Les cal
culs en virgule flottante pouvant introduire des arrondis, les valeurs flottante
s ou doubles peuvent être imprécises. Pour les valeurs qui doivent être précises
, telles que les valeurs monétaires, pensez à utiliser un type à précision fixe
tel qu'un <code>BigDecimal</code>. Pour les valeurs qui n'ont pas besoin d'être
précises, pensez à tester l'égalité sur une portée quelconque, par exemple : <co
de>if ( Math.abs(x - y) < .0000001 )</code>. Cf section 4.2.4 des spécificati
ons du langage Java.</p> |
| 3845 |
| 3846 |
| 3847 <h3><a name="VA_FORMAT_STRING_BAD_CONVERSION_TO_BOOLEAN">FS: Non-Boolean argumen
t formatted using %b format specifier (VA_FORMAT_STRING_BAD_CONVERSION_TO_BOOLEA
N)</a></h3> |
| 3848 |
| 3849 |
| 3850 <p> |
| 3851 An argument not of type Boolean is being formatted with a %b format specifier. T
his won't throw an |
| 3852 exception; instead, it will print true for any nonnull value, and false for null
. |
| 3853 This feature of format strings is strange, and may not be what you intended. |
| 3854 </p> |
| 3855 |
| 3856 |
| 3857 <h3><a name="IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD">IA: Appel amb
igu d'une méthode hérité ou externe (IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUT
ER_METHOD)</a></h3> |
| 3858 |
| 3859 |
| 3860 <p>Une classe interne invoque une méthode qui peut être résolue comme une méthod
e héritée ou comme une méthode définie dans une classe externe. La sémantique de
Java fait qu'elle sera résolue en invoquant la méthode héritée, mais ce n'est p
eut être pas votre intention. Si vous souhaitez réellement invoquer la méthode h
éritée, faite le en utilisant <code>super</code> (Ex : appelé <code>super.foo(17
)</code>) ce qui clarifiera votre code pour les autres lecteurs et pour FindBugs
.</p> |
| 3861 |
| 3862 |
| 3863 <h3><a name="IC_INIT_CIRCULARITY">IC: Initialisation circulaire (IC_INIT_CIRCULA
RITY)</a></h3> |
| 3864 |
| 3865 |
| 3866 <p>Une initialisation circulaire a été détectée dans les initialisations de vari
ables statiques de deux classes référencées par l'instance en erreur. De nombreu
ses sortes de comportements inattendus peuvent surgir d'une telle situation.</p> |
| 3867 |
| 3868 |
| 3869 <h3><a name="ICAST_IDIV_CAST_TO_DOUBLE">ICAST: Résultat d'une division entière t
ranstypé en nombre flottant (ICAST_IDIV_CAST_TO_DOUBLE)</a></h3> |
| 3870 |
| 3871 |
| 3872 <p>Ce code transtype le résultat d'une division entière en un nombre flottant à
double précision. Effectuer une division sur des nombres entiers n'est pas préci
s. Le fait que le résultat soit transtypé en <code>double</code> suggère que cet
te précision était voulue dès le départ. Peut être l'un ou l'autre des opérandes
, ou les deux opérandes, auraient du être transtypé avant d'effectuer la divisio
n. Voici un exemple :</p> |
| 3873 <blockquote> |
| 3874 <pre> |
| 3875 int x = 2; |
| 3876 int y = 5; |
| 3877 // Faux: renvoi 0.0 |
| 3878 double value1 = x / y; |
| 3879 |
| 3880 // Juste: renvoi 0.4 |
| 3881 double value2 = x / (double) y; |
| 3882 </pre> |
| 3883 </blockquote> |
| 3884 |
| 3885 |
| 3886 <h3><a name="ICAST_INTEGER_MULTIPLY_CAST_TO_LONG">ICAST: Résultat d'une multipli
cation entière transtypée en long (ICAST_INTEGER_MULTIPLY_CAST_TO_LONG)</a></h3> |
| 3887 |
| 3888 |
| 3889 <p>Ce code effectue des multiplications entières et transtype le résultat en <co
de>long</code>, comme dans : |
| 3890 <code>long convertDaysToMilliseconds(int days) { return 1000*3600*24*days; }</co
de>. Si la multiplication était réalisée en utilisant l'arithmétique <code>long<
/code>, vous pourriez éviter le risque de débordement de capacité du calcul. Vou
s pouvez par exemple corriger le code précédent par : <code>long convertDaysToMi
lliseconds(int days) { return 1000L*3600*24*days; }</code> ou <code><pre> |
| 3891 static final long MILLISECONDS_PER_DAY = 24L*3600*1000; |
| 3892 long convertDaysToMilliseconds(int days) { return days * MILLISECONDS_PER_DAY; }
|
| 3893 </pre></code></p> |
| 3894 |
| 3895 |
| 3896 <h3><a name="IM_AVERAGE_COMPUTATION_COULD_OVERFLOW">IM: Possibilité de débordeme
nt du calcul d'une moyenne (IM_AVERAGE_COMPUTATION_COULD_OVERFLOW)</a></h3> |
| 3897 |
| 3898 |
| 3899 <p>Le code calcule la moyenne de deux entiers au moyen d'une division ou d'un dé
calage signé vers la droite, puis utilise le résultat comme indice d'un tableau.
Si les valeurs moyennées sont très grandes, le calcul peut déborder (résultant
en un très grand négatif). En supposant que le résultat doive toujours être posi
tif, vous devriez plutôt utiliser un décalage à droite non signé. En d'autres te
rmes, utilisez plutôt <code>(low+high) >>> 1</code> au lieu de <code>(
low+high)/2</code>.</p> |
| 3900 <p>Le bug existe dans de nombreuses implémentations des recherches binaires et d
es tris fusion. Martin Buchholz <a href="http://bugs.sun.com/bugdatabase/view_bu
g.do?bug_id=6412541"> l'a recherché et corrigé </a> dans les librairies du JDK e
t Joshua Bloch <a href="http://googleresearch.blogspot.com/2006/06/extra-extra-r
ead-all-about-it-nearly.html"> a largement publié ce modèle de bug</a>.</p> |
| 3901 |
| 3902 |
| 3903 <h3><a name="IM_BAD_CHECK_FOR_ODD">IM: Test d'impaire ne fonctionnant pas avec l
es négatifs (IM_BAD_CHECK_FOR_ODD)</a></h3> |
| 3904 |
| 3905 |
| 3906 <p>Le code utilise <code>x % 2 == 1</code> pour véifier si une valeur est impair
e, mais cela ne fonctionera pas avec une valeur négative (Ex. : <code>(-5) % 2 =
= -1</code>). Si ce code doit tester si une valeur est impaire, envisagez d'util
iser <code>x & 1 == 1</code> ou <code>x % 2 != 0</code>.</p> |
| 3907 |
| 3908 |
| 3909 <h3><a name="INT_BAD_REM_BY_1">INT: Reste entier modulo 1 (INT_BAD_REM_BY_1)</a>
</h3> |
| 3910 |
| 3911 |
| 3912 <p>Cette expression (Ex. : <code>exp % 1</code>) est assurée de toujours renvoye
r 0. Vouliez-vous plutot dire <code>(exp & 1)</code> ou <code>(exp % 2)</code> ?
</p> |
| 3913 |
| 3914 |
| 3915 <h3><a name="INT_VACUOUS_BIT_OPERATION">INT: Vacuous bit mask operation on integ
er value (INT_VACUOUS_BIT_OPERATION)</a></h3> |
| 3916 |
| 3917 |
| 3918 <p> This is an integer bit operation (and, or, or exclusive or) that doesn't do
any useful work |
| 3919 (e.g., <code>v & 0xffffffff</code>). |
| 3920 |
| 3921 </p> |
| 3922 |
| 3923 |
| 3924 <h3><a name="INT_VACUOUS_COMPARISON">INT: Comparaison inutile de valeurs entière
s (INT_VACUOUS_COMPARISON)</a></h3> |
| 3925 |
| 3926 |
| 3927 <p>Il y a une comparaison entière qui renvoie toujours la même valeur (Ex. : <co
de>x <= Integer.MAX_VALUE</code>).</p> |
| 3928 |
| 3929 |
| 3930 <h3><a name="MTIA_SUSPECT_SERVLET_INSTANCE_FIELD">MTIA: La classe hérite de Serv
let et utilise les variables de l'instance. (MTIA_SUSPECT_SERVLET_INSTANCE_FIELD
)</a></h3> |
| 3931 |
| 3932 |
| 3933 <p>Cette classe hérite de la classe <code>Servlet</code>, et utilise une variabl
e de l'instance. Puisqu'une seule instance d'une classe <code>Servlet</code> est
créée par le cadre de travail J2EE, et est utilisée dans un environnement multi
tâche, ce paradigme est très fortement découragé et très certainement problémati
que. Considérer l'emploi seul de variables propres à la méthode.</p> |
| 3934 |
| 3935 |
| 3936 <h3><a name="MTIA_SUSPECT_STRUTS_INSTANCE_FIELD">MTIA: La classe hérite d'une cl
asse action Struts et utilise les variables de l'instance. (MTIA_SUSPECT_STRUTS_
INSTANCE_FIELD)</a></h3> |
| 3937 |
| 3938 |
| 3939 <p>Cette classe hérite d'une classe <code>Action</code> Struts, et utilise une v
ariable de cette instance. Puisqu'une seule instance de la classe <code>Action</
code> Struts est créée par le cadre de travail Struts, et est utilisée dans un e
nvironnement multitâche, ce paradigme est très fortement découragé et très certa
inement problématique. Considérer l'emploi seul de variables propres à la méthod
e.</p> |
| 3940 |
| 3941 |
| 3942 <h3><a name="NP_DEREFERENCE_OF_READLINE_VALUE">NP: Dereference of the result of
readLine() without nullcheck (NP_DEREFERENCE_OF_READLINE_VALUE)</a></h3> |
| 3943 |
| 3944 |
| 3945 <p> The result of invoking readLine() is dereferenced without checking to see
if the result is null. If there are no more lines of text |
| 3946 to read, readLine() will return null and dereferencing that will generate a null
pointer exception. |
| 3947 </p> |
| 3948 |
| 3949 |
| 3950 <h3><a name="NP_IMMEDIATE_DEREFERENCE_OF_READLINE">NP: Déréférencement immédiat
du résultat d'un readLine() (NP_IMMEDIATE_DEREFERENCE_OF_READLINE)</a></h3> |
| 3951 |
| 3952 |
| 3953 <p>Le résultat d'un appel à <code>readLine()</code> est immédiatement déréférenc
é. S'il n'y a plus d'autre lignes de texte à lire, <code>readLine()</code> retou
rnera <code>null</code> ce qui provoquera une <code>NullPointerException</code>
lors du déréférencement.</p> |
| 3954 |
| 3955 |
| 3956 <h3><a name="NP_LOAD_OF_KNOWN_NULL_VALUE">NP: Chargement d'une valeur connue pou
r être à null (NP_LOAD_OF_KNOWN_NULL_VALUE)</a></h3> |
| 3957 |
| 3958 |
| 3959 <p>La variable référencée est connue pour être à <code>null</code> suite à une v
érification précédente. Bien que cela soit valide, ce peut être une erreur (peut
-être vouliez-vous référencer une autre valeur ou le test précédent aurait-il du
e vérifier non-null plutôt que null).</p> |
| 3960 |
| 3961 |
| 3962 <h3><a name="NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION">NP: Method tightens nullne
ss annotation on parameter (NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION)</a></h3> |
| 3963 |
| 3964 <p> |
| 3965 A method should always implement the contract of a method it overrides.
Thus, if a method takes a parameter |
| 3966 that is marked as @Nullable, you shouldn't override that method in a subclas
s with a method where that parameter is @Nonnull. |
| 3967 Doing so violates the contract that the method should handle a null paramete
r. |
| 3968 </p> |
| 3969 |
| 3970 <h3><a name="NP_METHOD_RETURN_RELAXING_ANNOTATION">NP: Method relaxes nullness a
nnotation on return value (NP_METHOD_RETURN_RELAXING_ANNOTATION)</a></h3> |
| 3971 |
| 3972 <p> |
| 3973 A method should always implement the contract of a method it overrides.
Thus, if a method takes is annotated |
| 3974 as returning a @Nonnull value, |
| 3975 you shouldn't override that method in a subclass with a method annotated as
returning a @Nullable or @CheckForNull value. |
| 3976 Doing so violates the contract that the method shouldn't return null. |
| 3977 </p> |
| 3978 |
| 3979 <h3><a name="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE">NP: Pointeur à null renvoyé
par une méthode qui risque d'être déréférencé (NP_NULL_ON_SOME_PATH_FROM_RETURN
_VALUE)</a></h3> |
| 3980 |
| 3981 |
| 3982 <p>La valeur renvoyée par une méthode est déréférencée alors que cette méthode p
eut renvoyer <code>null</code>. Ceci peut conduire à une <code>NullPointerExcept
ion</code> quand le code sera exécuté.</p> |
| 3983 |
| 3984 |
| 3985 <h3><a name="NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE">NP: Possible null pointer
dereference on branch that might be infeasible (NP_NULL_ON_SOME_PATH_MIGHT_BE_I
NFEASIBLE)</a></h3> |
| 3986 |
| 3987 |
| 3988 <p> There is a branch of statement that, <em>if executed,</em> guarantees that |
| 3989 a null value will be dereferenced, which |
| 3990 would generate a <code>NullPointerException</code> when the code is executed. |
| 3991 Of course, the problem might be that the branch or statement is infeasible and t
hat |
| 3992 the null pointer exception can't ever be executed; deciding that is beyond the a
bility of FindBugs. |
| 3993 Due to the fact that this value had been previously tested for nullness, |
| 3994 this is a definite possibility. |
| 3995 </p> |
| 3996 |
| 3997 |
| 3998 <h3><a name="NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE">NP: Parameter
must be nonnull but is marked as nullable (NP_PARAMETER_MUST_BE_NONNULL_BUT_MARK
ED_AS_NULLABLE)</a></h3> |
| 3999 |
| 4000 |
| 4001 <p> This parameter is always used in a way that requires it to be nonnull, |
| 4002 but the parameter is explicitly annotated as being Nullable. Either the use |
| 4003 of the parameter or the annotation is wrong. |
| 4004 </p> |
| 4005 |
| 4006 |
| 4007 <h3><a name="NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD">NP: Read of unwritten publi
c or protected field (NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD)</a></h3> |
| 4008 |
| 4009 |
| 4010 <p> The program is dereferencing a public or protected |
| 4011 field that does not seem to ever have a non-null value written to it. |
| 4012 Unless the field is initialized via some mechanism not seen by the analysis, |
| 4013 dereferencing this value will generate a null pointer exception. |
| 4014 </p> |
| 4015 |
| 4016 |
| 4017 <h3><a name="NS_DANGEROUS_NON_SHORT_CIRCUIT">NS: Potentially dangerous use of no
n-short-circuit logic (NS_DANGEROUS_NON_SHORT_CIRCUIT)</a></h3> |
| 4018 |
| 4019 |
| 4020 <p> This code seems to be using non-short-circuit logic (e.g., & |
| 4021 or |) |
| 4022 rather than short-circuit logic (&& or ||). In addition, |
| 4023 it seem possible that, depending on the value of the left hand side, you might n
ot |
| 4024 want to evaluate the right hand side (because it would have side effects, could
cause an exception |
| 4025 or could be expensive.</p> |
| 4026 <p> |
| 4027 Non-short-circuit logic causes both sides of the expression |
| 4028 to be evaluated even when the result can be inferred from |
| 4029 knowing the left-hand side. This can be less efficient and |
| 4030 can result in errors if the left-hand side guards cases |
| 4031 when evaluating the right-hand side can generate an error. |
| 4032 </p> |
| 4033 |
| 4034 <p>See <a href="http://java.sun.com/docs/books/jls/third_edition/html/expression
s.html#15.22.2">the Java |
| 4035 Language Specification</a> for details |
| 4036 |
| 4037 </p> |
| 4038 |
| 4039 |
| 4040 <h3><a name="NS_NON_SHORT_CIRCUIT">NS: Utilisation discutable de logique binaire
(NS_NON_SHORT_CIRCUIT)</a></h3> |
| 4041 |
| 4042 |
| 4043 <p>Ce code semble utiliser de la logique binaire (Ex. : <code>&</code> ou <c
ode>|</code>) plutôt que les opérateurs booléens (<code>&&</code> ou <co
de>||</code>). La logique binaire entraîne l'évaluation systématique de toute l'
expression, même quand le résultat pourrait être immédiatement déduit. Ceci est
moins performant et peut provoquer des erreurs lorsque la partie gauche de l'exp
ression masque des cas de la partie droite.</p> |
| 4044 |
| 4045 |
| 4046 <h3><a name="PZLA_PREFER_ZERO_LENGTH_ARRAYS">PZLA: Envisagez de renvoyer un tabl
eau vide plutôt que null (PZLA_PREFER_ZERO_LENGTH_ARRAYS)</a></h3> |
| 4047 |
| 4048 |
| 4049 <p>Renvoyer un tableau vide constitue souvent une meilleure approche plutôt que
de renvoyer une référence à <code>null</code> pour signaler qu'il n'y a pas de r
ésultat (c'est-à-dire, une liste vide de résultats). De cette façon, aucune véri
fication explicite du <code>null</code> n'est nécessaire dans les méthodes clien
tes.</p> |
| 4050 <p>D'un autre côté, utiliser <code>null</code> signifie "il n'y a pas de réponse
à cette question". Cela peut donc être approprié. Par exemple, <code>File.listF
iles()</code> renvoi une liste vide si un répertoire donné ne contient pas de fi
chiers, et renvoi <code>null</code> si le fichier n'est pas un répertoire.</p> |
| 4051 |
| 4052 |
| 4053 <h3><a name="QF_QUESTIONABLE_FOR_LOOP">QF: Incrémentation compliquée, subtile au
incorrecte dans une boucle for (QF_QUESTIONABLE_FOR_LOOP)</a></h3> |
| 4054 |
| 4055 |
| 4056 <p>Etes vous certain que cette boucle incrémente la variable voulue ? Il sembler
aît qu'une autre variable est initialisée et vérifiée par la boucle.</p> |
| 4057 |
| 4058 |
| 4059 <h3><a name="RCN_REDUNDANT_COMPARISON_OF_NULL_AND_NONNULL_VALUE">RCN: Comparaiso
n redondante d'une valeur non nulle avec null (RCN_REDUNDANT_COMPARISON_OF_NULL_
AND_NONNULL_VALUE)</a></h3> |
| 4060 |
| 4061 |
| 4062 <p>Cette méthode contient une comparaison entre une référence connue pour être n
on nulle avec une autre référence connue pour être à <code>null</code>.</p> |
| 4063 |
| 4064 |
| 4065 <h3><a name="RCN_REDUNDANT_COMPARISON_TWO_NULL_VALUES">RCN: Comparaison redondan
te de deux valeurs nulles (RCN_REDUNDANT_COMPARISON_TWO_NULL_VALUES)</a></h3> |
| 4066 |
| 4067 |
| 4068 <p>Cette méthode contient une comparaison redondante entre deux références connu
es pour être obligatoirement à <code>null</code>.</p> |
| 4069 |
| 4070 |
| 4071 <h3><a name="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE">RCN: Test de nullité redo
ndant sur une valeur non nulle (RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE)</a></h
3> |
| 4072 |
| 4073 |
| 4074 <p>Cette méthode contient un test redondant de nullité sur une valeur connue pou
r être non nulle.</p> |
| 4075 |
| 4076 |
| 4077 <h3><a name="RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE">RCN: Test de nullité redonda
nt sur une valeur connue pour être à null (RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE
)</a></h3> |
| 4078 |
| 4079 |
| 4080 <p>Cette méthode contient un test redondant de nullité sur une valeur ne pouvant
qu'être à <code>null</code>.</p> |
| 4081 |
| 4082 |
| 4083 <h3><a name="REC_CATCH_EXCEPTION">REC: java.lang.Exception est intercepté alors
qu'Exception n'est jamais lancé (REC_CATCH_EXCEPTION)</a></h3> |
| 4084 |
| 4085 |
| 4086 <p>Cette méthode utilise un block <code>try-catch</code> qui intercepte les obje
ts <code>Exception</code>, mais <code>Exception</code> n'est jamais déclenché da
ns ce bloc, et <code>RuntimeException</code> n'est pas explicitement intercepté.
C'est une erreur commune de dire que <code>try / catch (Exception e)</code> es
t identique à plusieurs <code>try / catch</code>, mais cette tournure intercepte
également les <code>RuntimeException</code>, masquant des bugs potentiels.</p> |
| 4087 |
| 4088 |
| 4089 <h3><a name="RI_REDUNDANT_INTERFACES">RI: Classe implémentant la même interface
que sa super-classe (RI_REDUNDANT_INTERFACES)</a></h3> |
| 4090 |
| 4091 |
| 4092 <p>Cette classe déclare implémenter une interface qui est aussi implémentée par
une de ses classes mères. Ceci est redondant : dès qu'une super-classe implément
e une interface, toutes les sous-classes le font aussi par défaut. Cela peut ind
iquer que la hiérarchie d'héritage a changé depuis la création de cette classe e
t la cible de l'implémentation de l'interface doit peut-être être reprise en con
sidération.</p> |
| 4093 |
| 4094 |
| 4095 <h3><a name="RV_CHECK_FOR_POSITIVE_INDEXOF">RV: Méthode vérifiant que le résulta
t d'un String.indexOf() est positif (RV_CHECK_FOR_POSITIVE_INDEXOF)</a></h3> |
| 4096 |
| 4097 |
| 4098 <p>La méthode appelle <code>String.indexOf()</code> et vérifie si le résultat es
t strictement positif ou pas. Il est plus habituel de vérifier si le résultat es
t négatif. Il n'est strictement positif que lorsque la sous-chaine recherchée ap
paraît ailleurs qu'au début de la chaine.</p> |
| 4099 |
| 4100 |
| 4101 <h3><a name="RV_DONT_JUST_NULL_CHECK_READLINE">RV: Méthode ignorant le résultat
d'un readLine() après avoir vérifié qu'il est non nul (RV_DONT_JUST_NULL_CHECK_R
EADLINE)</a></h3> |
| 4102 |
| 4103 |
| 4104 <p>La valeur renvoyée par <code>readLine()</code> est ignorée après avoir vérifi
é s'il n'est pas à <code>null</code>. Dans quasiment tous les cas, si le résulta
t n'est pas à <code>null</code>, vous souhaiterez utiliser cette valeur. Appeler
de nouveau <code>readLine()</code> vous renverra une ligne différente.</p> |
| 4105 |
| 4106 |
| 4107 <h3><a name="RV_REM_OF_HASHCODE">RV: Reste d'un hashCode pouvant être négatif (R
V_REM_OF_HASHCODE)</a></h3> |
| 4108 |
| 4109 |
| 4110 <p>Ce code calcule le code de hachage, puis son reste modulo une certaine valeur
. Puisque le code de hachage peut être négatif, le reste peut également l'être.<
/p> |
| 4111 <p>En supposant que vous vouliez garantir que le résultat de votre opération ne
soit pas négatif, vous devriez modifier votre code. Si le diviseur est une puiss
ance de 2, vous pourriez utiliser un décalage binaire à la place (c'est-à-dire <
code>x.hashCode()&(n-1)</code> au lieu de <code>x.hashCode()%n</code>). Cela
est probablement plus rapide que de calculer le reste. Si le diviseur n'est pas
une puissance de 2, vous devriez prendre la valeur absolue du reste (<code>Math
.abs(x.hashCode()%n)</code>).</p> |
| 4112 |
| 4113 |
| 4114 <h3><a name="RV_REM_OF_RANDOM_INT">RV: Reste d'un entier signé 32 bits aléeatoir
e (RV_REM_OF_RANDOM_INT)</a></h3> |
| 4115 |
| 4116 |
| 4117 <p>Ce code génère un entier signé aléatoire puis calcule le reste de cette valeu
r modulo une autre valeur. Puisque ce nombre aléatoire peut être négatif, le res
te de l'opération peut également l'être. Soyez sûr que c'est voulu, et envisagez
d'utiliser à la place la méthode <code>Random.nextInt(int)</code>.</p> |
| 4118 |
| 4119 |
| 4120 <h3><a name="RV_RETURN_VALUE_IGNORED_INFERRED">RV: Method ignores return value,
is this OK? (RV_RETURN_VALUE_IGNORED_INFERRED)</a></h3> |
| 4121 |
| 4122 |
| 4123 <p>This code calls a method and ignores the return value. The return value |
| 4124 is the same type as the type the method is invoked on, and from our analysis it
looks |
| 4125 like the return value might be important (e.g., like ignoring the |
| 4126 return value of <code>String.toLowerCase()</code>). |
| 4127 </p> |
| 4128 <p>We are guessing that ignoring the return value might be a bad idea just from |
| 4129 a simple analysis of the body of the method. You can use a @CheckReturnValue ann
otation |
| 4130 to instruct FindBugs as to whether ignoring the return value of this method |
| 4131 is important or acceptable. |
| 4132 </p> |
| 4133 <p>Please investigate this closely to decide whether it is OK to ignore the retu
rn value. |
| 4134 </p> |
| 4135 |
| 4136 |
| 4137 <h3><a name="SA_FIELD_DOUBLE_ASSIGNMENT">SA: Double assignment of field (SA_FIEL
D_DOUBLE_ASSIGNMENT)</a></h3> |
| 4138 |
| 4139 |
| 4140 <p> This method contains a double assignment of a field; e.g. |
| 4141 </p> |
| 4142 <pre> |
| 4143 int x,y; |
| 4144 public void foo() { |
| 4145 x = x = 17; |
| 4146 } |
| 4147 </pre> |
| 4148 <p>Assigning to a field twice is useless, and may indicate a logic error or typo
.</p> |
| 4149 |
| 4150 |
| 4151 <h3><a name="SA_LOCAL_DOUBLE_ASSIGNMENT">SA: Double assignment of local variable
(SA_LOCAL_DOUBLE_ASSIGNMENT)</a></h3> |
| 4152 |
| 4153 |
| 4154 <p> This method contains a double assignment of a local variable; e.g. |
| 4155 </p> |
| 4156 <pre> |
| 4157 public void foo() { |
| 4158 int x,y; |
| 4159 x = x = 17; |
| 4160 } |
| 4161 </pre> |
| 4162 <p>Assigning the same value to a variable twice is useless, and may indicate a l
ogic error or typo.</p> |
| 4163 |
| 4164 |
| 4165 <h3><a name="SA_LOCAL_SELF_ASSIGNMENT">SA: Auto-alimentation d'une variable loca
le (SA_LOCAL_SELF_ASSIGNMENT)</a></h3> |
| 4166 |
| 4167 |
| 4168 <p>Cette méthode contient une auto-alimentation d'une variable locale, par exemp
le :</p> |
| 4169 <pre> |
| 4170 public vida foo() { |
| 4171 int x = 3; |
| 4172 x = x; |
| 4173 } |
| 4174 </pre> |
| 4175 <p>De telles affectations sont inutiles et peuvent indiquer une faute de frappe
ou une erreur de logique.</p> |
| 4176 |
| 4177 |
| 4178 <h3><a name="SF_SWITCH_FALLTHROUGH">SF: Un switch comporte un cas qui déborde su
r le suivant (SF_SWITCH_FALLTHROUGH)</a></h3> |
| 4179 |
| 4180 |
| 4181 <p>Cette méthode contient un <code>switch</code> dont l'un des cas déborde sur l
e suivant. Normalement, vous devez terminer chaque cas avec une instruction <cod
e>break</code> ou <code>return</code>.</p> |
| 4182 |
| 4183 |
| 4184 <h3><a name="SF_SWITCH_NO_DEFAULT">SF: Switch statement found where default case
is missing (SF_SWITCH_NO_DEFAULT)</a></h3> |
| 4185 |
| 4186 |
| 4187 <p> This method contains a switch statement where default case is missing. |
| 4188 Usually you need to provide a default case.</p> |
| 4189 <p>Because the analysis only looks at the generated bytecode, this warning can
be incorrect triggered if |
| 4190 the default case is at the end of the switch statement and doesn't end with a br
eak statement. |
| 4191 |
| 4192 |
| 4193 <h3><a name="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD">ST: Ecriture d'un champ st
atique depuis la méthode d'une instance (ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD
)</a></h3> |
| 4194 |
| 4195 |
| 4196 <p>La méthode de l'instance écrit la valeur d'un champ statique. Cela peut être
difficile à gérer si plusieurs instances ont la possibilité d'écrire cette valeu
r et cela ressemble surtout à une mauvaise pratique.</p> |
| 4197 |
| 4198 |
| 4199 <h3><a name="SE_PRIVATE_READ_RESOLVE_NOT_INHERITED">Se: Private readResolve meth
od not inherited by subclasses (SE_PRIVATE_READ_RESOLVE_NOT_INHERITED)</a></h3> |
| 4200 |
| 4201 |
| 4202 <p> This class defines a private readResolve method. Since it is private, it w
on't be inherited by subclasses. |
| 4203 This might be intentional and OK, but should be reviewed to ensure it is what is
intended. |
| 4204 </p> |
| 4205 |
| 4206 |
| 4207 <h3><a name="SE_TRANSIENT_FIELD_OF_NONSERIALIZABLE_CLASS">Se: Transient field of
class that isn't Serializable. (SE_TRANSIENT_FIELD_OF_NONSERIALIZABLE_CLASS)</
a></h3> |
| 4208 |
| 4209 |
| 4210 <p> The field is marked as transient, but the class isn't Serializable, so mar
king it as transient |
| 4211 has absolutely no effect. |
| 4212 This may be leftover marking from a previous version of the code in which the cl
ass was transient, or |
| 4213 it may indicate a misunderstanding of how serialization works. |
| 4214 </p> |
| 4215 |
| 4216 |
| 4217 <h3><a name="TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK">TQ: Value req
uired to have type qualifier, but marked as unknown (TQ_EXPLICIT_UNKNOWN_SOURCE_
VALUE_REACHES_ALWAYS_SINK)</a></h3> |
| 4218 |
| 4219 |
| 4220 <p> |
| 4221 A value is used in a way that requires it to be always be a value denoted
by a type qualifier, but |
| 4222 there is an explicit annotation stating that it is not known where the value
is required to have that type qualifier. |
| 4223 Either the usage or the annotation is incorrect. |
| 4224 </p> |
| 4225 |
| 4226 |
| 4227 <h3><a name="TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK">TQ: Value requ
ired to not have type qualifier, but marked as unknown (TQ_EXPLICIT_UNKNOWN_SOUR
CE_VALUE_REACHES_NEVER_SINK)</a></h3> |
| 4228 |
| 4229 |
| 4230 <p> |
| 4231 A value is used in a way that requires it to be never be a value denoted b
y a type qualifier, but |
| 4232 there is an explicit annotation stating that it is not known where the value
is prohibited from having that type qualifier. |
| 4233 Either the usage or the annotation is incorrect. |
| 4234 </p> |
| 4235 |
| 4236 |
| 4237 <h3><a name="UCF_USELESS_CONTROL_FLOW">UCF: Instruction de contrôle du flux inut
ile (UCF_USELESS_CONTROL_FLOW)</a></h3> |
| 4238 |
| 4239 |
| 4240 <p>Cette méthode contient une instruction de contrôle du flux inutile. Ceci est
souvent provoqué par inadvertance, en utilisant un paragraphe vide comme corps d
'une condition. Exemple :</p> |
| 4241 <pre> |
| 4242 if (argv.length == 1); |
| 4243 System.out.println("Hello, " + argv[0]); |
| 4244 </pre> |
| 4245 |
| 4246 |
| 4247 <h3><a name="UCF_USELESS_CONTROL_FLOW_NEXT_LINE">UCF: Useless control flow to ne
xt line (UCF_USELESS_CONTROL_FLOW_NEXT_LINE)</a></h3> |
| 4248 |
| 4249 |
| 4250 <p> This method contains a useless control flow statement in which control |
| 4251 flow follows to the same or following line regardless of whether or not |
| 4252 the branch is taken. |
| 4253 Often, this is caused by inadvertently using an empty statement as the |
| 4254 body of an <code>if</code> statement, e.g.:</p> |
| 4255 <pre> |
| 4256 if (argv.length == 1); |
| 4257 System.out.println("Hello, " + argv[0]); |
| 4258 </pre> |
| 4259 |
| 4260 |
| 4261 <h3><a name="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD">UrF: Unread public/protected
field (URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD)</a></h3> |
| 4262 |
| 4263 |
| 4264 <p> This field is never read. |
| 4265 The field is public or protected, so perhaps |
| 4266 it is intended to be used with classes not seen as part of the analysis. If
not, |
| 4267 consider removing it from the class.</p> |
| 4268 |
| 4269 |
| 4270 <h3><a name="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD">UuF: Unused public or protect
ed field (UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD)</a></h3> |
| 4271 |
| 4272 |
| 4273 <p> This field is never used. |
| 4274 The field is public or protected, so perhaps |
| 4275 it is intended to be used with classes not seen as part of the analysis. If
not, |
| 4276 consider removing it from the class.</p> |
| 4277 |
| 4278 |
| 4279 <h3><a name="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR">UwF: Champ non initialisé
dans le constructeur (UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR)</a></h3> |
| 4280 |
| 4281 |
| 4282 <p>Ce champ n'est jamais initialisé dans aucun constructeur, et est de ce fait <
code>null</code> une fois l'objet initialisé. Soit il s'agit d'une erreur, soit
il s'agit d'un design douteux puisque ce champ génèra une exception s'il est dér
éférencé avant toute initialisation.</p> |
| 4283 |
| 4284 |
| 4285 <h3><a name="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD">UwF: Unwritten public or p
rotected field (UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD)</a></h3> |
| 4286 |
| 4287 |
| 4288 <p> No writes were seen to this public/protected field. All reads of it
will return the default |
| 4289 value. Check for errors (should it have been initialized?), or remove it if it i
s useless.</p> |
| 4290 |
| 4291 |
| 4292 <h3><a name="XFB_XML_FACTORY_BYPASS">XFB: Méthode instanciant directement une im
plémentation spécifique des interfaces XML (XFB_XML_FACTORY_BYPASS)</a></h3> |
| 4293 |
| 4294 |
| 4295 <p>Cette méthode instancie une implémentation spécifique de l'interface XML. Il
est préférable d'utiliser les classes 'Factory' fournies pour créer ces objets,
ce qui permet de changer d'implémentation à l'exécution. Pour des détails, cf. :
</p> |
| 4296 <p> |
| 4297 <ul> |
| 4298 <li>javax.xml.parsers.DocumentBuilderFactory</li> |
| 4299 <li>javax.xml.parsers.SAXParserFactory</li> |
| 4300 <li>javax.xml.transform.TransformerFactory</li> |
| 4301 <li>org.w3c.dom.Document.create<i>XXXX</i></li> |
| 4302 </ul> |
| 4303 </p> |
| 4304 |
| 4305 |
| 4306 |
| 4307 |
| 4308 <hr> <p> |
| 4309 <script language="JavaScript" type="text/javascript"> |
| 4310 <!---//hide script from old browsers |
| 4311 document.write( "Last updated "+ document.lastModified + "." ); |
| 4312 //end hiding contents ---> |
| 4313 </script> |
| 4314 <p> Send comments to <a class="sidebar" href="mailto:findbugs@cs.umd.edu">findbu
gs@cs.umd.edu</a> |
| 4315 <p> |
| 4316 <A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?gro
up_id=96405&type=5" width="210" height="62" border="0" alt="SourceForge.net
Logo" /></A> |
| 4317 </td></tr></table> |
| 4318 </body></html> |
OLD | NEW |