[Fb-contrib-commit] SF.net SVN: fb-contrib:[1510] trunk/fb-contrib
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2010-01-25 02:01:36
|
Revision: 1510
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1510&view=rev
Author: dbrosius
Date: 2010-01-25 02:01:27 +0000 (Mon, 25 Jan 2010)
Log Message:
-----------
add S508C_NON_TRANSLATABLE_STRING
Modified Paths:
--------------
trunk/fb-contrib/etc/findbugs.xml
trunk/fb-contrib/etc/messages.xml
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2010-01-24 16:48:56 UTC (rev 1509)
+++ trunk/fb-contrib/etc/findbugs.xml 2010-01-25 02:01:27 UTC (rev 1510)
@@ -160,7 +160,7 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.Section508Compliance"
speed="fast"
- reports="S508C_NULL_LAYOUT,S508C_NO_SETLABELFOR,S508C_NO_SETSIZE,S508C_NON_ACCESSIBLE_JCOMPONENT,S508C_SET_COMP_COLOR" />
+ reports="S508C_NULL_LAYOUT,S508C_NO_SETLABELFOR,S508C_NO_SETSIZE,S508C_NON_ACCESSIBLE_JCOMPONENT,S508C_SET_COMP_COLOR,S508C_NON_TRANSLATABLE_STRING" />
<Detector class="com.mebigfatguy.fbcontrib.detect.UseEnumCollections"
speed="fast" reports="UEC_USE_ENUM_COLLECTIONS" />
@@ -436,6 +436,8 @@
category="CORRECTNESS" />
<BugPattern abbrev="S508C" type="S508C_SET_COMP_COLOR"
category="CORRECTNESS" />
+ <BugPattern abbrev="S508C" type="S508C_NON_TRANSLATABLE_STRING"
+ category="CORRECTNESS" />
<BugPattern abbrev="UEC" type="UEC_USE_ENUM_COLLECTIONS"
category="PERFORMANCE" />
<BugPattern abbrev="SIL" type="SIL_SQL_IN_LOOP" category="PERFORMANCE" />
Modified: trunk/fb-contrib/etc/messages.xml
===================================================================
--- trunk/fb-contrib/etc/messages.xml 2010-01-24 16:48:56 UTC (rev 1509)
+++ trunk/fb-contrib/etc/messages.xml 2010-01-25 02:01:27 UTC (rev 1510)
@@ -1870,6 +1870,18 @@
</Details>
</BugPattern>
+ <BugPattern type="S508C_NON_TRANSLATABLE_STRING">
+ <ShortDescription>Method passes constant string to title/label of component</ShortDescription>
+ <LongDescription>Method {1} passes constant string to title/label of component</LongDescription>
+ <Details>
+ <![CDATA[
+ <p>This method creates a component and passes a string literal to the title or label
+ of the component. As this string will be shown to users, it should be internationalizable
+ through the use of a resource bundle.</p>
+ ]]>
+ </Details>
+ </BugPattern>
+
<BugPattern type="UEC_USE_ENUM_COLLECTIONS">
<ShortDescription>Class uses an ordinary set or map with an enum class as the key</ShortDescription>
<LongDescription>Class {0} uses an ordinary set or map with an enum class as the key</LongDescription>
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2010-01-24 16:48:56 UTC (rev 1509)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2010-01-25 02:01:27 UTC (rev 1510)
@@ -78,6 +78,18 @@
clsNFException = cnfe;
}
}
+
+ private static final Map<String, Integer> displayTextMethods = new HashMap<String, Integer>();
+ static {
+ displayTextMethods.put("javax/swing/JLabel#<init>(Ljava/lang/String;)", Integer.valueOf(0));
+ displayTextMethods.put("javax/swing/JLabel#<init>(Ljava/lang/String;Ljavax/swing/Icon;I)", Integer.valueOf(1));
+ displayTextMethods.put("javax/swing/JLabel#<init>(Ljava/lang/String;I)", Integer.valueOf(2));
+ displayTextMethods.put("javax/swing/JButton#<init>(Ljava/lang/String;)", Integer.valueOf(0));
+ displayTextMethods.put("javax/swing/JButton#<init>(Ljava/lang/String;Ljavax/swing/Icon;)", Integer.valueOf(1));
+ displayTextMethods.put("javax/swing/JFrame#<init>(Ljava/lang/String;)", Integer.valueOf(0));
+ displayTextMethods.put("javax/swing/JFrame#<init>(Ljava/lang/String;Ljava/awt/GraphicsConfiguration;)", Integer.valueOf(1));
+ }
+
private final BugReporter bugReporter;
private OpcodeStack stack;
private Set<XField> fieldLabels;
@@ -265,6 +277,28 @@
}
}
}
+
+ if ((seen == INVOKEVIRTUAL) || (seen == INVOKESPECIAL) || (seen == INVOKEINTERFACE)) {
+ StringBuilder methodInfo = new StringBuilder();
+ methodInfo.append(getClassConstantOperand());
+ methodInfo.append("#");
+ methodInfo.append(getNameConstantOperand());
+ String signature = getSigConstantOperand();
+ signature = signature.substring(0, signature.indexOf(')') + 1);
+ methodInfo.append(signature);
+ Integer parmIndex = displayTextMethods.get(methodInfo.toString());
+ if (parmIndex != null) {
+ if (stack.getStackDepth() >= parmIndex.intValue()) {
+ OpcodeStack.Item item = stack.getStackItem(parmIndex.intValue());
+ if (item.getConstant() != null) {
+ bugReporter.reportBug(new BugInstance(this, "S508C_NON_TRANSLATABLE_STRING", NORMAL_PRIORITY)
+ .addClass(this)
+ .addMethod(this)
+ .addSourceLine(this));
+ }
+ }
+ }
+ }
} catch (ClassNotFoundException cnfe) {
bugReporter.reportMissingClass(cnfe);
} finally {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|