From 793aed998e45324d04872f09ad9c04a2b24321be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=87=B4=E4=BF=A1?= Date: Sun, 16 Mar 2025 16:43:43 +0800 Subject: [PATCH] test pmd --- src/main/java/pmd/Sample.java | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/main/java/pmd/Sample.java diff --git a/src/main/java/pmd/Sample.java b/src/main/java/pmd/Sample.java new file mode 100644 index 00000000..7ca1dafa --- /dev/null +++ b/src/main/java/pmd/Sample.java @@ -0,0 +1,38 @@ +public class Sample { + private int someValue; + + public Sample() { + // 空的构造函数 + } + + public void unusedMethod() { + // 这个方法没有被调用 + System.out.println("This method is never used."); + } + + public void doSomething() { + int value = 5; // 未被使用的局部变量 + someValue = 10; + someValue = 20; // 覆盖了之前的赋值 + } + + public void longMethod() { + // 过长的方法,应该被分解 + System.out.println("This is a very long method, and it should be split into smaller methods."); + System.out.println("It does too many things at once."); + System.out.println("It's hard to read and maintain."); + System.out.println("It's also not good for testing."); + } + + public double divide(int a, int b) { + // 没有检查除数是否为零 + return a / b; + } + + public String toString() { + // 忽略了父类的 toString 方法 + return "Sample{" + + "someValue=" + someValue + + '}'; + } +} \ No newline at end of file