forked from cvmfs/cvmfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpplint.py.cvmfs-patch
146 lines (139 loc) · 7.3 KB
/
cpplint.py.cvmfs-patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
diff --git a/cpplint.py b/cpplint.py
index 8158eb7..ab838e8 100755
--- a/cpplint.py
+++ b/cpplint.py
@@ -379,6 +379,14 @@ _LEGACY_ERROR_CATEGORIES = [
# tools which also use the NOLINT syntax, e.g. clang-tidy.
_OTHER_NOLINT_CATEGORY_PREFIXES = [
'clang-analyzer',
+ 'clang-tidy',
+ 'bugprone-branch-clone',
+ 'performance-no-int-to-ptr',
+ 'cert-oop54-cpp',
+ 'bugprone-unhandled-self-assignment',
+ 'bugprone-sizeof-expression',
+ 'bugprone-branch-clone',
+ 'misc-unconventional-assign-operator',
]
# The default state of the category filter. This is overridden by the --filter=
@@ -766,7 +774,7 @@ _TYPES = re.compile(
# uppercase character, such as Python.h or nsStringAPI.h, for example).
# - Lua headers.
_THIRD_PARTY_HEADERS_PATTERN = re.compile(
- r'^(?:[^/]*[A-Z][^/]*\.h|lua\.h|lauxlib\.h|lualib\.h)$')
+ r'^(?:[^/]*[A-Z][^/]*\.h|lua\.h|lauxlib\.h|lualib\.h|cvmfs_config\.h|sys/xattr\.h|gtest/gtest\.h|benchmark/benchmark\.h|cvmfs/testdoc\.h|cvmfs/testdoc\.cc)$')
# Pattern for matching FileInfo.BaseName() against test file name
_test_suffixes = ['_test', '_regtest', '_unittest']
@@ -2270,11 +2278,11 @@ def CheckForCopyright(filename, lines, error):
# We'll say it should occur by line 10. Don't forget there's a
# placeholder line at the front.
for line in xrange(1, min(len(lines), 11)):
- if re.search(r'Copyright', lines[line], re.I): break
+ if re.search(r'This file is part of the CernVM File System', lines[line], re.I): break
else: # means no copyright line was found
error(filename, 0, 'legal/copyright', 5,
- 'No copyright message found. '
- 'You should have a line: "Copyright [year] <Copyright Owner>"')
+ 'No cvmfs ownerhip tag found. '
+ 'You should have a line: "This file is part of the CernVM File System"')
def GetIndentLevel(line):
@@ -4286,7 +4294,7 @@ def CheckBraces(filename, clean_lines, linenum, error):
# following line if it is part of an array initialization and would not fit
# within the 80 character limit of the preceding line.
prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0]
- if (not Search(r'[,;:}{(]\s*$', prevline) and
+ if (not Search(r'[,;:}{()t>]\s*$', prevline) and
not Match(r'\s*#', prevline) and
not (GetLineWidth(prevline) > _line_length - 2 and '[]' in prevline)):
error(filename, linenum, 'whitespace/braces', 4,
@@ -4306,12 +4314,12 @@ def CheckBraces(filename, clean_lines, linenum, error):
# find the ( after the if
pos = line.find('else if')
pos = line.find('(', pos)
- if pos > 0:
- (endline, _, endpos) = CloseExpression(clean_lines, linenum, pos)
- brace_on_right = endline[endpos:].find('{') != -1
- if brace_on_left != brace_on_right: # must be brace after if
- error(filename, linenum, 'readability/braces', 5,
- 'If an else has a brace on one side, it should have it on both')
+ #if pos > 0:
+ # (endline, _, endpos) = CloseExpression(clean_lines, linenum, pos)
+ # brace_on_right = endline[endpos:].find('{') != -1
+ # if brace_on_left != brace_on_right: # must be brace after if
+ # error(filename, linenum, 'readability/braces', 5,
+ # 'If an else has a brace on one side, it should have it on both')
elif Search(r'}\s*else[^{]*$', line) or Match(r'[^}]*else\s*{', line):
error(filename, linenum, 'readability/braces', 5,
'If an else has a brace on one side, it should have it on both')
@@ -4879,7 +4887,8 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state,
# if(match($0, " <<")) complain = 0;
# if(match(prev, " +for \\(")) complain = 0;
# if(prevodd && match(prevprev, " +for \\(")) complain = 0;
- scope_or_label_pattern = r'\s*(?:public|private|protected|signals)(?:\s+(?:slots\s*)?)?:\s*\\?$'
+ #scope_or_label_pattern = r'\s*(?:public|private|protected|signals)(?:\s+(?:slots\s*)?)?:\s*\\?$'
+ scope_or_label_pattern = r'\s*\w+\s*:\s*\\?$'
classinfo = nesting_state.InnermostClass()
initial_spaces = 0
cleansed_line = clean_lines.elided[linenum]
@@ -5103,12 +5112,12 @@ def CheckIncludeLine(filename, clean_lines, linenum, include_state, error):
#
# We also make an exception for Lua headers, which follow google
# naming convention but not the include convention.
- match = Match(r'#include\s*"([^/]+\.(.*))"', line)
- if match:
- if (IsHeaderExtension(match.group(2)) and
- not _THIRD_PARTY_HEADERS_PATTERN.match(match.group(1))):
- error(filename, linenum, 'build/include_subdir', 4,
- 'Include the directory when naming header files')
+ #match = Match(r'#include\s*"([^/]+\.(.*))"', line)
+ #if match:
+ # if (IsHeaderExtension(match.group(2)) and
+ # not _THIRD_PARTY_HEADERS_PATTERN.match(match.group(1))):
+ # error(filename, linenum, 'build/include_subdir', 4,
+ # 'Include the directory when naming header files')
# we shouldn't include a file more than once. actually, there are a
# handful of instances where doing so is okay, but in general it's
@@ -5460,18 +5469,18 @@ def CheckGlobalStatic(filename, clean_lines, linenum, error):
# and functions at the same time would decrease accuracy of
# matching identifiers.
# string Class::operator*()
- if (match and
- not Search(r'\bstring\b(\s+const)?\s*[\*\&]\s*(const\s+)?\w', line) and
- not Search(r'\boperator\W', line) and
- not Match(r'\s*(<.*>)?(::[a-zA-Z0-9_]+)*\s*\(([^"]|$)', match.group(4))):
- if Search(r'\bconst\b', line):
- error(filename, linenum, 'runtime/string', 4,
- 'For a static/global string constant, use a C style string '
- 'instead: "%schar%s %s[]".' %
- (match.group(1), match.group(2) or '', match.group(3)))
- else:
- error(filename, linenum, 'runtime/string', 4,
- 'Static/global string variables are not permitted.')
+ #if (match and
+ # not Search(r'\bstring\b(\s+const)?\s*[\*\&]\s*(const\s+)?\w', line) and
+ # not Search(r'\boperator\W', line) and
+ # not Match(r'\s*(<.*>)?(::[a-zA-Z0-9_]+)*\s*\(([^"]|$)', match.group(4))):
+ # if Search(r'\bconst\b', line):
+ # error(filename, linenum, 'runtime/string', 4,
+ # 'For a static/global string constant, use a C style string '
+ # 'instead: "%schar%s %s[]".' %
+ # (match.group(1), match.group(2) or '', match.group(3)))
+ # else:
+ # error(filename, linenum, 'runtime/string', 4,
+ # 'Static/global string variables are not permitted.')
if (Search(r'\b([A-Za-z0-9_]*_)\(\1\)', line) or
Search(r'\b([A-Za-z0-9_]*_)\(CHECK_NOTNULL\(\1\)\)', line)):
@@ -5720,7 +5729,8 @@ def CheckForNonConstReference(filename, clean_lines, linenum,
decls = ReplaceAll(r'{[^}]*}', ' ', line) # exclude function body
for parameter in re.findall(_RE_PATTERN_REF_PARAM, decls):
if (not Match(_RE_PATTERN_CONST_REF_PARAM, parameter) and
- not Match(_RE_PATTERN_REF_STREAM_PARAM, parameter)):
+ not Match(_RE_PATTERN_REF_STREAM_PARAM, parameter) and
+ not Match(r'benchmark', parameter)): # fix for gtest
error(filename, linenum, 'runtime/references', 2,
'Is this a non-const reference? '
'If so, make const or use a pointer: ' +
@@ -6937,3 +6947,4 @@ def main():
if __name__ == '__main__':
main()
+