Skip to content

Commit 43b0191

Browse files
TylerMSFTTylerMSFT
authored andcommitted
improve draft
1 parent b1ee87c commit 43b0191

File tree

3 files changed

+18
-28
lines changed

3 files changed

+18
-28
lines changed

docs/ide/lnt-int-naming-convention.md

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,20 @@ monikerRange: ">=msvc-170"
1010

1111
Ensure that the naming convention for symbols aligns with the coding style specified in the project's `.editorconfig` file.
1212

13-
To enable this feature, add an `.editorconfig` file in the same directory as your project file. The `.editorconfig` specifies the naming conventions for symbols in your project. For an example `.editorconfig` that specifies the naming conventions for Unreal Engine projects, see [`.editorconfig` on ](https://raw.githubusercontent.com/microsoft/vc-ue-extensions/main/Source/.editorconfig).
13+
To enable this feature, add an `.editorconfig` file in the same directory as your project file. The `.editorconfig` specifies the naming conventions for symbols in your project. For an example `.editorconfig` that specifies the naming conventions for Unreal Engine projects, see this example on [GitHub](https://raw.githubusercontent.com/microsoft/vc-ue-extensions/main/Source/.editorconfig).
1414

1515
Once you have the `.editorconfig` file in your project, turn on the `int-naming-convention` check with the **Naming Convention** setting in the C/C++ Code Style options. For information about how to change this setting, see [Configure the linter](cpp-linter-overview.md#configure-the-linter).
1616

1717
## Example
1818

19-
The For example, an `editorconfig` file that contains:
19+
Given an `editorconfig` file that contains:
2020

21-
```cpp
22-
class MyClass
23-
{
24-
25-
public:
26-
27-
int getValue() { return value; } // Flagged: ‘getValue’ doesn't modify the object's state.
28-
29-
void setValue(int newValue) { value = newValue; } // OK: ‘setValue’ modifies the object's state.
30-
31-
private:
32-
33-
int value = 42;
34-
35-
};
21+
```
22+
cpp_naming_style.boolean_style.capitalization = pascal_case
23+
cpp_naming_style.boolean_style.required_prefix = b
3624
``````
3725
38-
flags the following code:
26+
The linter will flag the following code:
3927
4028
```cpp
4129
void example()
@@ -46,7 +34,7 @@ void example()
4634

4735
## How to fix the issue
4836

49-
Change the naming based on the code style specified in the `.editorconfig`. For example:
37+
Change the naming to match the style specified in the `.editorconfig`. For example:
5038

5139
```cpp
5240
void example()
@@ -55,9 +43,9 @@ void example()
5543
}
5644
```
5745

58-
The editor can make the change for you. Place the cursor on the flagged symbol, and choose **Show potential fixes** and then **Apply naming convention**:
46+
The editor can make the change for you. Place the cursor on the flagged symbol. Choose **Show potential fixes** and then **Apply naming convention**:
5947

60-
:::image type="content" source="media/int-naming-convention-apply-naming-convention.png" alt-text="Screenshot of the IDE suggesting to apply naming convention.":::
48+
:::image type="complex" source="media/int-naming-convention-apply-naming-convention.png" alt-text="Screenshot of the IDE suggesting applying naming convention.":::
6149
The code editor shows bool myFlag = true. With the cursor on that line of code, **Show potential fixes** appeared and was chosen. Now **Apply naming convention** is visible and it shows bool my Flag = true in red and the suggested change, bool b My Flag, in green. You can now choose **Apply naming convention** to change the flagged code to bool b My Flag = true.
6250
:::image-end:::
6351

docs/ide/lnt-make-member-function-const.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ monikerRange: ">=msvc-170"
88
---
99
# `make-member-function-const`
1010

11-
When member functions don’t modify their object state, mark them as const. This guidance comes from the [C++ Core Guideline Con.2](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#con2-by-default-make-member-functions-const).
11+
When member functions don’t modify their object state, annotate them with the `const` keyword. This guidance comes from the [C++ Core Guideline Con.2](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#con2-by-default-make-member-functions-const).
1212

1313
## Example
1414

@@ -18,13 +18,11 @@ class MyClass
1818
public:
1919

2020
int getValue() { return value; } // Flagged: ‘getValue’ doesn't modify the object's state.
21-
2221
void setValue(int newValue) { value = newValue; } // OK: ‘setValue’ modifies the object's state.
2322

2423
private:
2524

2625
int value = 42;
27-
2826
};
2927

3028
double getRadius()
@@ -35,7 +33,9 @@ double getRadius()
3533

3634
## How to fix the issue
3735

38-
The solution proposed by the linter is to mark member functions `const` when they don't modify the object's state. This provides a clear indication to both developers and the compiler that the function is safe to call on `const` objects. In the following example, `const` has been added to `getValue()` and `getRadius()`:
36+
The solution proposed by the linter is to mark member functions `const` when they don't modify the object's state. This provides a clear indication to both developers and the compiler that the function is safe to call on `const` objects.
37+
38+
In the following example, `const` has been added to `getValue()` and `getRadius()`:
3939

4040
```cpp
4141
class MyClass
@@ -57,12 +57,14 @@ double getRadius() const // added const
5757
}
5858
```
5959

60-
The editor can make this change for you. Place the cursor on the flagged symbol, and choose **Show potential fixes** and then **Make member const**:
60+
The editor can make this change for you. Place the cursor on the flagged symbol and choose **Show potential fixes** and then **Make member const**:
6161

6262
:::image type="content" source="media/make-member-function-const.png" alt-text="Screenshot of the editor suggesting to make member const." :::
6363
The cursor is on the line int getValue() and **Show potential fixes** appeared and was chosen. Now **Make member const** is visible and it shows the get value function with const added to it. You can now choose **Make member const** to make the change.
6464
:::image-end:::
6565

66+
Make this change for all flagged member functions.
67+
6668
## Remarks
6769

6870
This check focuses on `const` usage for member functions in C++ code. The C++ Core Guidelines recommends marking member functions as `const` when they don't modify the object's state.

docs/ide/toc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ items:
3232
href: ../ide/lnt-logical-bitwise-mismatch.md
3333
- name: lnt-int-naming-convention
3434
href: ../ide/lnt-int-naming-convention.md
35-
- name: lnt-uninitialized-local
36-
href: ../ide/lnt-uninitialized-local.md
3735
- name: lnt-make-member-function-const
3836
href: ../ide/lnt-make-member-function-const.md
37+
- name: lnt-uninitialized-local
38+
href: ../ide/lnt-uninitialized-local.md
3939
- name: Change signature
4040
href: ../ide/refactoring/change-signature.md
4141
- name: Convert to raw string literal

0 commit comments

Comments
 (0)