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

tools: add clang-tidy rule in src #26840

Closed
wants to merge 1 commit into from

Conversation

gengjiawen
Copy link
Member

@gengjiawen gengjiawen commented Mar 21, 2019

In short

  • make cpp check rules explicit and get checked by CI
  • select the rules most collaborators are comfortable with

Todo

Tools to ensure the rules

@refack told me some rules are checked.
Basically the rules should check most operating systems because we have platform-specific code such as using macro.
And should keep clang-tidy in same version when possible.
I have some thought on docker get involved in this. Hopefully I can put my thought
in node\build group this weekends.

Google Cpp Guideline

Related to #24315.
clang-tidy can handle some google cpp guideline rules.
I don't know should we

Rules need to be select.

The rules now included are already applied or in-review.

How to deal with false positive and make exceptions

.

cc @addaleax @bnoordhuis @refack @joyeecheung @jasnell @richardlau @danbev @Trott @BridgeAR

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Mar 21, 2019
src/.clang-tidy Outdated Show resolved Hide resolved
src/.clang-tidy Outdated Show resolved Hide resolved
@gengjiawen gengjiawen changed the title [WIP]src: add clang-tidy rule in src [WIP]tools: add clang-tidy rule in src Mar 21, 2019
@refack
Copy link
Contributor

refack commented Mar 22, 2019

@refack told me some rules are checked.

What I was referring to is V8's rule set.
But with @gengjiawen's help I've made https://ci.nodejs.org/job/node-clang-tidy/ to run for our code.

CI for this: https://ci.nodejs.org/job/node-clang-tidy/5/console
Result in https://gist.github.com/refack/ce2d10f8364a539c5da3314a777bee3e

src/.clang-tidy Outdated Show resolved Hide resolved
@gengjiawen gengjiawen changed the title [WIP]tools: add clang-tidy rule in src tools: add clang-tidy rule in src Apr 12, 2019
@BridgeAR
Copy link
Member

What's the status here?

@gengjiawen
Copy link
Member Author

What's the status here?

Need to change some rules in my side. Not know the progress in CI setup ? @refack

@refack
Copy link
Contributor

refack commented Apr 16, 2019

Let's see https://ci.nodejs.org/job/node-clang-tidy/6/
[Update:] 70844 warnings and 37 errors generated.

BTW: Apparently there a more comprehensive wrapper around LLVM's LibTooling - clang-check. Locally it gives me less false-positives.

@gengjiawen
Copy link
Member Author

I update the rules to disable performance-unnecessary-value-param since it's partial applied and enable modernize-deprecated-headers since it's fixed.

Also not quite sure modernize-use-equals-default are used since it's not introduced.
@refack Rerun node-clang-tidy ?

@refack
Copy link
Contributor

refack commented Apr 16, 2019

It's in the queue and will soon show up as https://ci.nodejs.org/job/node-clang-tidy/7/

@gengjiawen
Copy link
Member Author

Rebase after the four PRs got merged.
#27280
#27279
#27264
#27263

@refack
Copy link
Contributor

refack commented Apr 24, 2019

Rebased over #27264
https://ci.nodejs.org/job/node-clang-tidy/10/console

Filtered results https://gist.github.com/refack/8490362a2dd0dabb444a9e9f3ea1bd98

@gengjiawen
Copy link
Member Author

Rebased over #27264
ci.nodejs.org/job/node-clang-tidy/10/console

Filtered results gist.github.com/refack/8490362a2dd0dabb444a9e9f3ea1bd98

I rebased and some fix for the left. Can you trigger this task again ?

@gengjiawen gengjiawen force-pushed the clang-format-src branch 3 times, most recently from 18393d9 to cebebf0 Compare April 29, 2019 15:25
@gengjiawen
Copy link
Member Author

Revert node-url change for https://travis-ci.com/nodejs/node/jobs/196150407#L3090

../src/node_url.cc: In destructor ‘node::url::{anonymous}::URLHost::~URLHost()’:
../src/node_url.cc:123:19: error: use of deleted function ‘node::url::{anonymous}::URLHost::Value::~Value()’
 URLHost::~URLHost() {
                   ^
../src/node_url.cc:82:5: note: ‘node::url::{anonymous}::URLHost::Value::~Value()’ is implicitly deleted because the default definition would be ill-formed:
     ~Value() = default;

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

Nice, LGTM!

@gengjiawen
Copy link
Member Author

@refack Need to retrigger the Jenkins task.

@gengjiawen
Copy link
Member Author

@refack ping

@BridgeAR
Copy link
Member

@gengjiawen is there something you have to wait upon to land this besides rebasing?

@gengjiawen
Copy link
Member Author

@gengjiawen is there something you have to wait upon to land this besides rebasing?

This can land. But @refack works on a Jenkins job can make sure the rules checks on CI.
I guess we can land it, save CI job for later.

@richardlau
Copy link
Member

@gengjiawen is there something you have to wait upon to land this besides rebasing?

This can land. But @refack works on a Jenkins job can make sure the rules checks on CI.
I guess we can land it, save CI job for later.

I ran the job with default parameters and it failed: https://ci.nodejs.org/job/node-clang-tidy/12/console
Given we don't currently run this on the CI maybe this is a candidate for running as a GitHub action?

@gengjiawen
Copy link
Member Author

I ran the job with default parameters and it failed: ci.nodejs.org/job/node-clang-tidy/12/console
Given we don't currently run this on the CI maybe this is a candidate for running as a GitHub action?

Sure. But I am not familiar with related cpp tools. I am thinking landing this change first, thoughts ?

@richardlau
Copy link
Member

I ran the job with default parameters and it failed: ci.nodejs.org/job/node-clang-tidy/12/console
Given we don't currently run this on the CI maybe this is a candidate for running as a GitHub action?

Sure. But I am not familiar with related cpp tools. I am thinking landing this change first, thoughts ?

I don't use clang nor clang-tidy so I have no opinion on the rules.

@gengjiawen
Copy link
Member Author

Force push to resolve conflict.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@gengjiawen gengjiawen added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jan 9, 2020
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot
Copy link
Collaborator

@Trott
Copy link
Member

Trott commented Jan 12, 2020

Landed in a42dcbe

Trott pushed a commit that referenced this pull request Jan 12, 2020
PR-URL: #26840
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rich Trott <rtrott@gmail.com>
@Trott Trott closed this Jan 12, 2020
MylesBorins pushed a commit that referenced this pull request Jan 16, 2020
PR-URL: #26840
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rich Trott <rtrott@gmail.com>
@codebytere codebytere mentioned this pull request Jan 16, 2020
codebytere pushed a commit that referenced this pull request Mar 14, 2020
PR-URL: #26840
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rich Trott <rtrott@gmail.com>
codebytere pushed a commit that referenced this pull request Mar 17, 2020
PR-URL: #26840
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rich Trott <rtrott@gmail.com>
@codebytere codebytere mentioned this pull request Mar 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants