Ranides Atterwim преди 11 години
родител
ревизия
ea57dee142

+ 38 - 37
assira.rules.test/pom.xml

@@ -1,38 +1,39 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-	<modelVersion>4.0.0</modelVersion>
-	
-	<groupId>net.ranides</groupId>
-	<artifactId>assira.rules.test</artifactId>
-	<version>1.0-SNAPSHOT</version>
-	<packaging>jar</packaging>
-
-	<properties>
-		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-		<maven.compiler.source>1.7</maven.compiler.source>
-		<maven.compiler.target>1.7</maven.compiler.target>
-	</properties>
-	
-	<build>
-		<plugins>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-pmd-plugin</artifactId>
-				<version>3.4</version>
-				<configuration>
-					<rulesets>
-						<ruleset>rulesets/java/ranides.test.xml</ruleset>
-					</rulesets>
-				</configuration>
-				<dependencies>
-					<dependency>
-						<groupId>net.ranides</groupId>
-						<artifactId>assira.rules</artifactId>
-						<version>1.0-SNAPSHOT</version>
-					</dependency>
-				</dependencies>
-			</plugin>
-		</plugins>
-	</build>
-	
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+	
+    <groupId>net.ranides</groupId>
+    <artifactId>assira.rules.test</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>jar</packaging>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <netbeans.hint.license>WTFPL</netbeans.hint.license>
+        <maven.compiler.source>1.7</maven.compiler.source>
+        <maven.compiler.target>1.7</maven.compiler.target>
+    </properties>
+	
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-pmd-plugin</artifactId>
+                <version>5.3.3</version>
+                <configuration>
+                    <rulesets>
+                        <ruleset>rulesets/java/ranides.test.xml</ruleset>
+                    </rulesets>
+                </configuration>
+                <dependencies>
+                    <dependency>
+                        <groupId>net.ranides</groupId>
+                        <artifactId>assira.rules</artifactId>
+                        <version>1.0-SNAPSHOT</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
+        </plugins>
+    </build>
+	
 </project>

+ 56 - 25
assira.rules.test/src/main/java/net/ranides/assira/rules/test/ECB.java

@@ -1,25 +1,56 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package net.ranides.assira.rules.test;
-
-/**
- *
- * @author msieron
- */
-public class ECB {
-	
-	public static void main(String[] args) {
-		try {
-			if(true);
-			
-			if(true) { }
-			
-			System.out.println("Hello world");
-		} catch(RuntimeException ex) {
-		}
-	}
-	
-}
+/*
+ *  @author Ranides Atterwim <ranides@gmail.com>
+ *  @copyright Ranides Atterwim
+ *  @license WTFPL
+ *  @url http://ranides.net/projects/assira
+ */
+package net.ranides.assira.rules.test;
+
+public class ECB {
+    
+    int a1;
+    int a2;
+    int a3;
+    int a4;
+    int a5;
+    int a6;
+    int a7;
+    int a8;
+    int a9;
+    int a10;
+    int a11;
+    int a12;
+    int a13;
+    int a14;
+    int a15;
+    int a16;
+    int a17;
+    int a18;
+    int a19;
+    int a20;
+    int a21;
+    int a22;
+    int a23;
+    int a24;
+    int a25;
+    int a26;
+    int a27;
+    int a28;
+    int a29;
+    
+
+
+    public static void main(String[] args) {
+        try {
+            if (true);
+
+            if (true) {
+            }
+
+            System.out.println("Hello world");
+        } catch (RuntimeException ex) {
+
+        }
+    }
+
+}

+ 97 - 19
assira.rules/pom.xml

