File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -118,21 +118,30 @@ bool CweMap::loadCweMap(std::istream &str, const std::string &fileName) {
118118}
119119
120120bool CweMap::assignCwe (Defect &def) const {
121+ int &cweDst = def.cwe ;
122+
121123 // lookup by checker
122124 Private::TMapByChk::const_iterator rowIt = d->mapByChk .find (def.checker );
123125 if (d->mapByChk .end () == rowIt) {
126+ if (cweDst)
127+ // CWE already assigned, stay silent
128+ return true ;
129+
124130 if (!d->silent )
125131 std::cerr << " warning: CWE not found: checker = "
126132 << def.checker <<" \n " ;
127133 return false ;
128134 }
129135
130136 // lookup by event
131- int &cweDst = def.cwe ;
132137 const Private::TNumByEvent &row = rowIt->second ;
133138 const DefEvent &evt = def.events [def.keyEventIdx ];
134139 Private::TNumByEvent::const_iterator cweIt = row.find (evt.event );
135140 if (row.end () == cweIt) {
141+ if (cweDst)
142+ // CWE already assigned, stay silent
143+ return true ;
144+
136145 if (!d->silent )
137146 std::cerr << " warning: CWE not found: checker = " << def.checker
138147 << " , event = " << evt.event << " \n " ;
@@ -148,7 +157,7 @@ bool CweMap::assignCwe(Defect &def) const {
148157
149158 const int cweSrc = cweIt->second ;
150159 if (cweSrc == cweDst)
151- // already assigned
160+ // already assigned to the requested value
152161 return true ;
153162
154163 if (cweDst && !d->silent )
You can’t perform that action at this time.
0 commit comments