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

Code formatting with rustfmt.toml config #5684

Open
kamuik16 opened this issue Nov 21, 2024 · 1 comment
Open

Code formatting with rustfmt.toml config #5684

kamuik16 opened this issue Nov 21, 2024 · 1 comment

Comments

@kamuik16
Copy link
Contributor

Description

We can add a rustfmt.toml file to the repo and use some of the nightly features like

reorder_imports  = true
imports_granularity = "Crate"
format_code_in_doc_comments = true

Read more about these configs in here.

Motivation

Highly improved code formatting and readability.
Formatting imports.
Formatting the code in doc as well.
Example: reth - rustfmt.toml

Current Implementation

This:

pub use self::behaviour::{Behaviour, Event, MessageAuthenticity};
pub use self::config::{Config, ConfigBuilder, ValidationMode, Version};
pub use self::error::{ConfigBuilderError, PublishError, SubscriptionError, ValidationError};
pub use self::metrics::Config as MetricsConfig;
pub use self::peer_score::{
    score_parameter_decay, score_parameter_decay_with_base, PeerScoreParams, PeerScoreThresholds,
    TopicScoreParams,
};
pub use self::subscription_filter::{
    AllowAllSubscriptionFilter, CallbackSubscriptionFilter, CombinedSubscriptionFilters,
    MaxCountSubscriptionFilter, RegexSubscriptionFilter, TopicSubscriptionFilter,
    WhitelistSubscriptionFilter,
};
pub use self::topic::{Hasher, Topic, TopicHash};
pub use self::transform::{DataTransform, IdentityTransform};
pub use self::types::{Message, MessageAcceptance, MessageId, RawMessage};

will look like this:

pub use self::{
    behaviour::{Behaviour, Event, MessageAuthenticity},
    config::{Config, ConfigBuilder, ValidationMode, Version},
    error::{ConfigBuilderError, PublishError, SubscriptionError, ValidationError},
    metrics::Config as MetricsConfig,
    peer_score::{
        score_parameter_decay, score_parameter_decay_with_base, PeerScoreParams,
        PeerScoreThresholds, TopicScoreParams,
    },
    subscription_filter::{
        AllowAllSubscriptionFilter, CallbackSubscriptionFilter, CombinedSubscriptionFilters,
        MaxCountSubscriptionFilter, RegexSubscriptionFilter, TopicSubscriptionFilter,
        WhitelistSubscriptionFilter,
    },
    topic::{Hasher, Topic, TopicHash},
    transform::{DataTransform, IdentityTransform},
    types::{Message, MessageAcceptance, MessageId, RawMessage},
};

This is just one of the example across repo.

Are you planning to do it yourself in a pull request ?

Yes

@kamuik16
Copy link
Contributor Author

Curios to know the opinions of the maintainers here :)

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

No branches or pull requests

1 participant