@@ -1,20 +1,98 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <groupId>net.ranides</groupId>
-    <artifactId>assira.rules</artifactId>
-    <version>1.0-SNAPSHOT</version>
-    <packaging>jar</packaging>
-    <dependencies>
-        <dependency>
-            <groupId>net.sourceforge.pmd</groupId>
-            <artifactId>pmd-java</artifactId>
-            <version>5.3.3</version>
-        </dependency>
-    </dependencies>
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <maven.compiler.source>1.7</maven.compiler.source>
-        <maven.compiler.target>1.7</maven.compiler.target>
-    </properties>
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    
+    <groupId>net.ranides</groupId>
+    <artifactId>assira.rules</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>jar</packaging>
+    
+    <url>http://ranides.net/projects/assira</url>
+    
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.compiler.source>1.7</maven.compiler.source>
+        <maven.compiler.target>1.7</maven.compiler.target>
+        <netbeans.hint.license>WTFPL</netbeans.hint.license>
+    </properties>
+    
+    <distributionManagement>
+        <repository>
+            <id>maven.ranides.net</id>
+            <name>maven.ranides.net</name>
+            <url>ftp://maven.ranides.net/</url>
+        </repository>
+    </distributionManagement>
+    
+    <repositories>
+        <repository>
+            <id>ranides.net</id>
+            <name>ranides.net</name>
+            <url>http://maven.ranides.net</url>
+        </repository>
+    </repositories>
+    
+    <build>
+        <extensions>
+            <extension>
+                <groupId>org.apache.maven.wagon</groupId>
+                <artifactId>wagon-ftp</artifactId>
+                <version>1.0</version>
+            </extension>
+        </extensions>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.3.2</version>
+                <configuration>
+                    <source>${maven.compiler.source}</source>
+                    <target>${maven.compiler.target}</target>
+                    <compilerArgument>-Xlint:unchecked</compilerArgument>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-source-plugin</artifactId>
+                <version>2.2.1</version>
+                <executions>
+                    <execution>
+                        <id>attach-sources</id>
+                        <goals>
+                            <goal>jar-no-fork</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <version>2.9</version>
+                <executions>
+                    <execution>
+                        <id>javadocs-site</id>
+                        <phase>site</phase>
+                        <goals>
+                            <goal>javadoc</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <links>
+                        <link>http://docs.oracle.com/javase/7/docs/api/</link>
+                    </links>
+                    <version>true</version>
+                    <show>public</show>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    
+    <dependencies>
+        <dependency>
+            <groupId>net.sourceforge.pmd</groupId>
+            <artifactId>pmd-java</artifactId>
+            <version>5.3.3</version>
+        </dependency>
+    </dependencies>
 </project>

+ 0 - 44
assira.rules/src/main/java/net/ranides/assira/rules/ClassSize.java

@@ -1,44 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package net.ranides.assira.rules;
-
-import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration;
-import net.sourceforge.pmd.lang.java.ast.JavaNode;
-import net.sourceforge.pmd.lang.java.rule.AbstractStatisticalJavaRule;
-import net.sourceforge.pmd.lang.java.rule.codesize.ExcessiveClassLengthRule;
-import net.sourceforge.pmd.lang.java.rule.design.ExcessiveLengthRule;
-import static net.sourceforge.pmd.lang.rule.stat.StatisticalRule.MINIMUM_DESCRIPTOR;
-import net.sourceforge.pmd.stat.DataPoint;
-
-/**
- *
- * @author msieron
- */
-public class ClassSize extends AbstractStatisticalJavaRule {
-	
-
-	private final Class<?> nodeClass;
-
-    public ClassSize() {
-		super();
-		this.nodeClass = ASTClassOrInterfaceDeclaration.class;
-		setProperty(MINIMUM_DESCRIPTOR, 1000d);
-    }
-
-    @Override
-    public Object visit(final JavaNode node, final Object data) {
-		if (nodeClass.isInstance(node)) {
-			final DataPoint point = new DataPoint();
-			point.setNode(node);
-			point.setScore(1.0 * (node.getEndLine() - node.getBeginLine()));
-			point.setMessage(getMessage());
-			addDataPoint(point);
-		}
-
-		return node.childrenAccept(this, data);
-    }
-	
-}

