forked from SonarOpenCommunity/sonar-cxx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete support of alternative operators
* complete list of `overloadable-operator`s (yes, alternative operators can be used for operator overloading too) * complete `equalityExpression`, `andExpression`, `exclusiveOrExpression`, `inclusiveOrExpression`, `logicalAndExpression`, `logicalOrExpression` fixes SonarOpenCommunity#1569 * add missing support of alternative operators to the complexity metrics (see # SonarOpenCommunity#1494)
- Loading branch information
1 parent
bb69606
commit 6045ee1
Showing
10 changed files
with
85 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
cxx-squid/src/test/resources/metrics/complexity_alternative.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// same as complexity.cc but with alternative logical operators 'and' and 'or' | ||
# include <iostream> | ||
# include <exception> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
if(true) | ||
; | ||
|
||
if(true and false) | ||
; | ||
|
||
if(true or false) | ||
; | ||
|
||
for(;;); | ||
|
||
while(true); | ||
|
||
try{ | ||
} | ||
catch(std::exception e) {} | ||
catch(...) {} | ||
|
||
true ? 1 : 0; | ||
|
||
int i = 3; | ||
switch(i){ | ||
case 2: break; | ||
case 3: break; | ||
default: break; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
cxx-squid/src/test/resources/visitors/binary_logical_mixed_alternative.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// same as binary_logical_mixed.cc but with alternative logical operators 'and' and 'or' | ||
bool logical_mixed(bool a, bool b, bool c, bool d, bool e, bool f) | ||
{ | ||
if (a // +1 for `if` | ||
and b and c // +1 | ||
or d or e // +1 | ||
and f) // +1 | ||
{ | ||
return true; | ||
} | ||
return false; | ||
} |