removed old TODO checking

This commit is contained in:
Oliver Burn 2002-11-13 02:35:26 +00:00
parent 7514320e04
commit 01d27913a7
4 changed files with 0 additions and 141 deletions

View File

@ -20,19 +20,16 @@ package com.puppycrawl.tools.checkstyle;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.PrintStream;
import java.io.Serializable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.apache.regexp.RE;
import org.apache.regexp.RESyntaxException;
import com.puppycrawl.tools.checkstyle.api.Utils;
@ -46,16 +43,6 @@ import com.puppycrawl.tools.checkstyle.api.Utils;
public class Configuration
implements Serializable
{
////////////////////////////////////////////////////////////////////////////
// Constants
////////////////////////////////////////////////////////////////////////////
/** pattern defaults **/
private static final Map PATTERN_DEFAULTS = new HashMap();
static {
PATTERN_DEFAULTS.put(Defn.TODO_PATTERN_PROP, "TODO:");
}
////////////////////////////////////////////////////////////////////////////
// Member variables
////////////////////////////////////////////////////////////////////////////
@ -76,12 +63,6 @@ public class Configuration
mIntProps.put(Defn.TAB_WIDTH_PROP, new Integer(8));
}
/** map of all the pattern properties **/
private final Map mPatterns = new HashMap();
/** map of all the corresponding RE objects for pattern properties **/
private transient Map mRegexps = new HashMap();
/** map of all String properties - by default are null **/
private final Map mStringProps = new HashMap();
{
@ -112,10 +93,6 @@ public class Configuration
setBooleanProperty(aProps, Defn.ALL_BOOLEAN_PROPS[i]);
}
for (int i = 0; i < Defn.ALL_PATTERN_PROPS.length; i++) {
setPatternProperty(aProps, Defn.ALL_PATTERN_PROPS[i]);
}
for (int i = 0; i < Defn.ALL_INT_PROPS.length; i++) {
setIntProperty(aProps, aLog, Defn.ALL_INT_PROPS[i]);
}
@ -131,17 +108,6 @@ public class Configuration
*/
public Configuration()
{
try {
for (int i = 0; i < Defn.ALL_PATTERN_PROPS.length; i++) {
setPatternProperty(
Defn.ALL_PATTERN_PROPS[i],
(String) PATTERN_DEFAULTS.get(Defn.ALL_PATTERN_PROPS[i]));
}
}
catch (RESyntaxException ex) {
ex.printStackTrace();
throw new IllegalStateException(ex.getMessage());
}
}
/**
@ -160,22 +126,6 @@ public class Configuration
// initialize the transient fields
mLoader = Thread.currentThread().getContextClassLoader();
mRegexps = new HashMap();
try {
// Loop on the patterns creating the RE's
final Iterator keys = mPatterns.keySet().iterator();
while (keys.hasNext()) {
final String k = (String) keys.next();
mRegexps.put(k, new RE((String) mPatterns.get(k)));
}
}
catch (RESyntaxException ex) {
// This should never happen, as the serialized regexp patterns
// somehow must have passed a setPattern() method.
throw new InvalidObjectException(
"invalid regular expression syntax");
}
}
@ -208,11 +158,6 @@ public class Configuration
retVal.put(key, String.valueOf(getBooleanProperty(key)));
}
for (int i = 0; i < Defn.ALL_PATTERN_PROPS.length; i++) {
final String key = Defn.ALL_PATTERN_PROPS[i];
Utils.addObjectString(retVal, key, getPatternProperty(key));
}
for (int i = 0; i < Defn.ALL_INT_PROPS.length; i++) {
final String key = Defn.ALL_INT_PROPS[i];
Utils.addObjectString(retVal, key,
@ -245,18 +190,6 @@ public class Configuration
return getStringProperty(Defn.LOCALE_COUNTRY_PROP);
}
/** @return pattern to match to-do lines **/
String getTodoPat()
{
return getPatternProperty(Defn.TODO_PATTERN_PROP);
}
/** @return regexp to match to-do lines **/
RE getTodoRegexp()
{
return getRegexpProperty(Defn.TODO_PATTERN_PROP);
}
/** @return distance between tab stops */
int getTabWidth()
{
@ -316,57 +249,10 @@ public class Configuration
mIntProps.put(aName, new Integer(aTo));
}
/**
* Set an pattern property.
* @param aName name of the property to set
* @param aPat the value to set
* @throws RESyntaxException if an error occurs
*/
private void setPatternProperty(String aName, String aPat)
throws RESyntaxException
{
// Set the regexp first, incase cannot create the RE
mRegexps.put(aName, new RE(aPat));
mPatterns.put(aName, aPat);
}
////////////////////////////////////////////////////////////////////////////
// Private methods
////////////////////////////////////////////////////////////////////////////
/**
* Set the value of an pattern property. If the property is not defined
* then a default value is used.
* @param aProps the properties set to use
* @param aName the name of the property to parse
* @throws RESyntaxException if an error occurs
*/
private void setPatternProperty(Properties aProps, String aName)
throws RESyntaxException
{
setPatternProperty(
aName,
aProps.getProperty(aName, (String) PATTERN_DEFAULTS.get(aName)));
}
/**
* @return the pattern for specified property
* @param aName the name of the property
*/
private String getPatternProperty(String aName)
{
return (String) mPatterns.get(aName);
}
/**
* @return the regexp for specified property
* @param aName the name of the property
*/
private RE getRegexpProperty(String aName)
{
return (RE) mRegexps.get(aName);
}
/**
* @return an integer property
* @param aName the name of the integer property to get

View File

@ -29,8 +29,6 @@ public interface Defn
/** name of resource bundle for Checkstyle */
String CHECKSTYLE_BUNDLE = "com.puppycrawl.tools.checkstyle.messages";
/** property name for the to-do pattern **/
String TODO_PATTERN_PROP = "checkstyle.pattern.todo";
/** property name for allowing protected data **/
String TAB_WIDTH_PROP = "checkstyle.tab.width";
/** property name for requiring package documentation */
@ -52,12 +50,6 @@ public interface Defn
REQUIRE_PACKAGE_HTML_PROP,
};
/** All the properties that are a regulare expression */
String[] ALL_PATTERN_PROPS = new String[]
{
TODO_PATTERN_PROP,
};
/** All the integer properties */
String[] ALL_INT_PROPS = new String[]
{

View File

@ -103,10 +103,6 @@ class Verifier
**/
void reportCPPComment(int aStartLineNo, int aStartColNo)
{
final String cmt = mLines[aStartLineNo - 1].substring(aStartColNo);
if (mConfig.getTodoRegexp().match(cmt)) {
mMessages.add(aStartLineNo, "todo.match", mConfig.getTodoPat());
}
}
/**
@ -119,16 +115,6 @@ class Verifier
void reportCComment(int aStartLineNo, int aStartColNo,
int aEndLineNo, int aEndColNo)
{
final String[] cc = extractCComment(aStartLineNo, aStartColNo,
aEndLineNo, aEndColNo);
// Check for to-do comments
for (int i = 0; i < cc.length; i++) {
if (mConfig.getTodoRegexp().match(cc[i])) {
mMessages.add(aStartLineNo + i, "todo.match",
mConfig.getTodoPat());
}
}
}

View File

@ -87,15 +87,10 @@ public class CheckerTest
public void testSimple()
throws Exception
{
mProps.setProperty(Defn.TODO_PATTERN_PROP, "FIXME:");
final Checker c = createChecker();
final String filepath = getPath("InputSimple.java");
assertNotNull(c);
final String[] expected = {
filepath + ":161: Comment matches to-do format 'FIXME:'.",
filepath + ":162: Comment matches to-do format 'FIXME:'.",
filepath + ":163: Comment matches to-do format 'FIXME:'.",
filepath + ":167: Comment matches to-do format 'FIXME:'.",
};
verify(c, filepath, expected);
}