Skip to content

Commit 6978794

Browse files
authored
feat: adding crate typos and typos.toml (#1289)
* adding crate typos and typos.toml * Updating yoke-derive * Adding typos results and exclusions * Apply baseline from operator-templating * Fixing marker across repo
1 parent 1b564c0 commit 6978794

10 files changed

Lines changed: 67 additions & 9 deletions

File tree

‎.pre-commit-config.yaml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ default_language_version:
33
node: system
44

55
repos:
6+
- repo: https://github.com/crate-ci/typos
7+
rev: 00f422f3b19c57bc6338715ebfe3316d38768461 # v1.50.3
8+
hooks:
9+
- id: typos
10+
# Drop the upstream default `--write-changes` so the hook only
11+
# reports failures instead of writing changes.
12+
# Keep `--force-exclude` so the excludes in typos.toml still
13+
# apply to the paths prek passes in.
14+
args: ["--force-exclude"]
15+
616
- repo: https://github.com/pre-commit/pre-commit-hooks
717
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # 5.0.0
818
hooks:

‎crates/config-utils/src/template/cli_args.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct TemplateCommand {
1515
#[arg(value_enum)]
1616
pub file_type: Option<FileType>,
1717

18-
/// By default inserted values are automatically escaped according to the deteced file format. You can disable
18+
/// By default inserted values are automatically escaped according to the detected file format. You can disable
1919
/// this, e.g. when you need to insert XML tags (as they otherwise would be escaped).
2020
/// NOTE: Please make sure to correctly escape the inserted text on your own!
2121
#[clap(long)]

‎crates/config-utils/src/template/mod.rs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub enum Error {
3131
#[snafu(display(
3232
"The extension {extension} is not known, can not determine file type. Please specify the file type manually."
3333
))]
34-
ExtensionUnkown { extension: String },
34+
ExtensionUnkown { extension: String }, // typos:ignore-line
3535

3636
#[snafu(display("Failed to create temporary file {tmp_file_name:?}"))]
3737
CreateTemporaryFile {
@@ -63,6 +63,7 @@ pub enum Error {
6363
#[snafu(display(
6464
"Could not find the end pattern {end_pattern:?} in expression {expression:?}"
6565
))]
66+
// typos:ignore-next-line
6667
FindEndPatten {
6768
end_pattern: String,
6869
expression: String,
@@ -95,7 +96,7 @@ pub fn template(file_name: &PathBuf, file_type: Option<&FileType>, escape: bool)
9596

9697
KNOWN_FILE_TYPES
9798
.get(extension)
98-
.context(ExtensionUnkownSnafu { extension })?
99+
.context(ExtensionUnkownSnafu { extension })? // typos:ignore-line
99100
}
100101
};
101102

