CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/Utilities/ReleaseScripts/python/cmsCodeRules/config.py

Go to the documentation of this file.
00001 __author__="Aurelija"
00002 __date__ ="$2010-08-06 14.27.51$"
00003 
00004 import os
00005 from Utilities.ReleaseScripts.commentSkipper.commentSkipper import filter as comment
00006 from Utilities.ReleaseScripts.cmsCodeRules.cppFunctionSkipper import filterFiles as function
00007 ordering = ['1', '2', '3', '4', '5', '6']
00008 
00009 # default values for directories
00010 
00011 checkPath = os.getcwd()
00012 picklePath = os.getcwd()
00013 txtPath = os.getcwd()
00014 htmlPath = os.getcwd()
00015 
00016 # exception for directories and files 
00017 
00018 exceptPaths = []
00019 
00020 # --------------------------------------------------------------------------------
00021 # configuration info for each rule ...
00022 
00023 rulesNames = []
00024 Configuration = {}
00025 
00026 # --------------------------------------------------------------------------------
00027 
00028 # configuration for rule 1
00029 
00030 ruleName = '1'
00031 rulesNames.append(ruleName)
00032 Configuration[ruleName] = {}
00033 
00034 Configuration[ruleName]['description'] = 'Search for "using namespace" or "using std::" in header files'
00035 Configuration[ruleName]['filesToMatch'] = ['*.h']
00036 Configuration[ruleName]['exceptPaths'] = []
00037 Configuration[ruleName]['skip']  = [comment, function]
00038 Configuration[ruleName]['filter'] = '(\susing|\Ausing)\s+(namespace|std::)' #should be regular expression
00039 Configuration[ruleName]['exceptFilter'] = []
00040 
00041 # --------------------------------------------------------------------------------
00042 
00043 # configuration for rule 2
00044 
00045 ruleName = '2'
00046 rulesNames.append(ruleName)
00047 Configuration[ruleName] = {}
00048 
00049 Configuration[ruleName]['description'] = 'Search for CXXFLAGS flags that are set to -g or -O0 in BuildFile'
00050 Configuration[ruleName]['filesToMatch'] = ['BuildFile', 'BuildFile.xml']
00051 Configuration[ruleName]['exceptPaths'] = []
00052 Configuration[ruleName]['skip']  = [comment]
00053 Configuration[ruleName]['filter'] = '\s(CXXFLAGS|CPPFLAGS)(\+|=|\w|\"|\'|-|\s)*(-g|-O0)(\s|\'|\")' #should be regular expression
00054 Configuration[ruleName]['exceptFilter'] = []
00055 
00056 # --------------------------------------------------------------------------------
00057 
00058 # configuration for rule 3
00059 
00060 ruleName = '3'
00061 rulesNames.append(ruleName)
00062 Configuration[ruleName] = {}
00063 
00064 Configuration[ruleName]['description'] = 'Search for "catch(...)" statements in *.cc, *.cxx files'
00065 Configuration[ruleName]['filesToMatch'] = ['*.cc', '*.cxx']
00066 Configuration[ruleName]['exceptPaths'] = ['FWCore/*', 'EventFilter/*', '*/*/test/*', '*/*/bin/*']
00067 Configuration[ruleName]['skip']  = [comment]
00068 Configuration[ruleName]['filter'] = 'catch\s*\(\s*\.\.\.\s*\)' #should be regular expression
00069 Configuration[ruleName]['exceptFilter'] = []
00070 # --------------------------------------------------------------------------------
00071 
00072 # configuration for rule 4
00073 
00074 ruleName = '4'
00075 rulesNames.append(ruleName)
00076 Configuration[ruleName] = {}
00077 
00078 Configuration[ruleName]['description'] = 'Search for "copyright" declaration in *.c, *.cc, *.cxx, *.h files'
00079 Configuration[ruleName]['filesToMatch'] = ['*.h', '*.c', '*.cc', '*.cxx']
00080 Configuration[ruleName]['exceptPaths'] = [
00081                                            'FWCore/Utilities/interface/math_private.h',
00082                                            'FWCore/Utilities/interface/md5.h',
00083                                            'FWCore/Utilities/interface/tinyxml.h',
00084                                            'FWCore/Utilities/src/md5.c',
00085                                            'FWCore/Utilities/src/tinyxml.cc',
00086                                            'FWCore/Utilities/src/tinyxmlerror.cc',
00087                                            'FWCore/Utilities/src/tinyxmlparser.cc',
00088                                            'DataFormats/Common/interface/Trie.h',
00089                                            'DataFormats/Math/interface/sse_mathfun.h',
00090                                            'EventFilter/Processor/src/procUtils.cc',
00091                                            'CondCore/ORA/src/GenMD5.cc',
00092                                            'PhysicsTools/JetMCUtils/interface/combination.h',
00093                                          ] #could be file name, dir, fileName:line. But path should be only from that directory in which we are searching
00094 Configuration[ruleName]['skip']  = []
00095 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
00096 Configuration[ruleName]['exceptFilter'] = []
00097 
00098 # --------------------------------------------------------------------------------
00099 
00100 # configuration for rule 5
00101 
00102 ruleName = '5'
00103 rulesNames.append(ruleName)
00104 Configuration[ruleName] = {}
00105 
00106 Configuration[ruleName]['description'] = 'Search for "pragma" statement in *.c, *.cc, *.cxx, *.h files'
00107 Configuration[ruleName]['filesToMatch'] = ['*.h', '*.c', '*.cc', '*.cxx']
00108 Configuration[ruleName]['exceptPaths'] = ['*/*LinkDef.h',
00109                                           'FWCore/Utilities/interface/tinyxml.h',
00110                                           'Utilities/StorageFactory/src/LocalFileSystem.cc:.*:#\s*pragma\s+GCC\s+diagnostic\s+ignored',
00111                                           'RecoVertex/BeamSpotProducer/test/scripts/BSVectorDict.h',
00112                                           'FWCore/Utilities/*/*:.*:#\s*pragma\s+GCC\s+visibility\s+(push\\(default\\)|pop)\s*$',
00113                                          ]#could be file name, dir, fileName:line. Path should be only from that directory in which we are searching
00114 Configuration[ruleName]['skip']  = [comment]
00115 Configuration[ruleName]['filter'] = '#\s*pragma\s' #should be regular expression
00116 Configuration[ruleName]['exceptFilter'] = []
00117 # --------------------------------------------------------------------------------
00118 # configuration for rule 6
00119 
00120 ruleName = '6'
00121 rulesNames.append(ruleName)
00122 Configuration[ruleName] = {}
00123 
00124 Configuration[ruleName]['description'] = 'Search for "flags" statements in BuildFile'
00125 Configuration[ruleName]['filesToMatch'] = ['BuildFile', 'BuildFile.xml']
00126 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
00127                                           'Utilities/RFIOAdaptor/*BuildFile.xml:.*:_FILE_OFFSET_BITS=',
00128                                           'Utilities/DCacheAdaptor/*BuildFile.xml:.*:_FILE_OFFSET_BITS=',
00129                                           'Utilities/XrdAdaptor/*BuildFile.xml:.*:_FILE_OFFSET_BITS=',
00130                                           'Utilities/StorageFactory/*BuildFile.xml:.*:_FILE_OFFSET_BITS=',
00131                                           'Utilities/LStoreAdaptor/BuildFile.xml:.*:_FILE_OFFSET_BITS=',
00132                                           'DQM/EcalEndcapMonitorClient/plugins/BuildFile.xml:.*:"WITH_ECAL_COND_DB"',
00133                                           'DQM/EcalBarrelMonitorClient/plugins/BuildFile.xml:.*:"WITH_ECAL_COND_DB"',
00134                                           'DQM/CSCMonitorModule/*BuildFile.xml:.*:="DQMGLOBAL"',
00135                                           'DQMServices/Core/*BuildFile.xml:.*:="-DWITHOUT_CMS_FRAMEWORK=0"',
00136                                           'L1Trigger/CSCTrackFinder/BuildFile.xml:.*:ADD_SUBDIR=',
00137                                           'MagneticField/Interpolation/BuildFile.xml:.*:="-Wno-format"',
00138                                           'MagneticField/Interpolation/test/BuildFile.xml:.*:="-Wno-format"',
00139                                           'GeneratorInterface/Pythia6Interface/plugins/BuildFile.xml:.*:LDFLAGS="\$\(PYTHIA6_BASE\)/lib/pydata.o"',
00140                                          ]
00141 Configuration[ruleName]['skip']  = [comment]
00142 Configuration[ruleName]['filter'] = '<\s*(f|F)(l|L)(a|A)(g|G)(s|S)\s+' #should be regular expression
00143 Configuration[ruleName]['exceptFilter'] = ['EDM_PLUGIN','RIVET_PLUGIN', 'GENREFLEX_ARGS', 'TEST_RUNNER_ARGS', 'INSTALL_SCRIPTS', 'NO_TESTRUN', 'NO_EXPORT']
00144 # --------------------------------------------------------------------------------
00145 
00146 rulesDescription  = "Rule number    Description\n"
00147 rulesDescription += "----------------------------------------------------------------------------------------\n"
00148 for key, value in Configuration.items():
00149     rulesDescription += "     %s         %s\n" %(key, value['description'])
00150 
00151 # --------------------------------------------------------------------------------
00152 helpMsg  = "-----------------------------------------------------------HELP-----------------------------------------------------------\n"
00153 helpMsg += "cmsCodeRulesChecker.py [-h] [-html] [-s [DIRECTORY]] [-S [DIRECTORY]] [-p] [-r ruleNumber[,ruleNumber[, ...]]] [-d DIRECTORY]\n\n"
00154 helpMsg += "-r     Specifies rule or rules to be checked. After this parameter should\n       be at least one rule given.\n"
00155 helpMsg += "-d     Specifies that rules should be checked in DIRECTORY. Default \n       directory - current directory\n"
00156 helpMsg += "-S     Specifies to save results in python pickle files. Directory specifies\n       where to store these files. Default directory - current directory\n"
00157 helpMsg += "-s     Specifies to save results in .txt files. Directory specifies where to\n       store these files. Default directory - current directory\n"
00158 helpMsg += "-p     Specifies to print results into a screen\n"
00159 helpMsg += "-h     Prints help message\n"
00160 helpMsg += "-html  Reads pickle files and creates cmsCRPage.html\n\n"
00161 helpMsg += "By default cmsCodeRulesChecker.py checks all rules in current directory and prints results into screen.\n\n"
00162 helpMsg += rulesDescription