DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

CodeReview of JDK Source Code


jdk1.6.0_35/src.zip, only java package is reviewd(full package review caused a OutofMemory on java heap size).

Checkstyle Review

tyRules.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> 
<module name="Checker"> 
    <property name="severity" value="warning"/> 
    <module name="TreeWalker"> 
        <metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/> 
        <property name="fileExtensions" value="java"/> 
        <module name="MethodLength"> 
            <property name="max" value="200"/> 
        </module> 
        <module name="NestedIfDepth"> 
            <property name="max" value="5"/> 
        </module> 
        <module name="CyclomaticComplexity"/> 
            <module name="ParameterNumber"> 
            <property name="max" value="6"/> 
        </module> 
    </module> 
    <module name="StrictDuplicateCode"> 
        <property name="fileExtensions" value="java"/> 
        <property name="min" value="75"/> 
    </module> 
    <module name="FileLength"> 
        <property name="fileExtensions" value="java"/> 
        <property name="max" value="1000"/> 
    </module> 
</module>

Run code review

java -jar checkstyle-5.6-all.jar -c tyRules.xml -r /home/chad/tmp/jdksrc -o result.txt

Get Review Result

grep "Method length is" result.txt|wc -l
grep "Nested if-else depth is" result.txt|wc -l
grep "More than 6 parameters" result.txt|wc -l
grep "max allowed is 1,000" result.txt|wc -l
grep "Found duplicate of" result.txt|wc -l
grep "Cyclomatic Complexity is" result.txt|wc -l

Sonar Review

sonar-project.properties:

sonar.projectKey=jdk.sonar.analysis 
sonar.projectName=JDK 
sonar.projectVersion=1.6 
sonar.sources=jdksrc 
sonar.login=liuyan 
sonar.password=liuyan 
sonar.language=java 
sonar.profile=TongYong 
sonar.skipDesign=true 
sonar.dynamicAnalysis=false

Run code review

/opt/sonar-server/runner/sonar-runner-2.2/bin/sonar-runner

The profile TongYong is imported from above tyRules.xml.

Result

From Sonar

Lines of code: 202,505 (NBNC, not blank not comment code lines);

559,577 lines (total lines = NBNC + blank + comment);

Above can be verified by cloc.

2172 Classes, 21,275 methods, 675 method cyclomatic complexity are greater than 10,

Cyclomatic Complxity

GCP: 298/6276 = 4.75%

JDK: 674/21275 = 3.17%

Duplicate Lines

GCP:

JDK: 825/



Published

May 21, 2013

Last Updated

May 21, 2013

Category

Tech

Tags

  • checkstyle 4
  • sonar 17

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor