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

Custom linter: References should always be const #70

Open
MonsterDruide1 opened this issue Jun 6, 2024 · 4 comments
Open

Custom linter: References should always be const #70

MonsterDruide1 opened this issue Jun 6, 2024 · 4 comments

Comments

@MonsterDruide1
Copy link
Owner

I haven't seen a non-const reference around anywhere yet, non-const objects are handled with pointers instead. So the linter should complain when a non-const T& is seen around, because it is most likely wrong and should either be a pointer T*, or const T&.

@LynxDev2
Copy link
Contributor

While trying to fix this I noticed that there are a lot of non-const auto& in iterator for loops used in this project. Should this also apply to them?

@MonsterDruide1
Copy link
Owner Author

Good point - no, those should not be affected, as some of those require mutable references (e.g. ByamlWriterBigDataList::setOffset).

@LynxDev2
Copy link
Contributor

Should I skip this check for all auto references since they include the constness from the return type or should I only skip it for iterator for loops?

@MonsterDruide1
Copy link
Owner Author

Do not skip it for anything else. The idea is that we want to make the auto more "verbose" by extracting those additional qualifiers (like & and const). For loops, it has to be a non-const reference, so there is no other way to write it than auto& (or auto, but that violates the "more verbose" goal). Anything else that can take a const reference should also explicitly state const.

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

2 participants