contrib/check-code.py
changeset 16702 1751d96d324f
parent 16683 525fdb738975
child 16704 1f3acc30bdfe
equal deleted inserted replaced
16701:34c30506dd4e 16702:1751d96d324f
   133     (r'\w,\w', "missing whitespace after ,"),
   133     (r'\w,\w', "missing whitespace after ,"),
   134     (r'\w[+/*\-<>]\w', "missing whitespace in expression"),
   134     (r'\w[+/*\-<>]\w', "missing whitespace in expression"),
   135     (r'^\s+\w+=\w+[^,)\n]$', "missing whitespace in assignment"),
   135     (r'^\s+\w+=\w+[^,)\n]$', "missing whitespace in assignment"),
   136     (r'(\s+)try:\n((?:\n|\1\s.*\n)+?)\1except.*?:\n'
   136     (r'(\s+)try:\n((?:\n|\1\s.*\n)+?)\1except.*?:\n'
   137      r'((?:\n|\1\s.*\n)+?)\1finally:', 'no try/except/finally in Py2.4'),
   137      r'((?:\n|\1\s.*\n)+?)\1finally:', 'no try/except/finally in Py2.4'),
   138     (r'.{85}', "line too long"),
   138     (r'.{81}', "line too long"),
   139     (r' x+[xo][\'"]\n\s+[\'"]x', 'string join across lines with no space'),
   139     (r' x+[xo][\'"]\n\s+[\'"]x', 'string join across lines with no space'),
   140     (r'[^\n]\Z', "no trailing newline"),
   140     (r'[^\n]\Z', "no trailing newline"),
   141     (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"),
   141     (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"),
   142 #    (r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=',
   142 #    (r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=',
   143 #     "don't use underbars in identifiers"),
   143 #     "don't use underbars in identifiers"),
   204     (r'\.debug\(\_', "don't mark debug messages for translation"),
   204     (r'\.debug\(\_', "don't mark debug messages for translation"),
   205     (r'\.strip\(\)\.split\(\)', "no need to strip before splitting"),
   205     (r'\.strip\(\)\.split\(\)', "no need to strip before splitting"),
   206   ],
   206   ],
   207   # warnings
   207   # warnings
   208   [
   208   [
   209     (r'.{81}', "warning: line over 80 characters"),
       
   210     (r'^\s*except:$', "warning: naked except clause"),
   209     (r'^\s*except:$', "warning: naked except clause"),
   211     (r'ui\.(status|progress|write|note|warn)\([\'\"]x',
   210     (r'ui\.(status|progress|write|note|warn)\([\'\"]x',
   212      "warning: unwrapped ui message"),
   211      "warning: unwrapped ui message"),
   213   ]
   212   ]
   214 ]
   213 ]
   224   [
   223   [
   225     (r'//', "don't use //-style comments"),
   224     (r'//', "don't use //-style comments"),
   226     (r'^  ', "don't use spaces to indent"),
   225     (r'^  ', "don't use spaces to indent"),
   227     (r'\S\t', "don't use tabs except for indent"),
   226     (r'\S\t', "don't use tabs except for indent"),
   228     (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"),
   227     (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"),
   229     (r'.{85}', "line too long"),
   228     (r'.{81}', "line too long"),
   230     (r'(while|if|do|for)\(', "use space after while/if/do/for"),
   229     (r'(while|if|do|for)\(', "use space after while/if/do/for"),
   231     (r'return\(', "return is not a function"),
   230     (r'return\(', "return is not a function"),
   232     (r' ;', "no space before ;"),
   231     (r' ;', "no space before ;"),
   233     (r'\w+\* \w+', "use int *foo, not int* foo"),
   232     (r'\w+\* \w+', "use int *foo, not int* foo"),
   234     (r'\([^\)]+\) \w+', "use (int)foo, not (int) foo"),
   233     (r'\([^\)]+\) \w+', "use (int)foo, not (int) foo"),