Skip to content

Commit 808dd5f

Browse files
committed
A3-1-5: change definition of trivial length
of trivial member function to 10LOC
1 parent 5ce788f commit 808dd5f

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `A3-1-5` - `NonTrivialNonTemplateFunctionDefinedInsideClassDefinition.ql`, `TrivialOrTemplateFunctionDefinedOutsideClassDefinition.ql`:
2+
- Fixes #611. Relax definition of trivial length of trivial member function to 10 LOC.
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
| test.cpp:12:7:12:13 | trivial | Non-Trivial or non-template function trivial is defined in the class body of $@. | test.cpp:2:7:2:7 | A | A |
21
| test.cpp:26:7:26:9 | gcd | Non-Trivial or non-template function gcd is defined in the class body of $@. | test.cpp:2:7:2:7 | A | A |

cpp/autosar/test/rules/A3-1-5/test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class A {
99

1010
int getABar() { return 9; }
1111

12-
int trivial() { // NON_COMPLIANT
12+
int not_trivial() { // COMPLIANT - with threshold of 10 loc
1313
;
1414
;
1515
;

cpp/common/src/codingstandards/cpp/Class.qll

+2-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ class IntrospectedMemberFunction extends MemberFunction {
149149
}
150150

151151
predicate hasTrivialLength() {
152-
this.getBlock().getNumStmt() <= 3 and
152+
this.getBlock().getLastStmt().getLocation().getStartLine() -
153+
this.getBlock().getStmt(0).getLocation().getStartLine() <= 10 and
153154
not exists(this.getBlock().getStmt(_).getChildStmt())
154155
}
155156

0 commit comments

Comments
 (0)