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

ci: Add clang-tidy to CI #95

Closed
wants to merge 1 commit into from
Closed

ci: Add clang-tidy to CI #95

wants to merge 1 commit into from

Conversation

juan-lunarg
Copy link
Contributor

closes #76

Copy link
Collaborator

@charles-lunarg charles-lunarg left a comment

Choose a reason for hiding this comment

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

Looks like the minimal changes needed to make clang-tidy work and fix all the naming violations.

If this somehow gets merged before format utils, I better rebase and fix any incipient errors

}

std::string FormatString(const char *message, ...) {
std::size_t const STRING_BUFFER(4096);
std::size_t const string_buffer(4096);
Copy link
Collaborator

Choose a reason for hiding this comment

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

string_buffer is a confusing name since its the length of the buffer, not the buffer itself.

Copy link
Contributor

@christophe-lunarg christophe-lunarg left a comment

Choose a reason for hiding this comment

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

I am personnally not in favour of such changes. C.I. making more checks that on local system by default is hunting productivity. And if to increase productivity we need to use the flag, then the flag should be on my default.

Do we have in order already the -WERROR things on repo? Meaning that if C.I. is using it, we should use in by default on our system.

This case is already pretty painful to me, I don't want to deal with another case like this that in this end provide little value expect avoiding pedentic disucssions in code reviews.

Personnally I think that if we add such things, this should be discuss in engineering meetings with the team.


### clang-tidy

By default clang-tidy checking is disabled by default.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it disabled by default? It seems much better for me to hit issues on my system than on C.I., consume more C.I. resource and have to iterate, taking more development time. This is especially true that I don't see how the developer would even now what the rules are.

I would argu the same with VUL_WERROR being OFF by default.

I think we need to be more consious when we add new checks how this is going to affect the developers productivity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's off by default to avoid issues with package managers, machines that don't have clang-tidy installed by default, FetchContent/add_subdirectory users, etc.

Having it on by default is more complicated than having it on. That's just the way it is with open source projects.

@@ -150,17 +150,17 @@ std::filesystem::path LayerSettings::FindSettingsFile() {
LSTATUS err = RegOpenKeyEx(hives[hive_index], TEXT("Software\\Khronos\\Vulkan\\Settings"), 0, KEY_READ, &key);
if (err == ERROR_SUCCESS) {
TCHAR name[2048];
DWORD i = 0, name_size, type, pValues, value_size;
DWORD i = 0, name_size, type, p_values, value_size;
Copy link
Contributor

Choose a reason for hiding this comment

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

I have never seen this convention before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I grabbed the clang-tidy file from the vulkan validation layers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no preference tbh. Just a matter of changing the clang-tidy file.

- { key: readability-identifier-naming.VariableCase, value: lower_case }

@juan-lunarg
Copy link
Contributor Author

Why is it disabled by default?

Another reason to also have it disabled by default is because if your IDE registers .clang-tidy files. (Visual Studio Code, Visual Studio, and many other IDEs do). Is that it will pointlessly eat up build time. Since you can just fix the clang-tidy issues in your IDE.

I've looked at various other repos that have implemented clang-tidy and this seems to be the convention from what I can gather.

Personnally I think that if we add such things, this should be discuss in engineering meetings with the team.

Understood. This has been brought up multiple times in VVL meetings. It's a lot harder to implement on an existing codebase however. Since it would require a lot of fixes. The thought process was to get it working on a newer repo to iron the kinks in the workflow.

little value expect avoiding pedentic disucssions in code reviews.

As you said. The main intent behind clang-tidy is to enforce a style guide essentially. It's very flexible/powerful.

However, it does more than just style checking. It provides performance static analysis checks, security checks, etc.

@juan-lunarg
Copy link
Contributor Author

To be clear. I do understand the annoyance of adding more checks. But overall I thinks it's better for the health of the multiple code bases we have to manage.

@juan-lunarg
Copy link
Contributor Author

I've got a better idea that would go more smoothly. Closing this PR.

@juan-lunarg juan-lunarg closed this Sep 7, 2023
@juan-lunarg juan-lunarg deleted the juan/clang_tidy branch September 7, 2023 15:06
if(NOT CLANG_TIDY)
message(FATAL_ERROR "clang-tidy not found!")
endif()
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY}")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

CMAKE_<LANG>_CLANG_TIDY only works on the makefile / ninja generator.

Given how popular the visual studio generator is within our team this is likely only going to cause confusion.

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.

Run clang-tidy on header files that we ship
3 participants