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  'CondFormats/JetMETObjects/interface/Linkdef.h',
114  'DataFormats/GeometryVector/interface/Basic3DVectorLD.h',
115  'DataFormats/Scalers/interface/ScalersRaw.h',
116  'FWCore/MessageService/plugins/Module.cc',
117  'GeneratorInterface/RivetInterface/plugins/tinyxml.h',
118  'PerfTools/Callgrind/plugins/CallgrindAnalyzer.cc',
119  'PerfTools/Callgrind/src/ProfilerService.cc',
120  'RecoTracker/TkDetLayers/src/BladeShapeBuilderFromDet.h',
121  'RecoTracker/TkDetLayers/src/BoundDiskSector.h',
122  'RecoTracker/TkDetLayers/src/CompatibleDetToGroupAdder.h',
123  'RecoTracker/TkDetLayers/src/CompositeTECPetal.h',
124  'RecoTracker/TkDetLayers/src/CompositeTECWedge.h',
125  'RecoTracker/TkDetLayers/src/DetGroupMerger.h',
126  'RecoTracker/TkDetLayers/src/DiskSectorBounds.h',
127  'RecoTracker/TkDetLayers/src/ForwardDiskSectorBuilderFromDet.h',
128  'RecoTracker/TkDetLayers/src/ForwardDiskSectorBuilderFromWedges.h',
129  'RecoTracker/TkDetLayers/src/GlobalDetRodRangeZPhi.h',
130  'RecoTracker/TkDetLayers/src/LayerCrossingSide.h',
131  'RecoTracker/TkDetLayers/src/PixelBarrelLayerBuilder.h',
132  'RecoTracker/TkDetLayers/src/PixelBarrelLayer.h',
133  'RecoTracker/TkDetLayers/src/PixelBladeBuilder.h',
134  'RecoTracker/TkDetLayers/src/PixelBlade.h',
135  'RecoTracker/TkDetLayers/src/PixelForwardLayerBuilder.h',
136  'RecoTracker/TkDetLayers/src/PixelForwardLayer.h',
137  'RecoTracker/TkDetLayers/src/PixelForwardLayerPhase1.h',
138  'RecoTracker/TkDetLayers/src/PixelRodBuilder.h',
139  'RecoTracker/TkDetLayers/src/PixelRod.h',
140  'RecoTracker/TkDetLayers/src/SimpleTECWedge.h',
141  'RecoTracker/TkDetLayers/src/SubLayerCrossings.h',
142  'RecoTracker/TkDetLayers/src/TECLayerBuilder.h',
143  'RecoTracker/TkDetLayers/src/TECLayer.h',
144  'RecoTracker/TkDetLayers/src/TECPetalBuilder.h',
145  'RecoTracker/TkDetLayers/src/TECPetal.h',
146  'RecoTracker/TkDetLayers/src/TECWedgeBuilder.h',
147  'RecoTracker/TkDetLayers/src/TECWedge.h',
148  'RecoTracker/TkDetLayers/src/TIBLayerBuilder.h',
149  'RecoTracker/TkDetLayers/src/TIBLayer.h',
150  'RecoTracker/TkDetLayers/src/TIBRingBuilder.h',
151  'RecoTracker/TkDetLayers/src/TIBRing.h',
152  'RecoTracker/TkDetLayers/src/TIDLayerBuilder.h',
153  'RecoTracker/TkDetLayers/src/TIDLayer.h',
154  'RecoTracker/TkDetLayers/src/TIDRingBuilder.h',
155  'RecoTracker/TkDetLayers/src/TkDetUtil.h',
156  'RecoTracker/TkDetLayers/src/TkGeomDetCompatibilityChecker.h',
157  'RecoTracker/TkDetLayers/src/TOBLayerBuilder.h',
158  'RecoTracker/TkDetLayers/src/TOBLayer.h',
159  'RecoTracker/TkDetLayers/src/TOBRodBuilder.h',
160  'RecoTracker/TkDetLayers/src/TOBRod.h',
161  'RecoTracker/TkDetLayers/src/TIDRing.h',
162  ]#could be file name, dir, fileName:line. Path should be only from that directory in which we are searching
163 Configuration[ruleName]['skip'] = [comment]
164 Configuration[ruleName]['filter'] = '#\s*pragma\s' #should be regular expression
165 Configuration[ruleName]['exceptFilter'] = []
166 # --------------------------------------------------------------------------------
167 # configuration for rule 6
168 
169 ruleName = '6'
170 rulesNames.append(ruleName)
171 Configuration[ruleName] = {}
172 
173 Configuration[ruleName]['description'] = 'Search for "flags" statements in BuildFile'
174 Configuration[ruleName]['filesToMatch'] = ['BuildFile', 'BuildFile.xml']
175 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
176  'Utilities/RFIOAdaptor/*BuildFile.xml:.*:_FILE_OFFSET_BITS=',
177  'Utilities/DCacheAdaptor/*BuildFile.xml:.*:_FILE_OFFSET_BITS=',
178  'Utilities/XrdAdaptor/*BuildFile.xml:.*:_FILE_OFFSET_BITS=',
179  'Utilities/StorageFactory/*BuildFile.xml:.*:_FILE_OFFSET_BITS=',
180  'Utilities/LStoreAdaptor/BuildFile.xml:.*:_FILE_OFFSET_BITS=',
181  'DQM/CSCMonitorModule/*BuildFile.xml:.*:="DQMGLOBAL"',
182  'DQMServices/Core/*BuildFile.xml:.*:="-DWITHOUT_CMS_FRAMEWORK=0"',
183  'L1Trigger/CSCTrackFinder/BuildFile.xml:.*:ADD_SUBDIR=',
184  'MagneticField/Interpolation/BuildFile.xml:.*:="-Wno-format"',
185  'MagneticField/Interpolation/test/BuildFile.xml:.*:="-Wno-format"',
186  'GeneratorInterface/Pythia6Interface/plugins/BuildFile.xml:.*:LDFLAGS="\$\(PYTHIA6_BASE\)/lib/pydata.o"',
187  ]
188 Configuration[ruleName]['skip'] = [comment]
189 Configuration[ruleName]['filter'] = '<\s*(f|F)(l|L)(a|A)(g|G)(s|S)\s+' #should be regular expression
190 Configuration[ruleName]['exceptFilter'] = ['EDM_PLUGIN','RIVET_PLUGIN', 'GENREFLEX_ARGS', 'TEST_RUNNER_ARGS', 'INSTALL_SCRIPTS', 'NO_TESTRUN', 'NO_EXPORT']
191 # --------------------------------------------------------------------------------
192 
193 rulesDescription = "Rule number Description\n"
194 rulesDescription += "----------------------------------------------------------------------------------------\n"
195 for key, value in Configuration.items():
196  rulesDescription += " %s %s\n" %(key, value['description'])
197 
198 # --------------------------------------------------------------------------------
199 helpMsg = "-----------------------------------------------------------HELP-----------------------------------------------------------\n"
200 helpMsg += "cmsCodeRulesChecker.py [-h] [-html] [-s [DIRECTORY]] [-S [DIRECTORY]] [-p] [-r ruleNumber[,ruleNumber[, ...]]] [-d DIRECTORY]\n\n"
201 helpMsg += "-r Specifies rule or rules to be checked. After this parameter should\n be at least one rule given.\n"
202 helpMsg += "-d Specifies that rules should be checked in DIRECTORY. Default \n directory - current directory\n"
203 helpMsg += "-S Specifies to save results in python pickle files. Directory specifies\n where to store these files. Default directory - current directory\n"
204 helpMsg += "-s Specifies to save results in .txt files. Directory specifies where to\n store these files. Default directory - current directory\n"
205 helpMsg += "-p Specifies to print results into a screen\n"
206 helpMsg += "-h Prints help message\n"
207 helpMsg += "-html Reads pickle files and creates cmsCRPage.html\n\n"
208 helpMsg += "By default cmsCodeRulesChecker.py checks all rules in current directory and prints results into screen.\n\n"
209 helpMsg += rulesDescription