Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SonarQube - Rule Fields in a "Serializable" class should either be transient or serializable

It might look like duplicate question, but i have posted the code sample suggested by sonar rule Compliant one. When evaluating the below highlighted code with SonarQube it results in squid:S1948 rule violation.

enter image description here

Result,

enter image description here

Still its a mystery that why its showing violation for compliant code, plz clarify.

UPDATE

transient or serializable issue not resolved even with sonar.java.binaries

Sonar Scan is success but throws class loader warn:

08:26:44.984 INFO - Java bytecode scan... 08:26:44.992 WARN - Class 'dummyserial/Address' is not accessible through the C lassLoader. 08:26:44.993 WARN - Class 'dummyserial/Person' is not accessible through the Cl assLoader. 08:26:44.993 WARN - Class 'dummyserial/Address' is not accessible through the C lassLoader. 08:26:44.994 WARN - Class 'dummyserial/Person' is not accessible through the Cl assLoader. 08:26:44.994 WARN - Class 'dummyserial/Address' is not accessible through the C lassLoader. 08:26:44.997 WARN - Class 'dummyserial/Person' is not accessible through the Cl assLoader. 08:26:44.998 INFO - Java bytecode scan done: 14 ms

like image 525
Jeevanantham Avatar asked Sep 18 '15 11:09

Jeevanantham


1 Answers

As previously responded, you should fill the sonar.java.binaries property in order to allow bytecode analysis and symbol resolution. Having this property filled, the analysis would not raise any issue on that case.

Now, it is indeed annoying that we raise an issue when we can not resolve the symbol type of a field. I created the following ticket to handle the issue: SONARJAVA-1266

like image 126
Wohops Avatar answered Sep 28 '22 04:09

Wohops