Skip to content

Commit 50a0c05

Browse files
augustin-vsmoelius
authored andcommitted
update README, CI
1 parent a42d7c7 commit 50a0c05

File tree

4 files changed

+37
-22
lines changed

4 files changed

+37
-22
lines changed

examples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,4 @@ The example libraries are separated into the following three categories:
8080
[general]: #general
8181
[restriction]: #restriction
8282
[supplementary]: #supplementary
83+
[testing]: #testing

examples/supplementary/nonexistent_path_in_comment/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ crate-type = ["cdylib"]
1313
cargo_metadata = { workspace = true }
1414
clippy_utils = { git = "https://github.com/rust-lang/rust-clippy", rev = "19e305bb57a7595f2a8d81f521c0dd8bf854e739" }
1515
dylint_linting = { path = "../../../utils/linting" }
16-
regex = { workspace = true }
1716
once_cell = { workspace = true }
17+
regex = { workspace = true }
1818

1919
[dev-dependencies]
2020
dylint_testing = { path = "../../../utils/testing" }
Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
1-
# Nonexistent Path in Comment Lint
1+
# nonexistent_path_in_comment
22

33
### What it does
4-
5-
This lint checks comments in the code for file path references and verifies that the referenced files actually do exist. It processes both line comments (using `//`) and block comments (`/* ... */`) by using regex to extract potential file paths. When the lint finds a file path that does not exist on the filesystem it emits a warning.
4+
This lint checks code comments, including both line comments (using `//`) and block comments
5+
(`/*...*/`) for file path references. It then validates that the referenced files exist either
6+
relative to the source file's directory or relative to the workspace root. When a file path
7+
reference does not point to an existing file, the lint emits a warning.
68

79
### Why is this bad?
8-
9-
References to nonexistent files in comments can be misleading:
10-
- They clutter the code with outdated or inaccurate references.
11-
- They may cause confusion among developers who are trying to trace implementation details or documentation.
10+
References to nonexistent files in comments can be misleading:
11+
- They clutter the code with outdated or inaccurate references.
12+
- They may cause confusion among developers who are trying to trace implementation details
13+
or documentation.
1214

1315
### Known problems
14-
- Can only check for absolute path or path relative to commented file.
15-
- [This example from the issue](https://github.com/trailofbits/dylint/issues/1225#issue-2315607396) would get flaged even if it did exist, as this lint doesn't check for project root.
16+
- This example:
17+
```rust
18+
// dylint/dylint/build.rs (it exists)
19+
```
20+
would get flagged here because the workspace root is `supplementary`
21+
it did exist, as this lint doesn't check for project root.
1622

1723
### Example
18-
19-
The lint issues a warning when a comment refers to a file that does not exist:
20-
2124
```
22-
// See ../nonexistent/path/file.rs for further details
25+
// See ../nonexistent/path/file.rs for implementation details
2326
fn main() {}
2427
```
25-
26-
Use this approach instead, referring to a file that exists:
27-
28+
Use instead:
2829
```
29-
// See ../existing/file.rs for actual implementation details
30+
// See ../actual/path/file.rs for implementation details
3031
fn main() {}
31-
```
32+
```

examples/supplementary/nonexistent_path_in_comment/src/lib.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,24 @@ use rustc_span::{BytePos, FileName, Span, SyntaxContext};
1313

1414
dylint_linting::declare_late_lint! {
1515
/// ### What it does
16-
/// Checks for file paths in comments that don't exist in the filesystem.
16+
/// This lint checks code comments, including both line comments (using `//`) and block comments
17+
/// (`/*...*/`) for file path references. It then validates that the referenced files exist either
18+
/// relative to the source file's directory or relative to the workspace root. When a file path
19+
/// reference does not point to an existing file, the lint emits a warning.
1720
///
1821
/// ### Why is this bad?
19-
/// References to nonexistent files in comments can be misleading and may indicate outdated
20-
/// documentation or typos.
22+
/// References to nonexistent files in comments can be misleading:
23+
/// - They clutter the code with outdated or inaccurate references.
24+
/// - They may cause confusion among developers who are trying to trace implementation details
25+
/// or documentation.
26+
///
27+
/// ### Known problems
28+
/// - This example:
29+
/// ```rust
30+
/// // dylint/dylint/build.rs (it exists)
31+
/// ```
32+
/// would get flagged here because the workspace root is `supplementary`
33+
/// it did exist, as this lint doesn't check for project root.
2134
///
2235
/// ### Example
2336
/// ```

0 commit comments

Comments
 (0)