MCPcopy Index your code
hub / github.com/Tencent/CodeAnalysis / __get_linelength_param

Method __get_linelength_param

client/tool/cpplint.py:226–253  ·  view source on GitHub ↗

获取最大行长度参数 :param params: :return:

(self, params)

Source from the content-addressed store, hash-verified

224 return cmd_args
225
226 def __get_linelength_param(self, params):
227 """
228 获取最大行长度参数
229 :param params:
230 :return:
231 """
232 # 1. 从环境变量里获取
233 linelength = os.environ.get("CPPLINT_LINELENGTH", None)
234 if linelength:
235 return linelength
236
237 # 2. 从规则参数中获取
238 rule_list = params["rule_list"]
239 rule_params = None
240 # 找到linelength规则
241 for rule_info in rule_list:
242 if rule_info["name"] == "whitespace/line_length":
243 rule_params = rule_info["params"]
244 break
245 # 解析linelength规则参数
246 if rule_params:
247 rule_params = "[linelength]\r\n" + rule_params
248 rule_params_dict = ConfigReader(cfg_string=rule_params).read("linelength")
249 if "max" in rule_params_dict:
250 return rule_params_dict["max"]
251
252 # 3. 默认使用腾讯C++代码规范的行长度标准值
253 return "100"
254
255 def analyze(self, params):
256 """执行cpplint扫描任务

Callers 1

analyzeMethod · 0.95

Calls 3

ConfigReaderClass · 0.90
getMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected