From f29bad0e4ae929a2f13c9cfc94bad1979702dfbf Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Wed, 10 Aug 2016 23:02:18 +0200 Subject: [PATCH] sona java plugin: missing rule description --- .../l10n/java/rules/custom/GUJ0002_java.html | 23 ++++++++++++++++++++++ .../l10n/java/rules/custom/GUJ0002_java.json | 13 ++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 Sonar/Plugins/sonar-custom-java-plugin/src/main/resources/de/example/l10n/java/rules/custom/GUJ0002_java.html create mode 100644 Sonar/Plugins/sonar-custom-java-plugin/src/main/resources/de/example/l10n/java/rules/custom/GUJ0002_java.json 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" +} -- 2.1.4