nodejs/node

[C++ Lint Rule] #define indentation is Inconsistent

Open

#28,605 创建于 2019年7月9日

在 GitHub 查看
 (4 评论) (1 反应) (0 负责人)JavaScript (35,535 fork)batch import
c++help wantedstale

仓库指标

Star
 (117,218 star)
PR 合并指标
 (平均合并 18天 17小时) (30 天内合并 219 个 PR)

描述

I was recently going through the source code, trying to familiarize myself with the codebase, and I noticed that there's no consistent rule for how #defines are indented.

For example, in node_main.cc, there's no indentation at all in this #ifdef block.

However, in other places, like node.h, there's a space between the # and the define to indicate a kind of indentation.

There also seems to be inconsistency with how many spaces/tabs should go after the #define variable name and the value, as seen here.

Can we come up with a rule for this and add it to the C++ Style Guide? Maybe even add a rule to the linter?

To get started with the rules we can to define, some questions are:

  1. Should #defines inside of braces be indented?
  2. When should #ifdef X be used vs. if defined(X)?
  3. What should the indentation pattern be for #define/#ifdef/#if defined/#ifndef?

贡献者指南