Skip to content

ci: handle checpatch warnings as errors and increase line limit to 100 #30427

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

Merged
merged 2 commits into from
Jan 14, 2021

Conversation

nashif
Copy link
Member

@nashif nashif commented Dec 3, 2020

Fail CI if we have both errors and warnings.

Fixes #29960
Closes #30426

Signed-off-by: Anas Nashif [email protected]

Fail CI if we have both errors and warnings.

Signed-off-by: Anas Nashif <[email protected]>
Change max line length to 100, this is to follow Linux and to allow for
more readable code. Most warning we get now from checkpatch are because
of this limit which has prevented us from enforcing warning.

Signed-off-by: Anas Nashif <[email protected]>
@github-actions github-actions bot added the area: API Changes to public APIs label Dec 3, 2020
@nashif nashif force-pushed the checkpatch_enforce_warnings branch from 0b66927 to 4388358 Compare December 4, 2020 13:23
@nashif nashif marked this pull request as ready for review December 4, 2020 13:26
Copy link
Collaborator

@pabigot pabigot left a comment

Choose a reason for hiding this comment

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

Based on previous history in #27469 (comment) I think the line length change should be pulled out and handled separately. But I won't block this for that reason alone.

I don't object to making certain warnings errors if that causes the checkpatch part of compliance to go red, as long as it's understood that we're still going to have PRs that need to be merged with checkpatch errors where the diagnostic is simply irrelevant, and the reviewers and mergers will have to be careful to handle those exceptions consistently.

@nashif
Copy link
Member Author

nashif commented Dec 4, 2020

Based on previous history in #27469 (comment) I think the line length change should be pulled out and handled separately. But I won't block this for that reason alone.

This is all related and should be done the same time IMO, the main reason warnings are not failing CI right now is because of max line length.

@nashif nashif self-assigned this Dec 4, 2020
@nashif nashif requested a review from cvinayak December 4, 2020 21:39
Copy link
Contributor

@mbolivar-nordic mbolivar-nordic left a comment

Choose a reason for hiding this comment

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

Does this checkpatch configuration file treat complex macros without a do { ... } while (0) as warnings?

If so, it will do the wrong thing in some cases and error out when it should be ignored. E.g. soc/riscv/openisa_rv32m1/soc_offsets.h has a GEN_SOC_OFFSET_SYMS definition that can't be wrapped with a do/while.

@nashif
Copy link
Member Author

nashif commented Dec 5, 2020

Does this checkpatch configuration file treat complex macros without a do { ... } while (0) as warnings?

If so, it will do the wrong thing in some cases and error out when it should be ignored. E.g. soc/riscv/openisa_rv32m1/soc_offsets.h has a GEN_SOC_OFFSET_SYMS definition that can't be wrapped with a do/while.

we probably should just consider disabling the COMPLEX_MACRO warning in the configuration file and stop the many false positives we get. Right now they are being ignored anyways.

@pabigot
Copy link
Collaborator

pabigot commented Dec 5, 2020

we probably should just consider disabling the COMPLEX_MACRO warning in the configuration file and stop the many false positives we get. Right now they are being ignored anyways.

Also MULTISTATEMENT_MACRO_USE_DO_WHILE since that's wrong when the macros produce declarations, and TRAILING_SEMICOLON in similar circumstances.

LINE_SPACING generates diagnostics for things like static K_FOO_DEFINE() obj in a function when another declaration immediately precedes it, and SPACING when using declaring int useful(FILE* stream, ...) because it sees a multiplication expression.

This is a slippery slope. Maybe we should just throw out checkpatch.

@nashif
Copy link
Member Author

nashif commented Dec 7, 2020

Also MULTISTATEMENT_MACRO_USE_DO_WHILE since that's wrong when the macros produce declarations, and TRAILING_SEMICOLON in similar circumstances.

LINE_SPACING generates diagnostics for things like static K_FOO_DEFINE() obj in a function when another declaration immediately precedes it, and SPACING when using declaring int useful(FILE* stream, ...) because it sees a multiplication expression.

This is a slippery slope. Maybe we should just throw out checkpatch.

quick grep shows that checkpatch has 140 warnings and 47 errors, we right now ignore the 140 warnings and just enforce the errors.

It is not a slippery slope if we are decisive about certain rules and either remove them completely because they do not apply or fix them if that make sense. However, having a rule that we always have to override and that would confuse contributors and delay processing of PRs is the slippery slope we have to deal with.

checkpatch is not some type of holy book we have to follow and adhere to every rule, we have to be able to make "smart" decisions based on the nature of our code base and not how this works in Linux.

If we are to enforce warnings in CI then the most frequent and "annoying" warning going to be the line length, also because we have not enforce it for years, so all of the sudden EVERY change will fail.

again, there is nothing wrong with disabling some rules that are inconsistent and cause confusing and almost always require us to override.

@cvinayak
Copy link
Collaborator

cvinayak commented Dec 8, 2020

My approval is not required for the changes in this PR, as I am not an expert in these checks/scripts.

Copy link
Member

@carlescufi carlescufi left a comment

Choose a reason for hiding this comment

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

Let's get this in. @nashif I'd appreciate if you'd send an email to the mailing list informing of the policy change after this is merged.

@nashif nashif added the DNM This PR should not be merged (Do Not Merge) label Jan 14, 2021
@nashif
Copy link
Member Author

nashif commented Jan 14, 2021

looking into removing some very common and irrelevant warnings before we merge.

@nashif nashif removed the DNM This PR should not be merged (Do Not Merge) label Jan 14, 2021
@nashif nashif merged commit 384ad9c into zephyrproject-rtos:master Jan 14, 2021
@nashif nashif deleted the checkpatch_enforce_warnings branch January 14, 2021 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Changes to public APIs
Projects
None yet
6 participants