+ 41 - 0
assira.rules/src/main/java/net/ranides/assira/rules/TestECB.java

@@ -0,0 +1,41 @@
+/*
+ *  @author Ranides Atterwim <ranides@gmail.com>
+ *  @copyright Ranides Atterwim
+ *  @license WTFPL
+ *  @url http://ranides.net/projects/assira
+ */
+package net.ranides.assira.rules;
+
+import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration;
+import net.sourceforge.pmd.lang.java.ast.JavaNode;
+import net.sourceforge.pmd.lang.java.rule.AbstractStatisticalJavaRule;
+import net.sourceforge.pmd.lang.rule.properties.DoubleProperty;
+import static net.sourceforge.pmd.lang.rule.stat.StatisticalRule.MINIMUM_DESCRIPTOR;
+import net.sourceforge.pmd.stat.DataPoint;
+
+public class TestECB extends AbstractStatisticalJavaRule {
+    
+    // DoubleProperty MINIMUM_DESCRIPTOR = new DoubleProperty("minimum", "Minimum reporting threshold", 0d, 100d, null, 2.0f);
+
+    private final Class<?> nodeClass;
+
+    public TestECB() {
+        super();
+        this.nodeClass = ASTClassOrInterfaceDeclaration.class;
+        setProperty(MINIMUM_DESCRIPTOR, 20d);
+    }
+
+    @Override
+    public Object visit(final JavaNode node, final Object data) {
+        if (nodeClass.isInstance(node)) {
+            final DataPoint point = new DataPoint();
+            point.setNode(node);
+            point.setScore(1.0 * (node.getEndLine() - node.getBeginLine()));
+            point.setMessage(getMessage());
+            addDataPoint(point);
+        }
+
+        return node.childrenAccept(this, data);
+    }
+
+}

+ 45 - 29
assira.rules/src/main/resources/rulesets/java/ranides.test.xml

@@ -1,30 +1,46 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<ruleset name="net.ranides.assira.standard"
-    xmlns="http://pmd.sf.net/ruleset/1.0.0"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
-    xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
-
-    <description>TEST</description>
-
-    <!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
-	
-	<rule
-		name="TST-EC"
-		ref="rulesets/basic.xml/EmptyCatchBlock"
-		message="TEST: Must handle exceptions">
-		<priority>2</priority>
-	</rule>
-	
-	<!--
-	<rule
-		ref="rulesets/java/basic.xml/EmptyCatchBlock"
-		message="TEST: Must handle exceptions">
-		<priority>2</priority>
-	</rule>
-	
-	<rule ref="rulesets/basic.xml/EmptyIfStmt"/>
-	-->
-
+<?xml version="1.0" encoding="utf-8"?>
+
+<ruleset name="net.ranides.assira.standard"
+    xmlns="http://pmd.sf.net/ruleset/1.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
+    xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
+
+    <description>TEST</description>
+
+	<rule
+		name="TST-ECB"
+		ref="rulesets/basic.xml/EmptyCatchBlock"
+		message="TEST: Must handle exceptions">
+		<priority>2</priority>
+	</rule>
+        
+        <rule name="TST-RES"
+              language="java"
+              since="0.1"
+              message="TEST: Big"
+              class="net.ranides.assira.rules.TestECB"
+              externalInfoUrl="${pmd.website.baseurl}/rules/java/empty.html#EmptyCatchBlock">
+            <description>
+                class size
+            </description>
+            <priority>3</priority>
+            <properties>
+                <property name="xpath">
+                    <value>
+                        20
+                    </value>
+                </property>
+                <property name="allowCommentedBlocks" type="Boolean" value="false"/>
+            </properties>
+            
+            <example>
+  <![CDATA[
+public void doSomething() {
+  
+}
+ ]]>
+            </example>
+        </rule>
+
 </ruleset>