Thread: [Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/codeMetrics LineCounter.java,1.6,1.7
Brought to you by:
derrickoswald
From: <der...@us...> - 2003-09-10 03:39:06
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/codeMetrics In directory sc8-pr-cvs1:/tmp/cvs-serv24483/src/org/htmlparser/tests/codeMetrics Modified Files: LineCounter.java Log Message: Add style checking target to ant build script: ant checkstyle It uses a jar from http://checkstyle.sourceforge.net which is dropped in the lib directory. The rules are in the file htmlparser_checks.xml in the src directory. Added lexerapplications package with Tabby as the first app. It performs whitespace manipulation on source files to follow the style rules. This reduced the number of style violations to roughly 14,000. There are a few issues with the style checker that need to be resolved before it should be taken too seriously. For example: It thinks all method arguments should be final, even if they are modified by the code (which the compiler frowns on). It complains about long lines, even when there is no possibility of wrapping the line, i.e. a URL in a comment that's more than 80 characters long. It considers all naked integers as 'magic numbers', even when they are obvious, i.e. the 4 corners of a box. It complains about whitespace following braces, even in array initializers, i.e. X[][] = { {a, b} { } } But it points out some really interesting things, even if you don't agree with the style guidelines, so it's worth a look. Index: LineCounter.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/codeMetrics/LineCounter.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** LineCounter.java 8 Sep 2003 02:26:30 -0000 1.6 --- LineCounter.java 10 Sep 2003 03:38:23 -0000 1.7 *************** *** 11,15 **** // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software --- 11,15 ---- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. ! // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software *************** *** 18,27 **** // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com --- 18,27 ---- // For any questions or suggestions, you can write to me at : // Email :so...@in... ! // ! // Postal Address : // Somik Raha // Extreme Programmer & Coach // Industrial Logic Corporation ! // 2583 Cedar Street, Berkeley, // CA 94708, USA // Website : http://www.industriallogic.com *************** *** 36,40 **** public class LineCounter { ! public int count(File file) { System.out.println("Handling "+file.getName()); --- 36,40 ---- public class LineCounter { ! public int count(File file) { System.out.println("Handling "+file.getName()); *************** *** 51,55 **** } ! /** * Counts code excluding comments and blank lines in the given file * @param file --- 51,55 ---- } ! /** * Counts code excluding comments and blank lines in the given file * @param file *************** *** 64,72 **** do { line = reader.readLine(); ! if (line!=null && ! line.indexOf("*")==-1 && ! line.indexOf("//")==-1 && line.length()>0 ! ) count++; } while (line!=null); --- 64,72 ---- do { line = reader.readLine(); ! if (line!=null && ! line.indexOf("*")==-1 && ! line.indexOf("//")==-1 && line.length()>0 ! ) count++; } while (line!=null); *************** *** 82,86 **** public boolean accept(File file) { if (file.getName().indexOf(".java")!=-1 || file.isDirectory()) { ! return true; } else { return false; --- 82,86 ---- public boolean accept(File file) { if (file.getName().indexOf(".java")!=-1 || file.isDirectory()) { ! return true; } else { return false; *************** *** 93,97 **** return count; } ! public static void main(String [] args) { LineCounter lc = new LineCounter(); --- 93,97 ---- return count; } ! public static void main(String [] args) { LineCounter lc = new LineCounter(); |