Skip to content

Commit 44f288c

Browse files
Fix formatting and expectations files
1 parent 1909172 commit 44f288c

File tree

7 files changed

+172
-158
lines changed

7 files changed

+172
-158
lines changed
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
| test.cpp:15:26:15:44 | derivation | Class 'VirtualDerived1' inherits virtually from 'Base'. |
2-
| test.cpp:21:26:21:44 | derivation | Class 'VirtualDerived2' inherits virtually from 'Base'. |
3-
| test.cpp:25:26:25:44 | derivation | Class 'VirtualMultiple' inherits virtually from 'Base'. |
4-
| test.cpp:25:47:25:72 | derivation | Class 'VirtualMultiple' inherits virtually from 'AnotherBase'. |
5-
| test.cpp:30:32:30:51 | derivation | Class 'PrivateVirtualDerived' inherits virtually from 'Base'. |
6-
| test.cpp:34:34:34:55 | derivation | Class 'ProtectedVirtualDerived' inherits virtually from 'Base'. |
7-
| test.cpp:62:22:62:40 | derivation | Class 'DiamondLeft' inherits virtually from 'Base'. |
8-
| test.cpp:66:23:66:41 | derivation | Class 'DiamondRight' inherits virtually from 'Base'. |
9-
| test.cpp:78:21:78:39 | derivation | Class 'Level1' inherits virtually from 'Base'. |
10-
| test.cpp:82:21:82:41 | derivation | Class 'Level2' inherits virtually from 'Level1'. |
2+
| test.cpp:19:26:19:44 | derivation | Class 'VirtualDerived2' inherits virtually from 'Base'. |
3+
| test.cpp:23:26:23:44 | derivation | Class 'VirtualMultiple' inherits virtually from 'Base'. |
4+
| test.cpp:24:26:24:51 | derivation | Class 'VirtualMultiple' inherits virtually from 'AnotherBase'. |
5+
| test.cpp:29:32:29:51 | derivation | Class 'PrivateVirtualDerived' inherits virtually from 'Base'. |
6+
| test.cpp:33:34:33:55 | derivation | Class 'ProtectedVirtualDerived' inherits virtually from 'Base'. |
7+
| test.cpp:59:22:59:40 | derivation | Class 'DiamondLeft' inherits virtually from 'Base'. |
8+
| test.cpp:63:23:63:41 | derivation | Class 'DiamondRight' inherits virtually from 'Base'. |
9+
| test.cpp:75:19:75:37 | derivation | Class 'Level1' inherits virtually from 'Base'. |
10+
| test.cpp:79:19:79:39 | derivation | Class 'Level2' inherits virtually from 'Level1'. |

cpp/misra/test/rules/RULE-13-1-1/test.cpp

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,84 +2,81 @@
22

33
// Base class for testing virtual inheritance
44
struct Base {
5-
virtual std::int32_t getValue() { return 1; }
6-
std::int32_t m1;
5+
virtual std::int32_t getValue() { return 1; }
6+
std::int32_t m1;
77
};
88

99
// Another base class
1010
struct AnotherBase {
11-
std::int32_t m2;
11+
std::int32_t m2;
1212
};
1313

1414
// Test cases for virtual inheritance (non-compliant)
1515
struct VirtualDerived1 : public virtual Base { // NON_COMPLIANT
16-
std::int32_t getDoubleValue() {
17-
return getValue() * 2;
18-
}
16+
std::int32_t getDoubleValue() { return getValue() * 2; }
1917
};
2018

2119
struct VirtualDerived2 : public virtual Base { // NON_COMPLIANT
22-
std::int32_t getValue() override { return 3; }
20+
std::int32_t getValue() override { return 3; }
2321
};
2422

