Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename field mod::common::contexts::torrent::responses::Category::category_id to id to avoid Clippy error #388

Closed
josecelano opened this issue Nov 15, 2023 · 1 comment · Fixed by #502
Assignees
Labels
- Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat
Milestone

Comments

@josecelano
Copy link
Member

Clippy lints: https://rust-lang.github.io/rust-clippy/master/index.html#/struct_field_names

This is the current code:

#[rustversion::stable]
#[derive(Deserialize, PartialEq, Debug)]
pub struct Category {
    pub category_id: CategoryId, // todo: rename to `id`
    pub name: String,
    pub num_torrents: u64,
}

#[rustversion::nightly]
#[derive(Deserialize, PartialEq, Debug)]
#[allow(clippy::struct_field_names)]
pub struct Category {
    pub category_id: CategoryId, // todo: rename to `id`
    pub name: String,
    pub num_torrents: u64,
}

The field category_id should not be prefixed with the struct name.

NOTICE: the frontend type is also using the same name. So It must also be refactored there.

@josecelano josecelano added Code Cleanup / Refactoring Tidying and Making Neat - Developer - Torrust Improvement Experience labels Nov 15, 2023
@josecelano
Copy link
Member Author

@da2ce7 told me you can use the clippy #[allow(unknown_lints)] attribute so we could have done:

#[allow(unknown_lints)]
#[derive(Deserialize, PartialEq, Debug)]
pub struct Category {
    pub category_id: CategoryId, // todo: rename to `id`
    pub name: String,
    pub num_torrents: u64,
}

We are using it on the tracker.

josecelano added a commit to josecelano/torrust-index that referenced this issue Jan 3, 2024
@cgbosse cgbosse moved this to Maintenance in Torrust Solution Jan 10, 2024
@cgbosse cgbosse added this to the v3.0.0 milestone Jan 16, 2024
@josecelano josecelano self-assigned this Feb 27, 2024
@josecelano josecelano linked a pull request Feb 27, 2024 that will close this issue
@github-project-automation github-project-automation bot moved this from Maintenance to Done in Torrust Solution Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants