From e8a9b608621fb8b18037dec42075e42e0761d543 Mon Sep 17 00:00:00 2001 From: tristanzhou Date: Sun, 8 Jan 2017 23:21:03 +1300 Subject: [PATCH] Introduction to pmd (#972) * initial check for introduction to pmd * change name to static-analysis * move it to static-analysis --- static-analysis/pom.xml | 30 +++++++++++++++ .../src/main/java/com/baeldung/pmd/Cnt.java | 12 ++++++ .../src/main/resources/customruleset.xml | 37 +++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 static-analysis/pom.xml create mode 100644 static-analysis/src/main/java/com/baeldung/pmd/Cnt.java create mode 100644 static-analysis/src/main/resources/customruleset.xml diff --git a/static-analysis/pom.xml b/static-analysis/pom.xml new file mode 100644 index 0000000000..737816ec10 --- /dev/null +++ b/static-analysis/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + com.baeldung + static-analysis + 1.0-SNAPSHOT + + + + + + + + org.apache.maven.plugins + maven-pmd-plugin + 3.7 + + + rulesets/java/braces.xml + rulesets/java/naming.xml + + + + + + + \ No newline at end of file diff --git a/static-analysis/src/main/java/com/baeldung/pmd/Cnt.java b/static-analysis/src/main/java/com/baeldung/pmd/Cnt.java new file mode 100644 index 0000000000..4953646c9d --- /dev/null +++ b/static-analysis/src/main/java/com/baeldung/pmd/Cnt.java @@ -0,0 +1,12 @@ +package com.baeldung.pmd; + +public class Cnt { + + public int d(int a, int b) { + if (b == 0) + return Integer.MAX_VALUE; + else + return a / b; + } + +} diff --git a/static-analysis/src/main/resources/customruleset.xml b/static-analysis/src/main/resources/customruleset.xml new file mode 100644 index 0000000000..e0a009dd4a --- /dev/null +++ b/static-analysis/src/main/resources/customruleset.xml @@ -0,0 +1,37 @@ + + + + + This ruleset checks my code for bad stuff + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + + \ No newline at end of file