From d48b634431fc36001bc01813448cbaaf20392a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20B=C3=BCnger?= Date: Sat, 25 Jan 2025 20:12:44 +0100 Subject: [PATCH] Update rule description Format files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > Developer's Certificate of Origin 1.1 > > By making a contribution to this project, I certify that: > > (a) The contribution was created in whole or in part by me and I > have the right to submit it under the open source license > indicated in the file; or > > (b) The contribution is based upon previous work that, to the best > of my knowledge, is covered under an appropriate open source > license and I have the right under that license to submit that > work with modifications, whether created in whole or in part > by me, under the same open source license (unless I am > permitted to submit under a different license), as indicated > in the file; or > > (c) The contribution was provided directly to me by some other > person who certified (a), (b) or (c) and I have not modified > it. > > (d) I understand and agree that this project and the contribution > are public and that a record of the contribution (including all > personal information I submit with it, including my sign-off) is > maintained indefinitely and may be redistributed consistent with > this project or the open source license(s) involved. Signed-off-by: Matthias Bünger --- .../archunit/library/GeneralCodingRules.java | 18 +++++----- .../library/GeneralCodingRulesTest.java | 34 +++++++++---------- .../timeapi/incorrect/UsesJavaSqlDate.java | 8 ++--- .../timeapi/incorrect/UsesJavaSqlTime.java | 8 ++--- .../incorrect/UsesJavaSqlTimestamp.java | 8 ++--- .../incorrect/UsesJavaUtilCalender.java | 8 ++--- .../timeapi/incorrect/UsesJavaUtilDate.java | 8 ++--- 7 files changed, 45 insertions(+), 47 deletions(-) diff --git a/archunit/src/main/java/com/tngtech/archunit/library/GeneralCodingRules.java b/archunit/src/main/java/com/tngtech/archunit/library/GeneralCodingRules.java index 4666bc71f..2c4280ec4 100644 --- a/archunit/src/main/java/com/tngtech/archunit/library/GeneralCodingRules.java +++ b/archunit/src/main/java/com/tngtech/archunit/library/GeneralCodingRules.java @@ -515,12 +515,12 @@ public void check(JavaClass implementationClass, ConditionEvents events) { */ @PublicAPI(usage = ACCESS) public static final ArchRule OLD_DATE_AND_TIME_CLASSES_SHOULD_NOT_BE_USED = - noClasses() - .should().dependOnClassesThat().haveFullyQualifiedName("java.sql.Date") - .orShould().dependOnClassesThat().haveFullyQualifiedName("java.sql.Time") - .orShould().dependOnClassesThat().haveFullyQualifiedName("java.sql.Timestamp") - .orShould().dependOnClassesThat().haveFullyQualifiedName("java.util.Calendar") - .orShould().dependOnClassesThat().haveFullyQualifiedName("java.util.Date") - .as("since Java 8 (and JavaEE 7 if JPA is needed) java.time-API should be used.") - .because("since Java 8 (and JavaEE 7 if JPA is needed) java.time-API should be used."); -} + noClasses() + .should().dependOnClassesThat().haveFullyQualifiedName("java.sql.Date") + .orShould().dependOnClassesThat().haveFullyQualifiedName("java.sql.Time") + .orShould().dependOnClassesThat().haveFullyQualifiedName("java.sql.Timestamp") + .orShould().dependOnClassesThat().haveFullyQualifiedName("java.util.Calendar") + .orShould().dependOnClassesThat().haveFullyQualifiedName("java.util.Date") + .as("java.time API should be used") + .because("legacy date/time APIs have been replaced since Java 8 (JSR 310)"); +} \ No newline at end of file diff --git a/archunit/src/test/java/com/tngtech/archunit/library/GeneralCodingRulesTest.java b/archunit/src/test/java/com/tngtech/archunit/library/GeneralCodingRulesTest.java index bc756adfa..16faf91ae 100644 --- a/archunit/src/test/java/com/tngtech/archunit/library/GeneralCodingRulesTest.java +++ b/archunit/src/test/java/com/tngtech/archunit/library/GeneralCodingRulesTest.java @@ -187,45 +187,43 @@ void origin() { private @interface DeprecatedAnnotation { } - - @Test public void OLD_DATE_AND_TIME_CLASSES_SHOULD_NOT_BE_USED_should_fail_when_class_uses_java_util_date() { assertThatRule(OLD_DATE_AND_TIME_CLASSES_SHOULD_NOT_BE_USED) - .hasDescriptionContaining("since Java 8 (and JavaEE 7 if JPA is needed) java.time-API should be used.") - .checking(new ClassFileImporter().importClasses(UsesJavaUtilDate.class)) - .hasViolationContaining("calls method