CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
config.py
Go to the documentation of this file.
1 __author__="Aurelija"
2 __date__ ="$2010-08-06 14.27.51$"
3 
4 import os
6 from Utilities.ReleaseScripts.cmsCodeRules.cppFunctionSkipper import filterFiles as function
7 ordering = ['1', '2', '3', '4', '5', '6']
8 
9 # default values for directories
10 
11 checkPath = os.getcwd()
12 picklePath = os.getcwd()
13 txtPath = os.getcwd()
14 htmlPath = os.getcwd()
15 
16 # exception for directories and files
17 
18 exceptPaths = []
19 
20 # --------------------------------------------------------------------------------
21 # configuration info for each rule ...
22 
23 rulesNames = []
24 Configuration = {}
25 
26 # --------------------------------------------------------------------------------
27 
28 # configuration for rule 1
29 
30 ruleName = '1'
31 rulesNames.append(ruleName)
32 Configuration[ruleName] = {}
33 
34 Configuration[ruleName]['description'] = 'Search for "using namespace" or "using std::" in header files'
35 Configuration[ruleName]['filesToMatch'] = ['*.h']
36 Configuration[ruleName]['exceptPaths'] = []
37 Configuration[ruleName]['skip'] = [comment, function]
38 Configuration[ruleName]['filter'] = '(\susing|\Ausing)\s+(namespace|std::)' #should be regular expression
39 Configuration[ruleName]['exceptFilter'] = []
40 
41 # --------------------------------------------------------------------------------
42 
43 # configuration for rule 2
44 
45 ruleName = '2'
46 rulesNames.append(ruleName)
47 Configuration[ruleName] = {}
48 
49 Configuration[ruleName]['description'] = 'Search for CXXFLAGS flags that are set to -g or -O0 in BuildFile'
50 Configuration[ruleName]['filesToMatch'] = ['BuildFile', 'BuildFile.xml']
51 Configuration[ruleName]['exceptPaths'] = []
52 Configuration[ruleName]['skip'] = [comment]
53 Configuration[ruleName]['filter'] = '\s(CXXFLAGS|CPPFLAGS)(\+|=|\w|\"|\'|-|\s)*(-g|-O0)(\s|\'|\")' #should be regular expression
54 Configuration[ruleName]['exceptFilter'] = []
55 
56 # --------------------------------------------------------------------------------
57 
58 # configuration for rule 3
59 
60 ruleName = '3'
61 rulesNames.append(ruleName)
62 Configuration[ruleName] = {}
63 
64 Configuration[ruleName]['description'] = 'Search for "catch(...)" statements in *.cc, *.cxx files'
65 Configuration[ruleName]['filesToMatch'] = ['*.cc', '*.cxx']
66 Configuration[ruleName]['exceptPaths'] = ['FWCore/*', 'EventFilter/*', '*/*/test/*', '*/*/bin/*']
67 Configuration[ruleName]['skip'] = [comment]
68 Configuration[ruleName]['filter'] = 'catch\s*\(\s*\.\.\.\s*\)' #should be regular expression
69 Configuration[ruleName]['exceptFilter'] = []
70 # --------------------------------------------------------------------------------
71 
72 # configuration for rule 4
73 
74 ruleName = '4'
75 rulesNames.append(ruleName)
76 Configuration[ruleName] = {}
77 
78 Configuration[ruleName]['description'] = 'Search for "copyright" declaration in *.c, *.cc, *.cxx, *.h files'
79 Configuration[ruleName]['filesToMatch'] = ['*.h', '*.c', '*.cc', '*.cxx']
80 Configuration[ruleName]['exceptPaths'] = [
81  'FWCore/Utilities/interface/math_private.h',
82  'FWCore/Utilities/interface/md5.h',
83  'FWCore/Utilities/interface/tinyxml.h',
84  'FWCore/Utilities/src/md5.c',
85  'FWCore/Utilities/src/tinyxml.cc',
86  'FWCore/Utilities/src/tinyxmlerror.cc',
87  'FWCore/Utilities/src/tinyxmlparser.cc',
88  'DataFormats/Common/interface/Trie.h',
89  'DataFormats/Math/interface/sse_mathfun.h',
90  'EventFilter/Processor/src/procUtils.cc',
91  'CondCore/ORA/src/GenMD5.cc',
92  'PhysicsTools/JetMCUtils/interface/combination.h',
93  ] #could be file name, dir, fileName:line. But path should be only from that directory in which we are searching
94 Configuration[ruleName]['skip'] = []
95 Configuration[ruleName]['filter'] = '(\A|\W)(c|C)(o|O)(p|P)(y|Y)(r|R)(i|I)(g|G)(h|H)(t|T)\W(\+|=|\w|\"|\'|-|\s)*(\((c|C)\)|\d{4})' #should be regular expression
96 Configuration[ruleName]['exceptFilter'] = []
97 
98 # --------------------------------------------------------------------------------
99 
100 # configuration for rule 5
101 
102 ruleName = '5'
103 rulesNames.append(ruleName)
104 Configuration[ruleName] = {}
105 
106 Configuration[ruleName]['description'] = 'Search for "pragma" statement in *.c, *.cc, *.cxx, *.h files'
107 Configuration[ruleName]['filesToMatch'] = ['*.h', '*.c', '*.cc', '*.cxx']
108 Configuration[ruleName]['exceptPaths'] = ['*/*LinkDef.h',
109  'FWCore/Utilities/interface/tinyxml.h',
110  'Utilities/StorageFactory/src/LocalFileSystem.cc:.*:#\s*pragma\s+GCC\s+diagnostic\s+ignored',
111  'RecoVertex/BeamSpotProducer/test/scripts/BSVectorDict.h',
112  'FWCore/Utilities/*/*:.*:#\s*pragma\s+GCC\s+visibility\s+(push\\(default\\)|pop)\s*$',
113  ]#could be file name, dir, fileName:line. Path should be only from that directory in which we are searching
114 Configuration[ruleName]['skip'] = [comment]
115 Configuration[ruleName]['filter'] = '#\s*pragma\s' #should be regular expression
116 Configuration[ruleName]['exceptFilter'] = []
117 # --------------------------------------------------------------------------------
118 # configuration for rule 6
119 
120 ruleName = '6'
121 rulesNames.append(ruleName)
122 Configuration[ruleName] = {}
123 
124 Configuration[ruleName]['description'] = 'Search for "flags" statements in BuildFile'
125 Configuration[ruleName]['filesToMatch'] = ['BuildFile', 'BuildFile.xml']
126 Configuration[ruleName]['exceptPaths'] = ['Utilities/RFIOAdaptor/*BuildFile.xml:.*:NO_LIB_CHECKING=', #could be file name, dir, fileName:line, fileName:lineNORegEx:LineRegEx:. Path should be only from that directory in which we are searching
127  'Utilities/RFIOAdaptor/*BuildFile.xml:.*:_FILE_OFFSET_BITS=',
128  'Utilities/DCacheAdaptor/*BuildFile.xml:.*:_FILE_OFFSET_BITS=',
129  'Utilities/XrdAdaptor/*BuildFile.xml:.*:_FILE_OFFSET_BITS=',
130  'Utilities/StorageFactory/*BuildFile.xml:.*:_FILE_OFFSET_BITS=',
131  'Utilities/LStoreAdaptor/BuildFile.xml:.*:_FILE_OFFSET_BITS=',
132  'DQM/EcalEndcapMonitorClient/plugins/BuildFile.xml:.*:"WITH_ECAL_COND_DB"',
133  'DQM/EcalBarrelMonitorClient/plugins/BuildFile.xml:.*:"WITH_ECAL_COND_DB"',
134  'DQM/CSCMonitorModule/*BuildFile.xml:.*:="DQMGLOBAL"',
135  'DQMServices/Core/*BuildFile.xml:.*:="-DWITHOUT_CMS_FRAMEWORK=0"',
136  'L1Trigger/CSCTrackFinder/BuildFile.xml:.*:ADD_SUBDIR=',
137  'MagneticField/Interpolation/BuildFile.xml:.*:="-Wno-format"',
138  'MagneticField/Interpolation/test/BuildFile.xml:.*:="-Wno-format"',
139  'GeneratorInterface/Pythia6Interface/plugins/BuildFile.xml:.*:LDFLAGS="\$\(PYTHIA6_BASE\)/lib/pydata.o"',
140  ]
141 Configuration[ruleName]['skip'] = [comment]
142 Configuration[ruleName]['filter'] = '<\s*(f|F)(l|L)(a|A)(g|G)(s|S)\s+' #should be regular expression
143 Configuration[ruleName]['exceptFilter'] = ['EDM_PLUGIN','RIVET_PLUGIN', 'GENREFLEX_ARGS', 'TEST_RUNNER_ARGS', 'INSTALL_SCRIPTS', 'NO_TESTRUN', 'NO_EXPORT']
144 # --------------------------------------------------------------------------------
145 
146 rulesDescription = "Rule number Description\n"
147 rulesDescription += "----------------------------------------------------------------------------------------\n"
148 for key, value in Configuration.items():
149  rulesDescription += " %s %s\n" %(key, value['description'])
150 
151 # --------------------------------------------------------------------------------
152 helpMsg = "-----------------------------------------------------------HELP-----------------------------------------------------------\n"
153 helpMsg += "cmsCodeRulesChecker.py [-h] [-html] [-s [DIRECTORY]] [-S [DIRECTORY]] [-p] [-r ruleNumber[,ruleNumber[, ...]]] [-d DIRECTORY]\n\n"
154 helpMsg += "-r Specifies rule or rules to be checked. After this parameter should\n be at least one rule given.\n"
155 helpMsg += "-d Specifies that rules should be checked in DIRECTORY. Default \n directory - current directory\n"
156 helpMsg += "-S Specifies to save results in python pickle files. Directory specifies\n where to store these files. Default directory - current directory\n"
157 helpMsg += "-s Specifies to save results in .txt files. Directory specifies where to\n store these files. Default directory - current directory\n"
158 helpMsg += "-p Specifies to print results into a screen\n"
159 helpMsg += "-h Prints help message\n"
160 helpMsg += "-html Reads pickle files and creates cmsCRPage.html\n\n"
161 helpMsg += "By default cmsCodeRulesChecker.py checks all rules in current directory and prints results into screen.\n\n"
162 helpMsg += rulesDescription