Skip to content

Commit ca519cc

Browse files
authored
* Lint rst * Trim trailing whitespace
1 parent e872d1b commit ca519cc

File tree

5 files changed

+54
-47
lines changed

5 files changed

+54
-47
lines changed

.github/workflows/build-guidelines.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,10 @@ jobs:
7676
path: build
7777
retention-days: 7
7878
compression-level: 6 # Default compression level for a good balance of speed and size
79+
lint_rst:
80+
runs-on: ubuntu-latest
81+
steps:
82+
- name: Checkout repository
83+
uses: actions/checkout@v3
84+
- name: Check for typos
85+
run: pipx run sphinx-lint src

src/coding-guidelines/macros.rst

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,22 @@ Macros
101101
:tags: reduce-human-error
102102

103103
Functions should always be preferred over macros, except when macros provide essential functionality that functions cannot, such as variadic interfaces, compile-time code generation, or syntax extensions via custom derive and attribute macros.
104-
104+
105105
|
106106
107-
.. rationale::
107+
.. rationale::
108108
:id: rat_M9bp23ctkzQ7
109109
:status: draft
110110

111111
Although the compiler reports both the macro expansion and its invocation site, diagnostics originating within macros can be more difficult to interpret than those from ordinary function or type definitions. Complex or deeply nested macros may obscure intent and hinder static analysis, increasing the risk of misinterpretation or overlooked errors during code review.
112-
113112

114-
**Debugging Complexity**
113+
114+
**Debugging Complexity**
115115

116116
- Errors point to expanded code rather than source locations, making it difficult to trace compile-time errors back to the original macro invocation.
117117

118118
**Optimization**
119-
119+
120120
- Macros may inhibit compiler optimizations that work better with functions.
121121
- Macros act like ``#[inline(always)]`` functions, which can lead to code bloat.
122122
- They don't benefit from the compiler's inlining heuristics, missing out on selective inlining where the compiler decides when inlining is beneficial.
@@ -134,7 +134,7 @@ Macros
134134
:status: draft
135135

