MCPcopy Create free account
hub / github.com/catboost/catboost / check_file

Function check_file

tools/cpp_style_checker/wrapper.py:48–63  ·  view source on GitHub ↗
(clang_format_binary, style_config_path, filename)

Source from the content-addressed store, hash-verified

46
47
48def check_file(clang_format_binary, style_config_path, filename):
49 with open(filename, "rb") as f:
50 actual_source = f.read()
51
52 skip_reason = rules.get_skip_reason(filename, actual_source, skip_links=False)
53 if skip_reason:
54 return reporter.LintStatus.SKIPPED, "Style check is omitted: {}".format(skip_reason)
55
56 command = [clang_format_binary, '-assume-filename=' + filename, '-style=file:' + style_config_path]
57 styled_source = subprocess.check_output(command, input=actual_source)
58
59 if styled_source == actual_source:
60 return reporter.LintStatus.GOOD, ""
61 else:
62 diff = make_diff(actual_source, styled_source)
63 return reporter.LintStatus.FAIL, diff
64
65
66def make_diff(left, right):

Callers 1

mainFunction · 0.85

Calls 4

make_diffFunction · 0.85
openFunction · 0.50
readMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected