Merge remote-tracking branch 'origin/master'

master
wuhaoyang 10 months ago
commit 576eec8ba0
  1. 2
      sonar-keyware-plugins-cxx/src/main/java/com/keyware/sonar/cxx/rules/checkers/NumericalCopyChecker.java
  2. 2
      sonar-keyware-plugins-cxx/src/test/resources/com/keyware/sonar/cxx/rules/checkers/NumericalCopyChecker.cc

@ -42,7 +42,7 @@ public class NumericalCopyChecker extends SquidCheck<Grammar> {//当私有数组
for (AstNode ast : descendan) { for (AstNode ast : descendan) {
List<AstNode> descendants = ast.getDescendants(CxxGrammarImpl.expression); List<AstNode> descendants = ast.getDescendants(CxxGrammarImpl.expression);
for (AstNode des : descendants) { for (AstNode des : descendants) {
if ("return".equals(des.getParent().getTokenValue())){ if ("return".equals(des.getParent().getTokenValue()) || des.getTokenValue().contains("0")){
if (lists.contains(des.getTokenValue())) { if (lists.contains(des.getTokenValue())) {
getContext().createLineViolation(this, "应返回该私有数值的副本", des); getContext().createLineViolation(this, "应返回该私有数值的副本", des);
} }

@ -15,7 +15,7 @@ public:
return privateArray; // error return privateArray; // error
} }
// // 返回的是私有数组的指针 // 返回的是私有数组的指针
int* getPrivateArrayPtr() { int* getPrivateArrayPtr() {
return privateArray.data(); // error return privateArray.data(); // error
} }

Loading…
Cancel
Save