~widelands-dev/widelands/bug-1808169-disable-focus

« back to all changes in this revision

Viewing changes to cmake/codecheck/rules/contrived_std_string_find

  • Committer: qcs
  • Date: 2010-02-05 01:13:20 UTC
  • Revision ID: git-v1:136d6c48811c97ec1f98301726134b0de66f868c
Manual merge of cmake-migration branch to trunk

git-svn-id: https://widelands.svn.sourceforge.net/svnroot/widelands/trunk@5030 37b2a8de-5219-0410-9f54-a31bc463ab9c

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
 
 
4
"""
 
5
Do not call std::string::find_first_of or std::string::find with a string of
 
6
characters to locate that has the size 1. Use the version of
 
7
std::string::find that takes a single character to locate instead. Same for
 
8
find_last_of/rfind.
 
9
"""
 
10
 
 
11
error_msg = "Do not use find(\"a\"), use find('a')."
 
12
 
 
13
regexp = r"""r?find(_(first|last)_of)? *\("([^\]|\\[nt\"])"[,)]"""
 
14
 
 
15
forbidden = [
 
16
    'find_first_of("a")',
 
17
    'find_last_of("a")',
 
18
    'find("a")',
 
19
    'rfind("a")',
 
20
    'find_first_of("\\n")',
 
21
    'find_last_of("\\n")',
 
22
    'find("\\n")',
 
23
    'rfind("\\n")',
 
24
    'find_first_of("\\t")',
 
25
    'find_last_of("\\t")',
 
26
    'find("\\t")',
 
27
    'rfind("\\t")',
 
28
    'find_first_of("\\\\")',
 
29
    'find_last_of("\\\\")',
 
30
    'find("\\\\")',
 
31
    'rfind("\\\\")',
 
32
    'find_first_of("\\"")',
 
33
    'find_last_of("\\"")',
 
34
    'find("\\"")',
 
35
    'rfind("\\"")',
 
36
    'find_first_of("a", 1)',
 
37
    'find_last_of("a", 1)',
 
38
    'find("a", 1)',
 
39
    'rfind("a", 1)',
 
40
]
 
41
 
 
42
allowed = [
 
43
    'find("ab")',
 
44
    "find('a')",
 
45
    "rfind('a')",
 
46
    'rfind("ab")',
 
47
    "find('\\n')",
 
48
    'find("\\nx")',
 
49
    "rfind('\\n')",
 
50
    'rfind("\\nx")',
 
51
    "find('\\t')",
 
52
    'find("\\tx")',
 
53
    "rfind('\\t')",
 
54
    'rfind("\\tx")',
 
55
    "find('\\\\')",
 
56
    'find("\\\\x")',
 
57
    "rfind('\\\\')",
 
58
    'rfind("\\\\x")',
 
59
    "find('\\\"')",
 
60
    'find("\\"x")',
 
61
    "rfind('\\\"')",
 
62
    'rfind("\\"x")',
 
63
    "find('a', 1)",
 
64
    'find("ab", 1)',
 
65
    "rfind('a', 1)",
 
66
    'rfind("ab", 1)',
 
67
]