-
Notifications
You must be signed in to change notification settings - Fork 45
linter: add cpplint #47
base: main
Are you sure you want to change the base?
Conversation
so I have added the cpplint.py to run the python suite that node.js use: https://github.com/nodejs/node/blob/master/tools/cpplint.py |
I wonder if there is any reason not to use |
Having had a local discussion about this I think the concern was that clang-format wouldn't be available when running citgm builds. (I'd be happy with something that a developer just ran before creating a PR personally but I can see why other people want to integrate it into builds.) I think the main concern with this pull request at the moment is cpplint.py is 6153 lines long as it's copied from Node.js it's likely to get out of sync. |
I think ideally we want an npm module we can just have as a devDependency, one that can automatically fix stuff would be great. Not sure if there are any good ones though. |
My main objection to @gdams Where is this version of |
This PR adds cpplint to linter all the c/c++ files. It can be run from `npm test` or directly from `npm run lint`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rebase on top of master now that #52 has landed?
@@ -1,5 +1,6 @@ | |||
#include "node_report.h" | |||
// Copyright 2017 Nodereport |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any thoughts on what the copyright attribution should be? @nodejs/post-mortem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasnell you may be bringing all Node.js src copyright statements into alignment with legal requirements, opinions on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll et @jasnell confirm but I think it should be:
// Copyright node-report contributors. All rights reserved.
// SPDX-License-Identifier: MIT
in line with https://github.com/nodejs/node/pull/10599/files as these are "new" files that were never under the joyent copyright.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there was also some discussion about removing the All rights reserved
from that.
locations won't see bogus errors. | ||
""" | ||
fullname = self.FullName() | ||
# XXX(bnoordhuis) Expects that cpplint.py lives in the tools/ directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like cpplint.py should be in a tools/ directory. Can you move it?
I've had trouble getting clang-format installed when we used it once before for formatting checking. IIRC, it also had continuously changing formats, so you needed the exact correct version installed. The pain outweighed the gain. This PR LGTM, except that the copyright header comments don't refer to anyone who can hold copyright... does the linter require them? |
"test": "tap test/test*.js" | ||
"test": "npm run lint && npm run tap", | ||
"tap": "tap --timeout 10 test/test*.js", | ||
"lint": "python cpplint.py **/*.cc **/*.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, just realized, this should be:
"test": "tap --timeout 10 test/test*.js",
"pretest": "python cpplint.py **/*.cc **/*.h"
And the tap timeout change is unrelated to this PR, shouldn't it be a different PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have that as pretest? It means that you can't just do npm run lint
to lint your code.
This PR adds cpplint to linter all the c/c++ files. It can be run from
npm test
or directly fromnpm run lint
. There are still a few linter errors which I have included below: