Skip to content

ADR: add rust linting & formatting ADR proposal#80

Draft
theswiftfox wants to merge 2 commits intomainfrom
theswiftfox/adr_rust_style
Draft

ADR: add rust linting & formatting ADR proposal#80
theswiftfox wants to merge 2 commits intomainfrom
theswiftfox/adr_rust_style

Conversation

@theswiftfox
Copy link

Summary

Add an ADR regarding rust linter & formatting rules.
Outcome TBD before merging.

Notes for Reviewers

Feel free to add suggestions or propose a third option to be decided in the architecture meeting.

Signed-off-by: Elena Gantner <elena.gantner@mercedes-benz.com>
@alexmohr
Copy link

alexmohr commented Feb 9, 2026

Related suggestion: Once we agree on these rules they can be put into the CICD repository, to enable re-use. Furhtermore the CICD repo can offer a check to validate them and leave comments via reviewdog, similar to what we did in the CDA here

The goal is to formalize the usage of linting rules for rust using clippy and
set common codestyle rules applied through rustfmt.
This will help having a single style across the different components which
improves understandability and readability across the project context.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
improves understandability and readability across the project context.
improves understandability and readability across the project context and hence facilitates easier maintainability long-term.

?

# or `.saturating_sub(...)` to avoid unexpected runtime behavior or panics.
arithmetic_side_effects = "deny"
## lints related to readability of code
# enforce that references are cloned via eg. `Arc::clone` instead of `.clone()`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the advantage of enforcing this? maybe add a short rationale here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making it explicit that a reference is cloned, not the data that is referenced to (1:1 the reasoning clippy gives for the lint)

I can add this a short oneline reason though, thanks :)

Comment on lines 79 to 81
- Neutral: Might cause additional efforts when bringing in parts of existing
codebases into the context of OpenSOVD, but enforces those codebases to be on
par with the OpenSOVD expectations of clean & modern code.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I would argue here that it is inevitable that contributions from outside will adhere/be compliant to our coding guidelines (which we define for a reason) and hence are obliged to invest such efforts. As a result, such matter should not be a criterion here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm removing that section, as I agree with your sentiment.

### Defining a new set of common rules

With this option the idea is to take a look at what the CDA currently does and
set things that people deem to restrictive to optional with appropriate

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set things that people deem to restrictive to optional with appropriate
set things that people deem too restrictive to optional with appropriate

?
or what was meant exactly here?

Suggested change
set things that people deem to restrictive to optional with appropriate
set things that people deem to restrict to optional with appropriate

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh the first one, thanks! :)


- Good: potentially easier for new projects built upon existing codebases to
adapt to
- Negative: Could potentially lead to more fragmentation in regards to codestyle

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Negative: Could potentially lead to more fragmentation in regards to codestyle
- Negative: Could potentially lead to more fragmentation with regards to codestyle

Signed-off-by: Elena Gantner <elena.gantner@mercedes-benz.com>
@theswiftfox
Copy link
Author

Thanks for the feedback @stmuench :)
I updated the sections (hope I didn't miss anything)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants