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

Add custom clang-tidy check for fields that could be replaced by points #32852

Merged
merged 4 commits into from
Aug 2, 2019

Conversation

jbytheway
Copy link
Contributor

@jbytheway jbytheway commented Aug 2, 2019

Summary

SUMMARY: Infrastructure "Add static analysis check for fields that could be replaced by points"

Purpose of change

To help people use higher-level types in their code.

Describe the solution

This check looks for any struct or class containing two or three fields that look like they might be better replaced by a point or tripoint. It identifies them by examining the types and names. So, e.g. int foox, fooy; whould trigger this check.

Add this check and add suppressions for remaining cases triggering it.

I'm also fixing a couple of other random clang-tidy failures that have crept in recently.

Describe alternatives you've considered

There are other potential naming patterns that could be searched for. But this covered most of what seemed to exist in the codebase.

Additional context

It was by running this check that I discovered the code to be refactored for #32732, #32779, #32813, #32822, #32844, #32845. Now all that work is done I can add the check itself.

Next step is to do a similar check for function arguments to update APIs to take point arguments.

@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Code: Build Issues regarding different builds and build environments labels Aug 2, 2019
@ZhilkinSerg ZhilkinSerg merged commit 6e4bd90 into CleverRaven:master Aug 2, 2019
@jbytheway jbytheway deleted the xy_check branch August 2, 2019 16:53
misterprimus pushed a commit to misterprimus/Cataclysm-DDA that referenced this pull request Sep 21, 2019
…ts (CleverRaven#32852)

* Add clang-tidy check for structs with x,y members

* Suppress cata-xy warnings in various places

* Simplify boolean expression

* Remove redundant point initialization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Build Issues regarding different builds and build environments Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants