Skip to content

Commit 1fd5675

Browse files
authored
Merge pull request #633 from knewbury01/knewbury01/fix-611
A3-1-5: change definition of trivial length
2 parents ff36b36 + e068ecd commit 1fd5675

File tree

5 files changed

+25
-11
lines changed

5 files changed

+25
-11
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 |
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
| test.cpp:58:5:58:11 | getB | The trivial member function getB is not defined in the class body of $@. | test.cpp:2:7:2:7 | A | A |
2-
| test.cpp:60:25:60:28 | d | The template member function d is not defined in the class body of $@. | test.cpp:2:7:2:7 | A | A |
3-
| test.cpp:62:5:62:8 | b | The trivial member function b is not defined in the class body of $@. | test.cpp:2:7:2:7 | A | A |
4-
| test.cpp:81:34:81:57 | complexCalculation | The template member function complexCalculation is not defined in the class body of $@. | test.cpp:64:29:64:29 | B<C> | B<C> |
5-
| test.cpp:97:47:97:53 | d | The template member function d is not defined in the class body of $@. | test.cpp:64:29:64:29 | B<C> | B<C> |
6-
| test.cpp:101:27:101:33 | b | The template member function b is not defined in the class body of $@. | test.cpp:64:29:64:29 | B<C> | B<C> |
7-
| test.cpp:106:27:106:36 | getB | The template member function getB is not defined in the class body of $@. | test.cpp:64:29:64:29 | B<C> | B<C> |
1+
| test.cpp:65:5:65:11 | getB | The trivial member function getB is not defined in the class body of $@. | test.cpp:2:7:2:7 | A | A |
2+
| test.cpp:67:25:67:28 | d | The template member function d is not defined in the class body of $@. | test.cpp:2:7:2:7 | A | A |
3+
| test.cpp:69:5:69:8 | b | The trivial member function b is not defined in the class body of $@. | test.cpp:2:7:2:7 | A | A |
4+
| test.cpp:88:34:88:57 | complexCalculation | The template member function complexCalculation is not defined in the class body of $@. | test.cpp:71:29:71:29 | B<C> | B<C> |
5+
| test.cpp:104:47:104:53 | d | The template member function d is not defined in the class body of $@. | test.cpp:71:29:71:29 | B<C> | B<C> |
6+
| test.cpp:108:27:108:33 | b | The template member function b is not defined in the class body of $@. | test.cpp:71:29:71:29 | B<C> | B<C> |
7+
| test.cpp:113:27:113:36 | getB | The template member function getB is not defined in the class body of $@. | test.cpp:71:29:71:29 | B<C> | B<C> |

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

+15-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
;
@@ -28,6 +28,13 @@ class A {
2828
return a;
2929
int result = gcd(b, (a % b));
3030
;
31+
;
32+
;
33+
;
34+
;
35+
;
36+
;
37+
;
3138
return result;
3239
}
3340

@@ -131,5 +138,12 @@ int FooBar::f1(int a, int b) { // COMPLIANT not a trivial function
131138
return a;
132139
int result = FooBar::f1(b, (a % b));
133140
;
141+
;
142+
;
143+
;
144+
;
145+
;
146+
;
147+
;
134148
}
135149
}

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

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

151151
predicate hasTrivialLength() {
152-
this.getBlock().getNumStmt() <= 3 and
153-
not exists(this.getBlock().getStmt(_).getChildStmt())
152+
this.getBlock().getLocation().getEndLine() - this.getBlock().getLocation().getStartLine() <= 10
154153
}
155154

156155
predicate isSetter() {

0 commit comments

Comments
 (0)