From: Gustavo Martin Morcuende Date: Wed, 10 Aug 2016 21:02:18 +0000 (+0200) Subject: sona java plugin: missing rule description X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=f29bad0e4ae929a2f13c9cfc94bad1979702dfbf;p=JavaForFun sona java plugin: missing rule description --- diff --git a/Sonar/Plugins/sonar-custom-java-plugin/src/main/resources/de/example/l10n/java/rules/custom/GUJ0002_java.html b/Sonar/Plugins/sonar-custom-java-plugin/src/main/resources/de/example/l10n/java/rules/custom/GUJ0002_java.html new file mode 100644 index 0000000..6aa05e1 --- /dev/null +++ b/Sonar/Plugins/sonar-custom-java-plugin/src/main/resources/de/example/l10n/java/rules/custom/GUJ0002_java.html @@ -0,0 +1,23 @@ +

All threads are sharing the Spring Service instances and by extension instance fields. All Spring Service fields should then be either +static and/or final, or simply removed.

+

Noncompliant Code Example

+
+@Service("myService")
+public class MyServiceImpl implements MyService {
+  private String userName;  //As this field is shared by all users, it's obvious that this piece of information should be managed differently
+  ...
+}
+
+

or

+
+@Named("myService")
+public class MyServiceImpl extends MyService {
+  private String userName;  //Same reason
+  ...
+}
+
+

See

+ + diff --git a/Sonar/Plugins/sonar-custom-java-plugin/src/main/resources/de/example/l10n/java/rules/custom/GUJ0002_java.json b/Sonar/Plugins/sonar-custom-java-plugin/src/main/resources/de/example/l10n/java/rules/custom/GUJ0002_java.json new file mode 100644 index 0000000..e0fdd18 --- /dev/null +++ b/Sonar/Plugins/sonar-custom-java-plugin/src/main/resources/de/example/l10n/java/rules/custom/GUJ0002_java.json @@ -0,0 +1,13 @@ +{ + "title": "Spring services should not have mutable instance fields", + "status": "ready", + "remediation": { + "func": "Constant\/Issue", + "constantCost": "30min" + }, + "tags": [ + "multi-threading", + "bug" + ], + "defaultSeverity": "Major" +}