Thread: [Japi-cvs] SF.net SVN: japi:[1382] tools/archStat/trunk/src/prj/net/sf/japi/archstat/ ArchStat.java
Status: Beta
Brought to you by:
christianhujer
From: <chr...@us...> - 2009-10-05 00:20:57
|
Revision: 1382 http://japi.svn.sourceforge.net/japi/?rev=1382&view=rev Author: christianhujer Date: 2009-10-05 00:20:45 +0000 (Mon, 05 Oct 2009) Log Message: ----------- Fix some IntelliJ IDEA warnings. Modified Paths: -------------- tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java 2009-10-05 00:18:29 UTC (rev 1381) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java 2009-10-05 00:20:45 UTC (rev 1382) @@ -165,46 +165,46 @@ private static final Pattern SOURCE_LINE_PATTERN = Pattern.compile("^.*\\S.*\\S.*\\S.*$", Pattern.MULTILINE); /** Returns the number of lines in the specified string. - * @param string String of which to count lines. + * @param text String of which to count lines. * @return The number of lines in <var>string</var> */ - static int countLines(final CharSequence string) { - return count(LINE_COUNT_PATTERN, string) - 1; + static int countLines(final CharSequence text) { + return count(LINE_COUNT_PATTERN, text) - 1; } /** Returns a split array of lines for the specified string. - * @param string String to split. + * @param text String to split. * @return Array with lines. */ - static String[] getLines(final CharSequence string) { - return LINE_SPLIT_PATTERN.split(string); + static String[] getLines(final CharSequence text) { + return LINE_SPLIT_PATTERN.split(text); } /** Returns a String that is the input String with all comments removed. - * @param string String from which to remove the comments. + * @param text String from which to remove the comments. * @return Copy of <var>string</var> with all comments removed. */ - static CharSequence removeCComments(final CharSequence string) { - return COMMENT_PATTERN.matcher(string).replaceAll(""); + static CharSequence removeCComments(final CharSequence text) { + return COMMENT_PATTERN.matcher(text).replaceAll(""); } /** Returns the number of source lines of <var>string</var>. - * @param string String of which to count the number of source lines. + * @param text String of which to count the number of source lines. * @return The number of source lines of <var>string</var>. */ - static int countSourceLines(final CharSequence string) { - return count(SOURCE_LINE_PATTERN, string); + static int countSourceLines(final CharSequence text) { + return count(SOURCE_LINE_PATTERN, text); } /** Returns the number of matches of <var>pattern</var> on <var>string</var>. * @param pattern Pattern of which to count the matches. - * @param string String in which to count the matches. + * @param text String in which to count the matches. * @return The number of matches of <var>pattern</var> on <var>string</var>. */ - private static int count(final Pattern pattern, final CharSequence string) { + private static int count(final Pattern pattern, final CharSequence text) { int count = 0; - final Matcher m = pattern.matcher(string); - while (m.find()) { + final Matcher matcher = pattern.matcher(text); + while (matcher.find()) { count++; } return count; @@ -214,10 +214,11 @@ * @throws SAXException In case of XML issues when reading the default checkers. * @throws IOException In case of I/O problems when reading the default checkers. */ + @SuppressWarnings({"HardcodedFileSeparator"}) private void readDefaultCheckers() throws SAXException, IOException { - final Enumeration<URL> checkers = ArchStat.class.getClassLoader().getResources("net/sf/japi/archstat/Checker.xml"); - while (checkers.hasMoreElements()) { - final URL url = checkers.nextElement(); + final Enumeration<URL> checkerURLs = ArchStat.class.getClassLoader().getResources("net/sf/japi/archstat/Checker.xml"); + while (checkerURLs.hasMoreElements()) { + final URL url = checkerURLs.nextElement(); readCheckers(url); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-10-05 00:25:42
|
Revision: 1386 http://japi.svn.sourceforge.net/japi/?rev=1386&view=rev Author: christianhujer Date: 2009-10-05 00:25:32 +0000 (Mon, 05 Oct 2009) Log Message: ----------- Simplify code. Modified Paths: -------------- tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java 2009-10-05 00:25:14 UTC (rev 1385) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java 2009-10-05 00:25:32 UTC (rev 1386) @@ -66,7 +66,7 @@ /** {@inheritDoc} */ @SuppressWarnings({"InstanceMethodNamingConvention", "ProhibitedExceptionDeclared"}) public int run(@NotNull final List<String> args) throws Exception { - if (args.size() == 0) { + if (args.isEmpty()) { System.err.println("Error: No arguments given."); return 1; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-10-05 00:29:47
|
Revision: 1387 http://japi.svn.sourceforge.net/japi/?rev=1387&view=rev Author: christianhujer Date: 2009-10-05 00:29:39 +0000 (Mon, 05 Oct 2009) Log Message: ----------- Some code improvements. Modified Paths: -------------- tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java 2009-10-05 00:25:32 UTC (rev 1386) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java 2009-10-05 00:29:39 UTC (rev 1387) @@ -55,7 +55,7 @@ } /** The DocumentBuilder for parsing XML documents. */ - @NotNull private DocumentBuilder db; + @NotNull private DocumentBuilder documentBuilder; /** Whether or not to output memory statistics. */ private boolean memoryStatistics; @@ -74,7 +74,7 @@ System.err.println("Memory free (start): " + Runtime.getRuntime().freeMemory()); } final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - db = dbf.newDocumentBuilder(); + documentBuilder = dbf.newDocumentBuilder(); readDefaultCheckers(); final FileStat fileStat = new FileStat(checkers); for (final String arg : args) { @@ -137,7 +137,12 @@ */ public static CharSequence readFile(final File file) throws IOException { assert file.isFile(); - final StringBuilder sb = new StringBuilder((int) file.length()); + final long fileLength = file.length(); + if (fileLength > Integer.MAX_VALUE) { + throw new IOException("File too large" + file); + } + @SuppressWarnings({"NumericCastThatLosesPrecision"}) + final StringBuilder sb = new StringBuilder((int) fileLength); final BufferedReader in = new BufferedReader(new FileReader(file)); try { final char[] buf = new char[BUF_SIZE]; @@ -245,7 +250,7 @@ */ @Option({"c", "config"}) public void readCheckers(@NotNull final File file) throws SAXException, IOException { - readCheckers(db.parse(file)); + readCheckers(documentBuilder.parse(file)); } /** Reads additional configuration from the specified resource. @@ -254,7 +259,7 @@ * @throws SAXException in case of XML parsing errors. */ private void readCheckers(final URL url) throws SAXException, IOException { - readCheckers(db.parse(url.openStream())); + readCheckers(documentBuilder.parse(url.openStream())); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-10-05 01:22:57
|
Revision: 1383 http://japi.svn.sourceforge.net/japi/?rev=1383&view=rev Author: christianhujer Date: 2009-10-05 00:21:36 +0000 (Mon, 05 Oct 2009) Log Message: ----------- Remove duplicate object creation. Modified Paths: -------------- tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java Modified: tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java =================================================================== --- tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java 2009-10-05 00:20:45 UTC (rev 1382) +++ tools/archStat/trunk/src/prj/net/sf/japi/archstat/ArchStat.java 2009-10-05 00:21:36 UTC (rev 1383) @@ -234,7 +234,7 @@ // TODO:2009-02-18:christianhujer:Improve. throw new RuntimeException("Duplicate Checker " + check.getName()); } - checkers.add(new LineCheck((Element) nl.item(i))); + checkers.add(check); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |