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

docs: Add documentation for all cimple linters. #226

Merged
merged 1 commit into from
Dec 26, 2023

Conversation

iphydf
Copy link
Member

@iphydf iphydf commented Dec 26, 2023

This change is Reviewable

@iphydf iphydf added this to the v0.0.9 milestone Dec 26, 2023
@iphydf iphydf changed the title doc: Add documentation for all cimple linters. docs: Add documentation for all cimple linters. Dec 26, 2023
@iphydf iphydf marked this pull request as ready for review December 26, 2023 15:29
Copy link
Member

@robinlinden robinlinden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Some checks could maybe be replaced by clang-tidy at some point, but that's unrelated to the PR.

**Reason:** boolean returns using `bool` (or an `enum` type) are clearer than
ones returning an `int` that happens to only have 2 possible values.

## `-Wbooleans`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's good, but apparently it doesn't always trigger correctly. We have "*" enabled in clang-tidy, but I wrote this despite clang-tidy existing, being in use, and yet we had these. All linters written here are things we found that no other tool found, and thus wanted to fix everywhere.

**Reason:** compound literals aren't needed in initialisations. Without them,
the code is clearer.

## `-Wconstness`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy has https://clang.llvm.org/extra/clang-tidy/checks/misc/const-correctness.html which I think matches this check.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again I implemented this because clang-tidy didn't catch it, or not in the way we wanted it. I'll have a look at both of these to see if anything has improved since I did this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this one is newer than our clang-tidy version (14). I'll upgrade and see if it works.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it. I removed const here and ran only misc-const-correctness, and got no warnings. Let me know if I'm doing something wrong.

unexported implementation detail, and there is no compiler that can check
whether our declaration matches the implementation's definition.

## `-Wlarge-struct-params`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite:

The check is only applied to parameters of types that are expensive to copy which means they are not trivially copyable or have a non-trivial copy constructor or destructor.

All our types are trivially copyable. That doesn't mean they are cheap to copy.

stack overflows. Since we can't currently measure the size, we avoid any struct
passing altogether apart from some well-known exemptions.

## `-Wlogger-calls`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-Wformat-nonliteral could probably do this too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite. We actually want it to be a true string literal, not a thing composed of macros and strings and not a bunch of string literals concatenated.

@toktok-releaser toktok-releaser merged commit 231cece into TokTok:master Dec 26, 2023
11 checks passed
@robinlinden
Copy link
Member

I didn't know toktok-releaser merged even with unresolved conversations, but oh well.

@iphydf iphydf deleted the docs branch December 26, 2023 18:24
@iphydf
Copy link
Member Author

iphydf commented Dec 26, 2023

I didn't know toktok-releaser merged even with unresolved conversations, but oh well.

Fixed that. It won't do that again.

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

Successfully merging this pull request may close these issues.

3 participants