From 7533c8eaa61ffe668ce05fe55f72a3e06e9b6bcc Mon Sep 17 00:00:00 2001 From: "erwan.serandour" Date: Wed, 11 Dec 2024 15:25:51 +0100 Subject: [PATCH 1/4] Modify rule S1075, add new exceptions to the rule --- rules/S1075/java/rule.adoc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rules/S1075/java/rule.adoc b/rules/S1075/java/rule.adoc index 35c761c2566..76fc80f067d 100644 --- a/rules/S1075/java/rule.adoc +++ b/rules/S1075/java/rule.adoc @@ -1,5 +1,13 @@ include::../description.adoc[] +=== Exceptions + +This rules doesn't raise an issue when: + +* A relative URI is declared in a static final constant and the path contains at most two parts. +* An URI is declared in a static final constant and the constant is used in an annotation. +* An URI is declared in a variable annotated with any annotations. + == How to fix it === Code examples From e922c416ee4b1cad6caaf16d03ccc091574651ae Mon Sep 17 00:00:00 2001 From: "erwan.serandour" Date: Wed, 11 Dec 2024 15:30:41 +0100 Subject: [PATCH 2/4] fix grammar --- rules/S1075/java/rule.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rules/S1075/java/rule.adoc b/rules/S1075/java/rule.adoc index 76fc80f067d..0055647e588 100644 --- a/rules/S1075/java/rule.adoc +++ b/rules/S1075/java/rule.adoc @@ -4,9 +4,9 @@ include::../description.adoc[] This rules doesn't raise an issue when: -* A relative URI is declared in a static final constant and the path contains at most two parts. +* A relative URI is declared in a static final constant and the URI contains at most two parts. * An URI is declared in a static final constant and the constant is used in an annotation. -* An URI is declared in a variable annotated with any annotations. +* An URI is declared in a variable annotated with an annotation. == How to fix it From ce92faa1d9f030254678c1dd124cc2081aebed47 Mon Sep 17 00:00:00 2001 From: "erwan.serandour" Date: Fri, 13 Dec 2024 15:45:30 +0100 Subject: [PATCH 3/4] update after code review --- rules/S1075/java/rule.adoc | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/rules/S1075/java/rule.adoc b/rules/S1075/java/rule.adoc index 0055647e588..6106b78a87c 100644 --- a/rules/S1075/java/rule.adoc +++ b/rules/S1075/java/rule.adoc @@ -2,11 +2,11 @@ include::../description.adoc[] === Exceptions -This rules doesn't raise an issue when: +This rule does not raise an issue when: -* A relative URI is declared in a static final constant and the URI contains at most two parts. -* An URI is declared in a static final constant and the constant is used in an annotation. -* An URI is declared in a variable annotated with an annotation. +* A constant path is relative and contains at most two parts. +* A constant path is used in an annotation +* A path is annotated == How to fix it @@ -17,6 +17,8 @@ This rules doesn't raise an issue when: [source,java,diff-id=1,diff-type=noncompliant] ---- public class Foo { + public static final String FRIENDS_ENDPOINT = "/user/friends"; // Compliant path is relative and has only two parts + public Collection listUsers() { File userList = new File("/home/mylogin/Dev/users.txt"); // Noncompliant Collection users = parse(userList); @@ -46,6 +48,24 @@ public class Foo { } ---- +==== Exceptions + +[source,java] +---- +public class Foo { + public static final String FRIENDS_ENDPOINT = "/user/friends"; // Compliant path is relative and has only two parts + + public static final String ACCOUNT = "/account/group/list.html"; // Compliant path is used in an annotation + + @Value("${base.url}" + ACCOUNT) + private String groupUrl; + + @MyAnnotation() + String path = "/default/url/for/site"; // Compliant path is annotated + +} +---- + ifdef::env-github,rspecator-view[] ''' From 91f6b37ea412c55249d98261b0e144e2b9585685 Mon Sep 17 00:00:00 2001 From: "erwan.serandour" Date: Mon, 16 Dec 2024 13:45:52 +0100 Subject: [PATCH 4/4] merge exceptions sections with compliant solutions --- rules/S1075/java/rule.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/S1075/java/rule.adoc b/rules/S1075/java/rule.adoc index 6106b78a87c..8a6b7dd22cc 100644 --- a/rules/S1075/java/rule.adoc +++ b/rules/S1075/java/rule.adoc @@ -48,7 +48,7 @@ public class Foo { } ---- -==== Exceptions +Exceptions examples: [source,java] ----