Skip to content

Introduce basic linting infrastructure#34

Merged
camio merged 29 commits intobemanproject:mainfrom
wusatosi:clang-format
Oct 15, 2024
Merged

Introduce basic linting infrastructure#34
camio merged 29 commits intobemanproject:mainfrom
wusatosi:clang-format

Conversation

@wusatosi
Copy link
Copy Markdown
Member

@wusatosi wusatosi commented Sep 27, 2024

Introduce pre-commit based linting infrastructure:

  • pre-commit formats extra white space, extra line at end-of-file, C++ files, and CMake files. It flags linting error for Markdown.
  • CI does not push formatted change to pr/ main branch.
  • Pre-commit is portable (even with clang-format) and does not pollute global scope, thus no virtual environment facing files (like requirements.txt) is included. This is tested with an empty GitHub Codespace.

Action Items:

Reference implementation: bemanproject/optional#52

  • Note that this PR diverges with reference implementation greatly:
  • There's less "hooks" (linting rules)
  • Uses different & updated tool chains
  • The .clang-format is copied from Optional 26 & net29 with no modification.

Closes: #29 .

struct identity {
// Returns `t`.
template <class T>
#if defined(__cpp_constexpr)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I realize this is just a formatting PR, but I'm wondering if we actually need this macro for Beman? This would imply support for something prior to c++11 which really isn't our aim here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes this is a formatting pr! I am just presenting a preview of the formatting that is going to be adopted.

This is a good point! There's also a macro test for __cpp_lib_transparent_operators at testing implying C++14.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yes, well I guess I could see some library want c++14 support, but 98 -- not really. I suggest we move the macro at 33 as a drive by fix on this PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's fair! After the weekly sync yesterday I think I will expand the scope of this pr out to be "Introduce general pre-commit + linting", haven't got around to updating the title and description, so I will need to work on this for a bit, I will open a separate pr specifically deleting this line.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok I'm good with that

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note that this implies C++14 as std::forward is constexpr after C++14 and (I don't think) constexpr can call non-constexpr function in 11.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

unadorned, cool new vocab for me!

I think I will actually hold creating a pr regarding this in hope of clang-tidy flagging it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

May be bundled into #38

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fix in #55

Comment thread src/beman/exemplar/identity.t.cpp
@wusatosi wusatosi changed the title Introduce clang-format Introduce basic linting infrastructure Oct 1, 2024
Comment thread .cmake-format.json Outdated
Comment thread .pre-commit-config.yaml
Comment thread .pre-commit-config.yaml Outdated
Comment thread .pre-commit-config.yaml Outdated
Comment thread .pre-commit-config.yaml Outdated
Comment thread .pre-commit-config.yaml Outdated
Comment thread .pre-commit-config.yaml Outdated
Comment thread .pre-commit-config.yaml Outdated
@wusatosi
Copy link
Copy Markdown
Member Author

wusatosi commented Oct 2, 2024

Besides updating README, all configuration should be done. Opening for comments and reviews.

@wusatosi wusatosi marked this pull request as ready for review October 2, 2024 18:50
Copy link
Copy Markdown
Member

@camio camio left a comment

Choose a reason for hiding this comment

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

This PR looks great to me.

I've used markdownlint-cli in the past and it worked well. It's the first time I've used gersemi to format CMake and while the output was surprising in a couple instances, the fact it is automated overshadows this.

I think this should be merged and our style czar @JeffGarland can provide an improved .clang-format later.

Our README.md should include instructions on pre-commit, but it should be clear that this is only for developers intending to make changes to this repository (those building for use elsewhere don't need it). The Carbon pre-commit instructions are fairly decent.

@wusatosi, let me know if you want me to merge this now (and leave documentation to another PR) or if I should hold off.

Comment thread .pre-commit-config.yaml Outdated
@wusatosi

This comment has been minimized.

Copy link
Copy Markdown
Member

@steve-downey steve-downey left a comment

Choose a reason for hiding this comment

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

👍

And I'd like to apply some of this to optional26 as well, soon.

Comment thread .pre-commit-config.yaml Outdated
@wusatosi
Copy link
Copy Markdown
Member Author

wusatosi commented Oct 14, 2024

Weird, pr actions are not triggered anymore. GitHub must be down or smt

GitHub was being GitHub...

@wusatosi
Copy link
Copy Markdown
Member Author

I don't think pre-commit's action's caching is working.
I have never seen it reuse the previous environment (always cache-miss).
I will keep an eye on this after the pr is merged and file an issue upstream later if needed.

@wusatosi
Copy link
Copy Markdown
Member Author

@camio This pr is ready to merge now, I don't want to block progress of #46 as we have overlapping config file.

I can file a separate pr to add documentation.

Copy link
Copy Markdown
Member

@steve-downey steve-downey left a comment

Choose a reason for hiding this comment

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

+1

@camio camio merged commit bd7ad35 into bemanproject:main Oct 15, 2024
@camio camio mentioned this pull request Dec 5, 2024
@camio camio mentioned this pull request Feb 27, 2025
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.

Define .clang-format or equivalent

5 participants