136136
Using a macro where a simple function would suffice, leads to hidden mutation:
137-
137+
138138
.. code-block:: rust
139139
140140
macro_rules! increment_and_double {
@@ -162,7 +162,7 @@ Macros
162162
.. code-block:: rust
163163
164164
fn increment_and_double(x: &mut i32) -> i32 {
165-
*x += 1; // mutation is explicit
165+
*x += 1; // mutation is explicit
166166
*x * 2
167167
}
168168
let mut num = 5;
@@ -172,7 +172,7 @@ Macros
172172
173173
The function version makes the mutation and borrowing explicit in its signature, improving readability, safety, and debuggability.
174174

175-
175+
176176

177177
.. guideline:: Shall not use Function-like Macros
178178
:id: gui_WJlWqgIxmE8P
@@ -355,7 +355,7 @@ Macros
355355
Attribute macros shall neither be declared nor invoked.
356356
Prefer less powerful macros that only extend source code.
357357

358-
.. rationale::
358+
.. rationale::
359359
:id: rat_X8uCF5yx7Mpo
360360
:status: draft
361361

@@ -366,9 +366,9 @@ Macros
366366
:status: draft
367367

368368
Explanation of code example.
369-
369+
370370
.. code-block:: rust
371-
371+
372372
#[tokio::main] // non-compliant
373373
async fn main() {
374374
@@ -379,26 +379,26 @@ Macros
379379
:status: draft
380380

381381
Explanation of code example.
382-
382+
383383
.. code-block:: rust
384-
384+
385385
fn example_function() {
386386
// Compliant implementation
387387
}
388-
388+
389389
.. guideline:: Do not hide unsafe blocks within macro expansions
390-
:id: gui_FRLaMIMb4t3S
391-
:category: required
392-
:status: draft
393-
:release: todo
390+
:id: gui_FRLaMIMb4t3S
391+
:category: required
392+
:status: draft
393+
:release: todo
394394
:fls: fls_4vjbkm4ceymk
395395
:decidability: todo
396396
:scope: todo
397397
:tags: reduce-human-error
398398

399399
Description of the guideline goes here.
400400

401-
.. rationale::
401+
.. rationale::
402402
:id: rat_WJubG7KuUDLW
403403
:status: draft
404404

src/coding-guidelines/types-and-traits.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Types and Traits
1717
:tags: numerics
1818

1919
Code must not rely on Rust's implicit integer wrapping behavior that may occur in release
20-
builds. Instead, explicitly handle potential overflows using the standard library's checked,
20+
builds. Instead, explicitly handle potential overflows using the standard library's checked,
2121
saturating, or wrapping operations.
2222

2323
.. rationale::
@@ -36,17 +36,17 @@ Types and Traits
3636

3737
.. _overflow-checks: https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/codegen-options/index.md#overflow-checks
3838
.. _frequently requested change: https://lang-team.rust-lang.org/frequently-requested-changes.html#numeric-overflow-checking-should-be-on-by-default-even-in-release-mode
39-
39+
4040
Safety-critical software requires consistent and predictable behavior across all build
4141
configurations. Explicit handling of potential overflow conditions improves code clarity,
4242
maintainability, and reduces the risk of numerical errors in production.
4343

4444
.. non_compliant_example::
4545
:id: non_compl_ex_PO5TyFsRTlWv
4646
:status: draft
47-
47+
4848
.. code-block:: rust
49-
49+
5050
fn calculate_next_position(current: u32, velocity: u32) -> u32 {
5151
// Potential for silent overflow in release builds
5252
current + velocity
@@ -55,9 +55,9 @@ Types and Traits
5555
.. compliant_example::
5656
:id: compl_ex_WTe7GoPu5Ez0
5757
:status: draft
58-
58+
5959
.. code-block:: rust
60-
60+
6161
fn calculate_next_position(current: u32, velocity: u32) -> u32 {
6262
// Explicitly handle potential overflow with checked addition
6363
current.checked_add(velocity).expect("Position calculation overflowed")

src/conf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,28 @@
3838
"directive": "guideline",
3939
"title": "Guideline",
4040
"prefix": "gui_",
41-
"color": "#BFD8D2",
41+
"color": "#BFD8D2",
4242
"style": "node"
4343
},
4444
{
4545
"directive": "rationale",
4646
"title": "Rationale",
4747
"prefix": "rat_",
48-
"color": "#DF744A",
48+
"color": "#DF744A",
4949
"style": "node"
5050
},
5151
{
5252
"directive": "compliant_example",
5353
"title": "Compliant Example",
5454
"prefix": "compl_ex_",
55-
"color": "#729FCF",
55+
"color": "#729FCF",
5656
"style": "node"
5757
},
5858
{
5959
"directive": "non_compliant_example",
6060
"title": "Non-Compliant Example",
6161
"prefix": "non_compl_ex_",
62-
"color": "#729FCF",
62+
"color": "#729FCF",
6363
"style": "node"
6464
}
6565
]

src/process/style-guideline.rst

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ We will examine each part:
3939
:scope: module
4040
:tags: numerics
4141

42-
Code must not rely on Rust's implicit integer wrapping behavior that occurs in release builds.
43-
Instead, explicitly handle potential overflows using the standard library's checked,
42+
Code must not rely on Rust's implicit integer wrapping behavior that occurs in release builds.
43+
Instead, explicitly handle potential overflows using the standard library's checked,
4444
saturating, or wrapping operations.
4545

4646
.. rationale::
@@ -50,17 +50,17 @@ We will examine each part:
5050
In debug builds, Rust performs runtime checks for integer overflow and will panic if detected.
5151
However, in release builds (with optimizations enabled), integer operations silently wrap
5252
around on overflow, creating potential for silent failures and security vulnerabilities.
53-
53+
5454
Safety-critical software requires consistent and predictable behavior across all build
5555
configurations. Explicit handling of potential overflow conditions improves code clarity,
5656
maintainability, and reduces the risk of numerical errors in production.
5757

5858
.. non_compliant_example::
5959
:id: non_compl_ex_PO5TyFsRTlWv
6060
:status: draft
61-
61+
6262
.. code-block:: rust
63-
63+
6464
fn calculate_next_position(current: u32, velocity: u32) -> u32 {
6565
// Potential for silent overflow in release builds
6666
current + velocity
@@ -69,9 +69,9 @@ We will examine each part:
6969
.. compliant_example::
7070
:id: compl_ex_WTe7GoPu5Ez0
7171
:status: draft
72-
72+
7373
.. code-block:: rust
74-
74+
7575
fn calculate_next_position(current: u32, velocity: u32) -> u32 {
7676
// Explicitly handle potential overflow with checked addition
7777
current.checked_add(velocity).expect("Position calculation overflowed")
@@ -142,7 +142,7 @@ An organization or project **MAY** choose to recategorize any ``required`` guide
142142
``advisory``
143143
^^^^^^^^^^^^
144144

145-
These are recommendations and **SHOULD** be applied. However, the category of ``advisory`` does not mean
145+
These are recommendations and **SHOULD** be applied. However, the category of ``advisory`` does not mean
146146
that these items can be ignored, but rather that they **SHOULD** be followed as far as reasonably practical.
147147
Formal deviation is not necessary for advisory guidelines but, if the formal deviation process is not followed,
148148
alternative arrangements **MUST** be made for documenting non-compliances.
@@ -181,7 +181,7 @@ the ``status`` to ``retired``.
181181
* ``approved``
182182
* ``retired``
183183

184-
Guidelines have a lifecycle. When they are first proposed and **MUST** be marked as ``draft``
184+
Guidelines have a lifecycle. When they are first proposed and **MUST** be marked as ``draft``
185185
to allow adoption and feedback to accrue. The Coding Guidelines Subcommittee **MUST**
186186
periodically review ``draft`` guidelines and either promote them to ``approved``
187187
or demote them to ``retired``.
@@ -196,8 +196,8 @@ For more, see :ref:`Guideline Lifecycle`.
196196
``draft``
197197
^^^^^^^^^
198198

199-
These guidelines are not yet considered in force, but are mature enough they **MAY** be enforced.
200-
No formal deviation is required as outlined in :ref:`Compliance`, but alternative arrangements
199+
These guidelines are not yet considered in force, but are mature enough they **MAY** be enforced.
200+
No formal deviation is required as outlined in :ref:`Compliance`, but alternative arrangements
201201
**MUST** be made for documenting non-compliances.
202202

203203
*Note*: ``draft`` guideline usage and feedback will help to either promote them to ``approved`` or demote
@@ -339,7 +339,7 @@ require a deviation.
339339
In debug builds, Rust performs runtime checks for integer overflow and will panic if detected.
340340
However, in release builds (with optimizations enabled), integer operations silently wrap
341341
around on overflow, creating potential for silent failures and security vulnerabilities.
342-
342+
343343
Safety-critical software requires consistent and predictable behavior across all build
344344
configurations. Explicit handling of potential overflow conditions improves code clarity,
345345
maintainability, and reduces the risk of numerical errors in production.
@@ -373,9 +373,9 @@ TODO(pete.levasseur)
373373
.. non_compliant_example::
374374
:id: non_compl_ex_PO5TyFsRTlWv
375375
:status: draft
376-
376+
377377
.. code-block:: rust
378-
378+
379379
fn calculate_next_position(current: u32, velocity: u32) -> u32 {
380380
// Potential for silent overflow in release builds
381381
current + velocity
@@ -384,7 +384,7 @@ TODO(pete.levasseur)
384384
``non_compliant_example`` ``id``
385385
--------------------------------
386386

387-
A unique identifier for each ``non_compliant_example``. ``non_compliant_example`` identifiers
387+
A unique identifier for each ``non_compliant_example``. ``non_compliant_example`` identifiers
388388
**MUST** begin with ``non_compl_ex_``.
389389

390390
These identifiers are considered **stable** across releases and **MUST NOT** be removed.
@@ -440,9 +440,9 @@ than the current guideline.
440440
.. compliant_example::
441441
:id: compl_ex_WTe7GoPu5Ez0
442442
:status: draft
443-
443+
444444
.. code-block:: rust
445-
445+
446446
fn calculate_next_position(current: u32, velocity: u32) -> u32 {
447447
// Explicitly handle potential overflow with checked addition
448448
current.checked_add(velocity).expect("Position calculation overflowed")
@@ -451,7 +451,7 @@ than the current guideline.
451451
``compliant_example`` ``id``
452452
----------------------------
453453

454-
A unique identifier for each ``compliant_example``. ``compliant_example`` identifiers
454+
A unique identifier for each ``compliant_example``. ``compliant_example`` identifiers
455455
**MUST** begin with ``compl_ex_``.
456456

457457
These identifiers are considered **stable** across releases and **MUST NOT** be removed.

0 commit comments

Comments
 (0)