25-
struct VirtualMultiple : public virtual Base, public virtual AnotherBase { // NON_COMPLIANT
26-
std::int32_t m3;
23+
struct VirtualMultiple : public virtual Base,
24+
public virtual AnotherBase { // NON_COMPLIANT
25+
std::int32_t m3;
2726
};
2827

2928
// Test cases for private virtual inheritance (non-compliant)
3029
struct PrivateVirtualDerived : private virtual Base { // NON_COMPLIANT
31-
std::int32_t m4;
30+
std::int32_t m4;
3231
};
3332

3433
struct ProtectedVirtualDerived : protected virtual Base { // NON_COMPLIANT
35-
std::int32_t m5;
34+
std::int32_t m5;
3635
};
3736

3837
// Test cases for regular inheritance (compliant)
3938
struct RegularDerived1 : public Base { // COMPLIANT
40-
std::int32_t getTripleValue() {
41-
return getValue() * 3;
42-
}
39+
std::int32_t getTripleValue() { return getValue() * 3; }
4340
};
4441

4542
struct RegularDerived2 : public Base { // COMPLIANT
46-
std::int32_t getValue() override { return 4; }
43+
std::int32_t getValue() override { return 4; }
4744
};
4845

4946
struct RegularMultiple : public Base, public AnotherBase { // COMPLIANT
50-
std::int32_t m6;
47+
std::int32_t m6;
5148
};
5249

5350
struct PrivateRegularDerived : private Base { // COMPLIANT
54-
std::int32_t m7;
51+
std::int32_t m7;
5552
};
5653

5754
struct ProtectedRegularDerived : protected Base { // COMPLIANT
58-
std::int32_t m8;
55+
std::int32_t m8;
5956
};
6057

6158
// Diamond hierarchy with virtual inheritance (non-compliant)
6259
struct DiamondLeft : public virtual Base { // NON_COMPLIANT
63-
std::int32_t leftMethod() { return getValue() + 10; }
60+
std::int32_t leftMethod() { return getValue() + 10; }
6461
};
6562

6663
struct DiamondRight : public virtual Base { // NON_COMPLIANT
67-
std::int32_t getValue() override { return 5; }
64+
std::int32_t getValue() override { return 5; }
6865
};
6966

7067
struct DiamondBottom : public DiamondLeft, public DiamondRight { // COMPLIANT
71-
std::int32_t bottomMethod() {
72-
return leftMethod(); // Calls DiamondRight::getValue() due to dominance
73-
}
68+
std::int32_t bottomMethod() {
69+
return leftMethod(); // Calls DiamondRight::getValue() due to dominance
70+
}
7471
};
7572

7673
void test_edge_cases() {
77-
// Multiple levels of virtual inheritance
78-
struct Level1 : public virtual Base { // NON_COMPLIANT
79-
std::int32_t m9;
80-
};
81-
82-
struct Level2 : public virtual Level1 { // NON_COMPLIANT
83-
std::int32_t m10;
84-
};
74+
// Multiple levels of virtual inheritance
75+
struct Level1 : public virtual Base { // NON_COMPLIANT
76+
std::int32_t m9;
77+
};
78+
79+
struct Level2 : public virtual Level1 { // NON_COMPLIANT
80+
std::int32_t m10;
81+
};
8582
}
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
No expected results have yet been specified
1+
| test.cpp:6:16:6:17 | m1 | Non-static data member 'm1' has mixed access level with other data members in class 'MixedAccessClass'. |
2+
| test.cpp:8:16:8:17 | m2 | Non-static data member 'm2' has mixed access level with other data members in class 'MixedAccessClass'. |
3+
| test.cpp:45:16:45:17 | m1 | Non-static data member 'm1' has mixed access level with other data members in class 'ProtectedAndPrivateClass'. |
4+
| test.cpp:47:16:47:17 | m2 | Non-static data member 'm2' has mixed access level with other data members in class 'ProtectedAndPrivateClass'. |
5+
| test.cpp:53:16:53:17 | m1 | Non-static data member 'm1' has mixed access level with other data members in class 'PublicAndProtectedClass'. |
6+
| test.cpp:55:16:55:17 | m2 | Non-static data member 'm2' has mixed access level with other data members in class 'PublicAndProtectedClass'. |
7+
| test.cpp:61:16:61:17 | m1 | Non-static data member 'm1' has mixed access level with other data members in class 'AllThreeAccessLevels'. |
8+
| test.cpp:63:16:63:17 | m2 | Non-static data member 'm2' has mixed access level with other data members in class 'AllThreeAccessLevels'. |
9+
| test.cpp:65:16:65:17 | m3 | Non-static data member 'm3' has mixed access level with other data members in class 'AllThreeAccessLevels'. |
10+
| test.cpp:71:16:71:17 | m1 | Non-static data member 'm1' has mixed access level with other data members in class 'OnlyProtected'. |
11+
| test.cpp:72:16:72:17 | m2 | Non-static data member 'm2' has mixed access level with other data members in class 'OnlyProtected'. |
12+
| test.cpp:73:16:73:17 | m3 | Non-static data member 'm3' has mixed access level with other data members in class 'OnlyProtected'. |
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
| test.cpp:5:5:5:14 | TestClass1 | Constructor 'TestClass1' that is callable with a single argument shall be explicit. |
2-
| test.cpp:6:5:6:25 | operator std::int32_t | Conversion operator shall be explicit. |
3-
| test.cpp:23:5:23:14 | TestClass4 | Constructor 'TestClass4' that is callable with a single argument shall be explicit. |
4-
| test.cpp:24:5:24:14 | TestClass4 | Constructor 'TestClass4' that is callable with a single argument shall be explicit. |
5-
| test.cpp:41:5:41:19 | operator double | Conversion operator shall be explicit. |
6-
| test.cpp:42:5:42:24 | operator const char * | Conversion operator shall be explicit. |
1+
| test.cpp:5:3:5:12 | TestClass1 | Constructor 'TestClass1' that is callable with a single argument shall be explicit. |
2+
| test.cpp:6:3:6:23 | operator std::int32_t | Conversion operator shall be explicit. |
3+
| test.cpp:23:3:23:12 | TestClass4 | Constructor 'TestClass4' that is callable with a single argument shall be explicit. |
4+
| test.cpp:25:3:25:12 | TestClass4 | Constructor 'TestClass4' that is callable with a single argument shall be explicit. |
5+
| test.cpp:44:3:44:17 | operator double | Conversion operator shall be explicit. |
6+
| test.cpp:45:3:45:23 | operator const char * | Conversion operator shall be explicit. |

cpp/misra/test/rules/RULE-15-1-3/test.cpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,46 @@
22

33
class TestClass1 {
44
public:
5-
TestClass1(std::int32_t a); // NON_COMPLIANT
6-
operator std::int32_t() const; // NON_COMPLIANT
5+
TestClass1(std::int32_t a); // NON_COMPLIANT
6+
operator std::int32_t() const; // NON_COMPLIANT
77
};
88

99
class TestClass2 {
1010
public:
11-
explicit TestClass2(std::int32_t a); // COMPLIANT
12-
explicit operator bool() const; // COMPLIANT
11+
explicit TestClass2(std::int32_t a); // COMPLIANT
12+
explicit operator bool() const; // COMPLIANT
1313
};
1414

1515
class TestClass3 {
1616
public:
17-
TestClass3(const TestClass3& other); // COMPLIANT - copy constructor
18-
TestClass3(TestClass3&& other); // COMPLIANT - move constructor
17+
TestClass3(const TestClass3 &other); // COMPLIANT - copy constructor
18+
TestClass3(TestClass3 &&other); // COMPLIANT - move constructor
1919
};
2020

2121
class TestClass4 {
2222
public:
23-
TestClass4(std::int32_t a, std::int32_t b = 0); // NON_COMPLIANT - callable with one argument
24-
TestClass4(char a = 'a', std::int32_t b = 0); // NON_COMPLIANT - callable with one argument
25-
TestClass4(char a, char b); // COMPLIANT - requires two arguments
23+
TestClass4(std::int32_t a,
24+
std::int32_t b = 0); // NON_COMPLIANT - callable with one argument
25+
TestClass4(char a = 'a',
26+
std::int32_t b = 0); // NON_COMPLIANT - callable with one argument
27+
TestClass4(char a, char b); // COMPLIANT - requires two arguments
2628
};
2729

2830
class TestClass5 {
2931
public:
30-
explicit TestClass5(std::int32_t a, std::int32_t b = 0); // COMPLIANT
31-
explicit TestClass5(char a = 'a', std::int32_t b = 0); // COMPLIANT
32+
explicit TestClass5(std::int32_t a, std::int32_t b = 0); // COMPLIANT
33+
explicit TestClass5(char a = 'a', std::int32_t b = 0); // COMPLIANT
3234
};
3335

3436
class TestClass6 {
3537
public:
36-
TestClass6(std::int32_t a, std::int32_t b, std::int32_t c = 0); // COMPLIANT - requires at least two arguments
38+
TestClass6(std::int32_t a, std::int32_t b,
39+
std::int32_t c = 0); // COMPLIANT - requires at least two arguments
3740
};
3841

3942
class TestClass7 {
4043
public:
41-
operator double() const; // NON_COMPLIANT
42-
operator const char*() const; // NON_COMPLIANT
43-
explicit operator void*() const; // COMPLIANT
44+
operator double() const; // NON_COMPLIANT
45+
operator const char *() const; // NON_COMPLIANT
46+
explicit operator void *() const; // COMPLIANT
4447
};
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
| test.cpp:11:15:11:23 | operator+ | Symmetrical operator 'operator+' should be implemented as a non-member function. |
2-
| test.cpp:12:15:12:23 | operator- | Symmetrical operator 'operator-' should be implemented as a non-member function. |
3-
| test.cpp:13:15:13:23 | operator* | Symmetrical operator 'operator*' should be implemented as a non-member function. |
4-
| test.cpp:14:15:14:23 | operator/ | Symmetrical operator 'operator/' should be implemented as a non-member function. |
5-
| test.cpp:15:15:15:23 | operator% | Symmetrical operator 'operator%' should be implemented as a non-member function. |
6-
| test.cpp:17:10:17:19 | operator== | Symmetrical operator 'operator==' should be implemented as a non-member function. |
7-
| test.cpp:18:10:18:19 | operator!= | Symmetrical operator 'operator!=' should be implemented as a non-member function. |
8-
| test.cpp:19:10:19:18 | operator< | Symmetrical operator 'operator<' should be implemented as a non-member function. |
9-
| test.cpp:20:10:20:19 | operator<= | Symmetrical operator 'operator<=' should be implemented as a non-member function. |
10-
| test.cpp:21:10:21:19 | operator>= | Symmetrical operator 'operator>=' should be implemented as a non-member function. |
11-
| test.cpp:22:10:22:18 | operator> | Symmetrical operator 'operator>' should be implemented as a non-member function. |
12-
| test.cpp:24:15:24:23 | operator^ | Symmetrical operator 'operator^' should be implemented as a non-member function. |
13-
| test.cpp:25:15:25:23 | operator& | Symmetrical operator 'operator&' should be implemented as a non-member function. |
14-
| test.cpp:26:15:26:23 | operator\| | Symmetrical operator 'operator\|' should be implemented as a non-member function. |
15-
| test.cpp:28:10:28:19 | operator&& | Symmetrical operator 'operator&&' should be implemented as a non-member function. |
16-
| test.cpp:29:10:29:19 | operator\|\| | Symmetrical operator 'operator\|\|' should be implemented as a non-member function. |
17-
| test.cpp:32:15:32:23 | operator+ | Symmetrical operator 'operator+' should be implemented as a non-member function. |
18-
| test.cpp:33:10:33:19 | operator== | Symmetrical operator 'operator==' should be implemented as a non-member function. |
1+
| test.cpp:11:13:11:21 | operator+ | Symmetrical operator 'operator+' should be implemented as a non-member function. |
2+
| test.cpp:12:13:12:21 | operator- | Symmetrical operator 'operator-' should be implemented as a non-member function. |
3+
| test.cpp:13:13:13:21 | operator* | Symmetrical operator 'operator*' should be implemented as a non-member function. |
4+
| test.cpp:14:13:14:21 | operator/ | Symmetrical operator 'operator/' should be implemented as a non-member function. |
5+
| test.cpp:15:13:15:21 | operator% | Symmetrical operator 'operator%' should be implemented as a non-member function. |
6+
| test.cpp:17:8:17:17 | operator== | Symmetrical operator 'operator==' should be implemented as a non-member function. |
7+
| test.cpp:18:8:18:17 | operator!= | Symmetrical operator 'operator!=' should be implemented as a non-member function. |
8+
| test.cpp:19:8:19:16 | operator< | Symmetrical operator 'operator<' should be implemented as a non-member function. |
9+
| test.cpp:20:8:20:17 | operator<= | Symmetrical operator 'operator<=' should be implemented as a non-member function. |
10+
| test.cpp:21:8:21:17 | operator>= | Symmetrical operator 'operator>=' should be implemented as a non-member function. |
11+
| test.cpp:22:8:22:16 | operator> | Symmetrical operator 'operator>' should be implemented as a non-member function. |
12+
| test.cpp:24:13:24:21 | operator^ | Symmetrical operator 'operator^' should be implemented as a non-member function. |
13+
| test.cpp:25:13:25:21 | operator& | Symmetrical operator 'operator&' should be implemented as a non-member function. |
14+
| test.cpp:26:13:26:21 | operator\| | Symmetrical operator 'operator\|' should be implemented as a non-member function. |
15+
| test.cpp:28:8:28:17 | operator&& | Symmetrical operator 'operator&&' should be implemented as a non-member function. |
16+
| test.cpp:29:8:29:17 | operator\|\| | Symmetrical operator 'operator\|\|' should be implemented as a non-member function. |
17+
| test.cpp:32:13:32:21 | operator+ | Symmetrical operator 'operator+' should be implemented as a non-member function. |
18+
| test.cpp:33:8:33:17 | operator== | Symmetrical operator 'operator==' should be implemented as a non-member function. |

0 commit comments

Comments
 (0)