@@ -198,7 +199,7 @@ fn replacement_action_for_env_var(env_var_name: &str) -> Result<String> {
198199
/// * `replacement_action` must be a function that is called and get passed the [`&str`] content between the start and end
199200
/// pattern. This can e.g. be the name of the env var or file name to read.
200201
///
201-
/// Returns wether the `line` was modified.
202+
/// Returns whether the `line` was modified.
202203
fn replace_thingy_in_line(
203204
line: &mut String,
204205
start_pattern: &str,
@@ -223,6 +224,7 @@ fn replace_thingy_in_line(
223224
debug_assert_eq!(&line[index..index + start_pattern.len()], start_pattern);
224225
let (parameter, _) = line[index + start_pattern.len()..]
225226
.split_once(end_pattern)
227+
// typos:ignore-next-line
226228
.context(FindEndPattenSnafu {
227229
// FIXME: Truncate string to not bloat error message
228230
expression: &line[index..],

‎crates/stackable-operator/src/commons/product_image_selection.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ pub struct ResolvedProductImage {
132132

133133
/// Kubernetes' supported image pull policies.
134134
///
135-
/// Our product image selection choses the policy automatically based on two factors:
135+
/// Our product image selection chooses the policy automatically based on two factors:
136136
///
137137
/// - If the image pull policy is explicitly set by the user
138138
/// - If the used Stackable version is considered floating/the user opted for

‎crates/stackable-operator/src/kvp/label/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ impl Labels {
450450
///
451451
/// This function returns a result, because the parameters `owner`, `app_name`,
452452
/// and `role` can contain invalid data or can exceed the maximum allowed
453-
/// number fo characters.
453+
/// number of characters.
454454
pub fn role_selector<R>(owner: &R, app_name: &str, role: &str) -> Result<Self, LabelError>
455455
where
456456
R: Resource,

‎crates/stackable-operator/src/v2/env_overrides.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ mod tests {
117117
#[test]
118118
fn deserialize_rejects_invalid_names() {
119119
// "=" is not allowed in environment variable names.
120+
// typos:ignore-block-start
120121
let result: Result<EnvOverrides, serde_json::Error> = serde_json::from_value(json!({
121122
"FO=O": "1"
122123
}));
@@ -128,6 +129,7 @@ mod tests {
128129
),
129130
result.map_err(|err| err.to_string())
130131
);
132+
// typos:ignore-block-end
131133
}
132134

133135
#[test]

‎crates/stackable-operator/src/v2/macros/attributed_string_type.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ mod tests {
767767
}
768768

769769
#[test]
770-
fn test_attributed_string_type_json_schema_without_constaints() {
770+
fn test_attributed_string_type_json_schema_without_constraints() {
771771
type T = JsonSchemaWithoutConstraintsTest;
772772

773773
T::test_example();

‎crates/stackable-telemetry/src/tracing/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ impl Tracing {
562562
// NOTE (@NickLarsenNZ): There are various propagators. Eg: TraceContextPropagator
563563
// standardises HTTP headers to propagate trace-id, parent-id, etc... while the
564564
// BaggagePropagator sets a "baggage" header with the value being key=value pairs. There
565-
// are other kinds too. There is also B3 and Jaeger, and some legacy stuff like OT Trace
565+
// are other kinds too. There is also B3 and Jaeger, and some legacy stuff like OT Trace // typos:ignore-line
566566
// and OpenCensus.
567567
// See: https://opentelemetry.io/docs/specs/otel/context/api-propagators/
568568
TraceContextPropagator::new(),

‎crates/stackable-versioned-macros/tests/inputs/pass/shortnames.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use stackable_versioned::versioned;
33
#[versioned(version(name = "v1alpha1"))]
44
// ---
55
pub(crate) mod versioned {
6-
#[versioned(crd(group = "stackable.tech", shortname = "f", shortname = "fo", doc = "Test"))]
6+
#[versioned(crd(group = "stackable.tech", shortname = "f", shortname = "fo", doc = "Test"))] // typos:ignore-line
77
#[derive(
88
Clone,
99
Debug,

‎typos.toml‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Configuration for typos (https://github.com/crate-ci/typos), run via the prek
2+
# hook in .pre-commit-config.yaml.
3+
4+
[files]
5+
# Bare `typos` skips hidden dirs by default, but prek passes explicit paths and
6+
# so does check them. Turn it off so both agree.
7+
ignore-hidden = false
8+
9+
extend-exclude = [
10+
# Ignore `.git`, which the above `ignore-hidden = false` would otherwise pull in.
11+
".git/",
12+
# Generated by `cargo xtask crd preview`. Most of the content is Kubernetes'
13+
# own schema documentation, which is not ours to correct, and the doc
14+
# comments we do own are already checked at their source.
15+
"crates/stackable-operator/crds/",
16+
# Generated by `cargo insta`. The inputs they are rendered from are checked
17+
# at their source in the sibling `inputs/` directories.
18+
"crates/*/tests/snapshots/",
19+
]
20+
21+
[default]
22+
# typos has no native suppression directive
23+
# (https://github.com/crate-ci/typos/issues/316), so these regexes provide one.
24+
# A marker must sit in a comment: after `#`, `//` or `;` (free text may follow),
25+
# or inside a closed `<!-- -->`, `/* */` or `{# #}` (free text may precede the
26+
# closer). An unterminated `typos:ignore-block-start` suppresses nothing.
27+
#
28+
# Use one of the following when the word is correct at one place but would still be a typo elsewhere:
29+
#
30+
# # typos:ignore-line at the end of the line it applies to
31+
# # typos:ignore-next-line on its own line, above the offending line
32+
# # typos:ignore-block-start / typos:ignore-block-end around a block
33+
extend-ignore-re = [
34+
'(?Rm)^.*?(?:(?:^|[^{])(?:#|//|;)[ \t]*typos:ignore-line\b.*|(?:<!--[ \t]*typos:ignore-line\b.*?-->|/\*[ \t]*typos:ignore-line\b.*?\*/|\{#[ \t]*typos:ignore-line\b.*?#\})[ \t]*)$',
35+
'(?Rm)^[ \t]*(?:(?:#|//|;)[ \t]*typos:ignore-next-line\b.*|(?:<!--[ \t]*typos:ignore-next-line\b.*?-->|/\*[ \t]*typos:ignore-next-line\b.*?\*/|\{#[ \t]*typos:ignore-next-line\b.*?#\})[ \t]*)\r?\n.*$',
36+
'(?ms)(?:(?:^|[^{])(?:#|//|;)[ \t]*typos:ignore-block-start\b|<!--[ \t]*typos:ignore-block-start\b[^\n]*?-->|/\*[ \t]*typos:ignore-block-start\b[^\n]*?\*/|\{#[ \t]*typos:ignore-block-start\b[^\n]*?#\}).*?(?:(?:^|[^{])(?:#|//|;)[ \t]*typos:ignore-block-end\b|<!--[ \t]*typos:ignore-block-end\b[^\n]*?-->|/\*[ \t]*typos:ignore-block-end\b[^\n]*?\*/|\{#[ \t]*typos:ignore-block-end\b[^\n]*?#\})',
37+
]
38+
39+
# Before adding an entry in here, consider an in-place marker instead.
40+
# Every entry below gets a one-line comment saying what the word is.
41+
[default.extend-words]
42+
# Accepted variant of "unparsable". Used in stackable-versioned test fixture file
43+
# names (`unparseable_missing_field.json`), where an in-place marker cannot go.
44+
unparseable = "unparseable"

0 commit comments

Comments
 (0)