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

chore(transport): remove module_name_repetitions #2284

Open
mxinden opened this issue Dec 12, 2024 · 4 comments
Open

chore(transport): remove module_name_repetitions #2284

mxinden opened this issue Dec 12, 2024 · 4 comments
Labels
good first issue Good for newcomers p3 Backlog

Comments

@mxinden
Copy link
Collaborator

mxinden commented Dec 12, 2024

We allow the clippy lint module_name_repetitions:

#![allow(clippy::module_name_repetitions)] // This lint doesn't work here.

We e.g. prefix various types in the ecn module with Ecn:

/// The number of packets to use for testing a path for ECN capability.
pub const ECN_TEST_COUNT: usize = 10;
/// The number of packets to use for testing a path for ECN capability when exchanging
/// Initials during the handshake. This is a lower number than [`ECN_TEST_COUNT`] to avoid
/// unnecessarily delaying the handshake; we would otherwise double the PTO [`ECN_TEST_COUNT`]
/// times.
const ECN_TEST_COUNT_INITIAL_PHASE: usize = 3;
/// The state information related to testing a path for ECN capability.
/// See RFC9000, Appendix A.4.
#[derive(Debug, PartialEq, Clone, Copy)]
enum EcnValidationState {

As discussed in #2270 (comment), I suggest removing the allow and instead fix the module name repetition.

@mxinden mxinden added good first issue Good for newcomers p3 Backlog labels Dec 12, 2024
@mansf-osk
Copy link
Collaborator

I'll start working on this! Are there any places where we don't want to get rid of the module name repetitions? As far as I can see we allow them in a lot of modules, just going by this quick search.

Maybe it makes sense to remove the crate-wide allow attributes (as the one referenced above) and leave be or possibly add local allow's where it makes sense to keep the module name repetitions?

@mxinden
Copy link
Collaborator Author

mxinden commented Jan 3, 2025

@mansf-osk I suggest starting with a single module, e.g. neqo-transport/src/ecn.rs.

Small pull requests reduce the likelihood of merge conflicts and make reviewing easier.

Maybe it makes sense to remove the crate-wide allow attributes (as the one referenced above) and leave be or possibly add local allow's where it makes sense to keep the module name repetitions?

Happy for the crate-wide #![allow(clippy::module_name_repetitions)] to be replaced by the missing local allows with the first pull request.

@larseggert
Copy link
Collaborator

Just so I understand, we would rename e.g. EcnInfo to Ecn::Info, i.e. prefix with the module name? (Because otherwise Info is a bit generic.)

@mxinden
Copy link
Collaborator Author

mxinden commented Jan 4, 2025

It would be defined as:

// neqo-transport/src/ecn.rs

pub struct Info {
  // ...
}

and it would be used as:

// Some other file.

use ecn;

fn my_func() {
  let ecn_info = ecn::Info::new();
}

Just like in the standard library where it is std::io::Error and not std::io::IoError.

Does that make sense @larseggert?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers p3 Backlog
Projects
None yet
Development

No branches or pull requests

3 participants