GyulyVGC / sniffnet

Comfortably monitor your Internet traffic 🕵️‍♂️
https://sniffnet.net
Apache License 2.0
14.41k stars 439 forks source link

clippy: apply missing_const_for_fn lint #523

Closed CosminPerRam closed 2 months ago

CosminPerRam commented 2 months ago

This PR applies the missing_const_for_fn lint and also adds it to the CI.

Technically the majority of them should be already optimized away, but if they can be const, should they be const?

I also found 3 instances of translations functions having per item .to_string() instead of on the entire match block and a single translation function call that was cloned unnecessarily.

GyulyVGC commented 2 months ago

As mentioned in the same lint page you linked:

Const functions are currently still being worked on, with some features only being available on nightly. This lint does not consider all edge cases currently and the suggestions may be incorrect if you are using this lint on stable.

In general I think that's better to rely on the lints included by default in clippy warnings, since they are the ones considered to be more stable and impactful.

I'm also used to run quite often clippy pedantic, and not even that includes this specific lint.

I prefer waiting until this is stabilised.

Thanks anyway for your effort!

CosminPerRam commented 2 months ago

Well, we don't have to add that lint to CI, but other than that, the changes are there to be added.

GyulyVGC commented 2 months ago

Yeah, as you say I don't think it'd be an issue to merge these changes, but since the official docs themselves warn that suggestions may be incorrect, I prefer waiting the stabilisation of the lint to be sure to apply it only where really necessary.