I am having an issue with Sonar Cloud and SonarQube, and I was hoping someone might be able to help me troubleshoot it.
Here is a brief description of the problem:
I am trying to create a new document in Mongoose, but SonarQube is giving me the error “Replace User with a constructor function.” I have already defined the User object as a constructor function using the mongoose.model() function, but the error persists.
Here is the relevant code snippet:
const testData = {
...userData,
profileImage: { picture }
};
const testSonarQube = new User(testData);
Here is some additional information that might be helpful in troubleshooting the issue:
Sonar Cloud Scan Version: sonarcloud-scan:1.4.0
Sonar Cloud Quality Gate Version:0.1.6
Programming language: js
Error message: “Replace User with a constructor function.”
I would really appreciate any help or advice that anyone might be able to offer. Thank you in advance for your assistance!
CodePudding user response:
SonarQube Community member mentioned "Indeed mongoose.model is not a case the JS engine considers for that rule." and they created a ticket to implement it https://github.com/SonarSource/SonarJS/issues/3646