I am using SimpleDataTables JS Library and their minimal suggested implementation:
const dataTable = new DataTable("#myTable");
In SC this throws me an Remove this useless assignment to variable "dataTable". and an Remove the declaration of the unused 'dataTable' variable.
If I remove the assignement SC tells me to Either remove this useless object instantiation of "DataTable" or use it.
In SC, the FIRST approach is considered a code-smell, the second approach is considered a bug. So I prefer to use first approach, but still SC is not fully happy.
With my rather limited knowledge of JS, I would say simply doing new DataTable("#myTable"); is the right approach.
Of course, strictly speaking, that library should probably not have sideffects when instantiating the object but rather provide a method (like DataTable->run()), but that is not the case.
Is there some other approach to do it “correctly” other than marking this as a false alarm?